GroupsController.cs 832 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922
  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. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  941. string title = $"系统通知";
  942. string content = $"团组[{groupName}]已确认出团!";
  943. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  944. }
  945. catch (Exception ex)
  946. {
  947. }
  948. #endregion
  949. #region 应用推送
  950. try
  951. {
  952. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  953. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  954. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  955. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  956. {
  957. List<string> userList = new List<string>() { users.QiyeChatUserId };
  958. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  959. }
  960. }
  961. catch (Exception ex)
  962. {
  963. }
  964. #endregion
  965. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  966. return Ok(JsonView(true, "操作成功!", groupData.Data));
  967. }
  968. /// <summary>
  969. /// 获取团组名称data And 签证国别Data
  970. /// </summary>
  971. /// <param name="dto"></param>
  972. /// <returns></returns>
  973. [HttpPost]
  974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  975. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  976. {
  977. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(groupData.Data));
  983. }
  984. /// <summary>
  985. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  986. /// </summary>
  987. /// <returns></returns>
  988. [HttpPost]
  989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  990. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  991. {
  992. try
  993. {
  994. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  995. if (groupData.Code != 0)
  996. {
  997. return Ok(JsonView(false, groupData.Msg));
  998. }
  999. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1000. }
  1001. catch (Exception ex)
  1002. {
  1003. return Ok(JsonView(false, "程序错误!"));
  1004. throw;
  1005. }
  1006. }
  1007. /// <summary>
  1008. /// 团组清单 Excel
  1009. /// </summary>
  1010. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1011. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1012. /// <returns></returns>
  1013. [HttpGet]
  1014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1015. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1016. {
  1017. DateTime _beginDt, _endDt;
  1018. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1019. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1020. if (!beginBool && !endBool)
  1021. {
  1022. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1023. }
  1024. string sql = string.Format(@"
  1025. SELECT
  1026. ROW_NUMBER,
  1027. Id,
  1028. SalesQuoteNo,
  1029. TourCode,
  1030. TeamTypeId,
  1031. TeamType,
  1032. TeamLevId,
  1033. TeamLev,
  1034. TeamName,
  1035. ClientName,
  1036. ClientUnit,
  1037. VisitDate,
  1038. VisitDays,
  1039. VisitPNumber,
  1040. JietuanOperatorId,
  1041. JietuanOperator,
  1042. IsSure,
  1043. CreateTime,
  1044. IsBid
  1045. FROM
  1046. (
  1047. SELECT
  1048. ROW_NUMBER() OVER(
  1049. ORDER BY
  1050. gdi.CreateTime Desc
  1051. ) AS ROW_NUMBER,
  1052. gdi.Id,
  1053. SalesQuoteNo,
  1054. TourCode,
  1055. ssd.Id TeamTypeId,
  1056. ssd.Name TeamType,
  1057. ssd1.Id TeamLevId,
  1058. ssd1.Name TeamLev,
  1059. TeamName,
  1060. ClientName,
  1061. ClientUnit,
  1062. VisitDate,
  1063. VisitDays,
  1064. VisitPNumber,
  1065. JietuanOperator JietuanOperatorId,
  1066. su.CnName JietuanOperator,
  1067. IsSure,
  1068. gdi.CreateTime,
  1069. gdi.IsBid
  1070. FROM
  1071. Grp_DelegationInfo gdi
  1072. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1073. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1074. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1075. WHERE
  1076. gdi.IsDel = 0
  1077. AND gdi.IsBid = 0
  1078. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1079. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1080. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1081. #region 处理所属部门
  1082. /*
  1083. * 1.sq 和 gyy 等显示 市场部
  1084. * 2.王鸽和主管及张总还有管理员号统一国交部
  1085. * 2-1. 4 管理员 ,21 张海麟
  1086. */
  1087. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1088. List<int> userIds1 = new List<int>() { 4, 21 };
  1089. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1090. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1091. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1092. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1093. .ToListAsync();
  1094. foreach (var item in groupList)
  1095. {
  1096. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1097. }
  1098. #endregion
  1099. #region Excel
  1100. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1101. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1102. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1103. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1104. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1105. //载入模板
  1106. WorkbookDesigner designer = new WorkbookDesigner();
  1107. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1108. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1109. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1110. dt.TableName = "GroupList";
  1111. designer.SetDataSource(dt);
  1112. designer.Process();
  1113. if (!Directory.Exists(savePath))
  1114. {
  1115. Directory.CreateDirectory(savePath);
  1116. }
  1117. string serverPath = $"{savePath}{fileName}";
  1118. designer.Workbook.Save(serverPath);
  1119. string rst = $"{servicePath}{ftpPath}{fileName}";
  1120. #endregion
  1121. return Ok(JsonView(true, "操作成功!", rst));
  1122. }
  1123. #endregion
  1124. #region 团组&签证
  1125. /// <summary>
  1126. /// 根据团组Id获取签证客户信息List
  1127. /// </summary>
  1128. /// <param name="dto">请求dto</param>
  1129. /// <returns></returns>
  1130. [HttpPost]
  1131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1132. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1133. {
  1134. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1135. if (groupData.Code != 0)
  1136. {
  1137. return Ok(JsonView(false, groupData.Msg));
  1138. }
  1139. return Ok(JsonView(groupData.Data));
  1140. }
  1141. /// <summary>
  1142. /// IOS获取团组签证拍照上传进度01(团组列表)
  1143. /// </summary>
  1144. /// <param name="dto">请求dto</param>
  1145. /// <returns></returns>
  1146. [HttpPost]
  1147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1148. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1149. {
  1150. if (dto == null)
  1151. {
  1152. return Ok(JsonView(false, "参数为空"));
  1153. }
  1154. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1155. return Ok(JsonView(visaList));
  1156. }
  1157. /// <summary>
  1158. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1159. /// </summary>
  1160. /// <returns></returns>
  1161. [HttpPost]
  1162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1163. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1164. {
  1165. if (dto == null)
  1166. {
  1167. return Ok(JsonView(false, "请求错误:"));
  1168. }
  1169. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1170. return Ok(JsonView(list));
  1171. }
  1172. /// <summary>
  1173. /// IOS获取团组签证拍照上传进度03(相册)
  1174. /// </summary>
  1175. /// <returns></returns>
  1176. [HttpPost]
  1177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1178. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1179. {
  1180. if (dto == null)
  1181. {
  1182. return Ok(JsonView(false, "请求错误:"));
  1183. }
  1184. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1185. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1186. list.ForEach(s => s.url = url);
  1187. return Ok(JsonView(list));
  1188. }
  1189. /// <summary>
  1190. /// IOS获取团组签证拍照上传进度04(图片上传)
  1191. /// </summary>
  1192. /// <param name="dto"></param>
  1193. /// <returns></returns>
  1194. [HttpPost]
  1195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1196. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1197. {
  1198. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1199. //if (!string.IsNullOrEmpty(result))
  1200. //{
  1201. //}
  1202. //else {
  1203. // return Ok(JsonView(false, "上传失败"));
  1204. //}
  1205. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1206. int sucNum = 0;
  1207. try
  1208. {
  1209. foreach (var item in dto.base64DataList)
  1210. {
  1211. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1212. string result = decodeBase64ToImage(item, imageName);
  1213. if (!string.IsNullOrEmpty(result))
  1214. {
  1215. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1216. pic.CreateUserId = dto.CreateUserId;
  1217. pic.PicName = imageName;
  1218. pic.PicPath = result;
  1219. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1220. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1221. if (insertResult > 0)
  1222. {
  1223. sucNum++;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. catch (Exception ex)
  1229. {
  1230. return Ok(JsonView(false, ex.Message));
  1231. }
  1232. string msg = string.Format(@"成功上传{0}张", sucNum);
  1233. return Ok(JsonView(true, msg));
  1234. }
  1235. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1236. {
  1237. string filename = "";//声明一个string类型的相对路径
  1238. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1239. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1240. try//会有异常抛出,try,catch一下
  1241. {
  1242. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1243. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1244. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1245. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1246. //文件名称
  1247. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1248. //上传的文件的路径
  1249. string filePath = "";
  1250. if (!Directory.Exists(fileDir))
  1251. {
  1252. Directory.CreateDirectory(fileDir);
  1253. }
  1254. //上传的文件的路径
  1255. filePath = fileDir + filename;
  1256. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1257. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1258. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1259. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1260. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1261. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1262. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1263. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1264. bitmap.Dispose();
  1265. }
  1266. catch (Exception e)
  1267. {
  1268. string massage = e.Message;
  1269. Logs("IOS图片上传Error:" + massage);
  1270. //filename = e.Message;
  1271. }
  1272. return filename;//返回相对路径
  1273. }
  1274. /// <summary>
  1275. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1276. /// </summary>
  1277. /// <param name="dto"></param>
  1278. /// <returns></returns>
  1279. [HttpPost]
  1280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1281. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1282. {
  1283. if (dto == null)
  1284. {
  1285. return Ok(JsonView(false, "请求错误:"));
  1286. }
  1287. string msg = "参数错误";
  1288. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1289. {
  1290. try
  1291. {
  1292. //_delegationVisaRep.BeginTran();
  1293. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1294. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1295. .Where(s => s.Id == dto.visaProgressCustomerId)
  1296. .ExecuteCommandAsync();
  1297. if (updCount > 0 && dto.publishCode == 1)
  1298. {
  1299. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1300. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1301. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1302. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1303. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1304. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1305. if (groupData == null)
  1306. {
  1307. _delegationVisaRep.RollbackTran();
  1308. }
  1309. string title = string.Format(@"[签证进度更新]");
  1310. string content = string.Format(@"测试文本");
  1311. bool rst = await _message.AddMsg(new MessageDto()
  1312. {
  1313. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1314. IssuerId = dto.publisher,
  1315. Title = title,
  1316. Content = content,
  1317. ReleaseTime = DateTime.Now,
  1318. UIdList = new List<int> {
  1319. 234
  1320. }
  1321. });
  1322. if (rst)
  1323. {
  1324. return Ok(JsonView(true, "发送通知成功"));
  1325. }
  1326. }
  1327. //_delegationVisaRep.CommitTran();
  1328. }
  1329. catch (Exception)
  1330. {
  1331. //_delegationVisaRep.RollbackTran();
  1332. }
  1333. }
  1334. return Ok(JsonView(true, msg));
  1335. }
  1336. #endregion
  1337. #region 团组任务分配
  1338. /// <summary>
  1339. /// 团组任务分配初始化
  1340. /// </summary>
  1341. /// <param name="dto"></param>
  1342. /// <returns></returns>
  1343. [HttpPost]
  1344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1345. public async Task<IActionResult> GetTaskAssignmen()
  1346. {
  1347. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1348. if (groupData.Code != 0)
  1349. {
  1350. return Ok(JsonView(false, groupData.Msg));
  1351. }
  1352. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1353. }
  1354. /// <summary>
  1355. /// 团组任务分配查询
  1356. /// </summary>
  1357. /// <param name="dto"></param>
  1358. /// <returns></returns>
  1359. [HttpPost]
  1360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1361. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1362. {
  1363. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1364. if (groupData.Code != 0)
  1365. {
  1366. return Ok(JsonView(false, groupData.Msg));
  1367. }
  1368. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1369. }
  1370. /// <summary>
  1371. /// 团组任务分配操作
  1372. /// </summary>
  1373. /// <param name="dto"></param>
  1374. /// <returns></returns>
  1375. [HttpPost]
  1376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1377. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1378. {
  1379. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1380. if (groupData.Code != 0)
  1381. {
  1382. return Ok(JsonView(false, groupData.Msg));
  1383. }
  1384. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1385. }
  1386. /// <summary>
  1387. /// 团组任务分配
  1388. /// 批量分配
  1389. /// 查询团组
  1390. /// </summary>
  1391. /// <param name="dto"></param>
  1392. /// <returns></returns>
  1393. [HttpPost]
  1394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1395. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1396. {
  1397. //参数验证
  1398. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1399. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1400. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1401. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1402. }
  1403. /// <summary>
  1404. /// 团组任务分配
  1405. /// 批量分配
  1406. /// </summary>
  1407. /// <param name="dto"></param>
  1408. /// <returns></returns>
  1409. [HttpPost]
  1410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1411. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1412. {
  1413. //参数验证
  1414. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1415. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1416. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1417. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1418. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1419. }
  1420. #endregion
  1421. #region 团组费用审核
  1422. /// <summary>
  1423. /// 费用审核
  1424. /// 团组列表 Page
  1425. /// </summary>
  1426. /// <param name="_dto">团组列表请求dto</param>
  1427. /// <returns></returns>
  1428. [HttpPost]
  1429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1430. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1431. {
  1432. #region 参数验证
  1433. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1434. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1436. #region 页面操作权限验证
  1437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1438. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1439. #endregion
  1440. #endregion
  1441. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1442. {
  1443. string sqlWhere = string.Empty;
  1444. if (_dto.IsSure == 0) //未完成
  1445. {
  1446. sqlWhere += string.Format(@" And IsSure = 0");
  1447. }
  1448. else if (_dto.IsSure == 1) //已完成
  1449. {
  1450. sqlWhere += string.Format(@" And IsSure = 1");
  1451. }
  1452. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1453. {
  1454. string tj = _dto.SearchCriteria;
  1455. 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}%')",
  1456. tj, tj, tj, tj, tj);
  1457. }
  1458. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1459. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1460. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1461. From (
  1462. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1463. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1464. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1465. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1466. From Grp_DelegationInfo gdi
  1467. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1468. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1469. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1470. Where gdi.IsDel = 0 {0}
  1471. ) temp ", sqlWhere);
  1472. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1473. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1474. var _view = new
  1475. {
  1476. PageFuncAuth = pageFunAuthView,
  1477. Data = _DelegationList
  1478. };
  1479. return Ok(JsonView(true, "查询成功!", _view, total));
  1480. }
  1481. else
  1482. {
  1483. return Ok(JsonView(false, "查询失败"));
  1484. }
  1485. }
  1486. /// <summary>
  1487. /// 获取团组费用审核
  1488. /// </summary>
  1489. /// <param name="paras">参数Json字符串</param>
  1490. /// <returns></returns>
  1491. [HttpPost]
  1492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1493. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1494. {
  1495. try
  1496. {
  1497. #region 参数验证
  1498. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1499. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1500. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1501. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1502. #region 页面操作权限验证
  1503. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1504. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1505. #endregion
  1506. #endregion
  1507. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1508. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1509. #region 费用清单
  1510. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1511. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1512. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1513. List<Grp_CreditCardPayment> entityList = _groupRepository
  1514. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1515. .Where(exp.ToExpression())
  1516. .ToList();
  1517. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1518. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1519. /*
  1520. * 76://酒店预订
  1521. */
  1522. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1523. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1524. .ToListAsync();
  1525. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1526. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1527. .ToListAsync();
  1528. /*
  1529. * 79://车/导游地接
  1530. */
  1531. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1532. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1533. .ToListAsync();
  1534. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1535. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1536. .ToListAsync();
  1537. /*
  1538. * 80: //签证
  1539. */
  1540. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1541. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1542. .ToListAsync();
  1543. /*
  1544. *81: //邀请/公务活动
  1545. */
  1546. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1547. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1548. .ToListAsync();
  1549. /*
  1550. * 82: //团组客户保险
  1551. */
  1552. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1553. /*
  1554. * Lable = 85 机票预订
  1555. */
  1556. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1557. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1558. .ToListAsync();
  1559. /*
  1560. * 85 机票预定
  1561. */
  1562. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1563. /*
  1564. * 98 其他款项
  1565. */
  1566. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1567. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1568. .ToListAsync();
  1569. /*
  1570. * 285:收款退还
  1571. */
  1572. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1573. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1574. .ToListAsync();
  1575. /*
  1576. * 1015: //超支费用
  1577. */
  1578. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1579. /*
  1580. * 币种信息
  1581. */
  1582. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1583. /*
  1584. * 车/导游地接 费用类型
  1585. */
  1586. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1587. /*
  1588. * 车/导游地接 费用类型
  1589. */
  1590. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1591. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1592. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1593. /*
  1594. * 用户信息
  1595. */
  1596. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1597. /*
  1598. * 费用模块
  1599. */
  1600. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1601. string priceModule = string.Empty;
  1602. if (sdPriceName != null)
  1603. {
  1604. priceModule = sdPriceName.Name;
  1605. }
  1606. /*
  1607. * 成本信息
  1608. */
  1609. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1610. decimal _groupRate = 0.0000M;
  1611. string _groupCurrencyCode = "-";
  1612. if (groupCost != null)
  1613. {
  1614. _groupRate = groupCost.Rate;
  1615. if (int.TryParse(groupCost.Currency, out int _currency))
  1616. {
  1617. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1618. }
  1619. else _groupCurrencyCode = groupCost.Currency;
  1620. }
  1621. string costContentSql = $"Select * From Grp_GroupCost";
  1622. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1623. //处理日期为空的天数
  1624. for (int i = 0; i < groupCostDetails.Count; i++)
  1625. if (i != 0)
  1626. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1627. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1628. /*
  1629. * 处理详情数据
  1630. */
  1631. foreach (var entity in entityList)
  1632. {
  1633. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1634. _detail.Id = entity.Id;
  1635. _detail.PriceName = priceModule;
  1636. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1637. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1638. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1639. //处理金额
  1640. if (entity.CTable == 1015)
  1641. {
  1642. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1643. if (czInfo != null)
  1644. {
  1645. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1646. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1647. }
  1648. }
  1649. /*
  1650. * 应付款金额
  1651. */
  1652. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1653. string PaymentCurrency_WaitPay = "Unknown";
  1654. string hotelCurrncyCode = "Unknown";
  1655. string hotelCurrncyName = "Unknown";
  1656. if (sdPaymentCurrency_WaitPay != null)
  1657. {
  1658. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1659. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1660. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1661. if (hotelCurrncyCode.Equals("CNY"))
  1662. {
  1663. entity.DayRate = 1.0000M;
  1664. }
  1665. }
  1666. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1667. /*
  1668. * 此次付款金额
  1669. */
  1670. decimal CurrPayStr = 0.00M,
  1671. OriginalCurrPay = 0.00M;
  1672. if (entity.PayPercentage == 0)
  1673. {
  1674. if (entity.PayThenMoney != 0)
  1675. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1676. }
  1677. else
  1678. {
  1679. if (entity.PayMoney != 0)
  1680. {
  1681. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1682. }
  1683. }
  1684. if (_dto.Label == 79)
  1685. {
  1686. string original = string.Empty;
  1687. if (hotelCurrncyCode.Equals("CNY"))
  1688. {
  1689. OriginalCurrPay = CurrPayStr;
  1690. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1691. }
  1692. else
  1693. {
  1694. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1695. //760 EUR(7600.00 CNY)
  1696. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1697. }
  1698. }
  1699. else
  1700. {
  1701. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1702. }
  1703. /*
  1704. * 剩余尾款
  1705. */
  1706. decimal BalanceStr = 0;
  1707. if (CurrPayStr != 0)
  1708. {
  1709. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1710. BalanceStr = 0;
  1711. else
  1712. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1713. }
  1714. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1715. /*
  1716. * Bus名称
  1717. */
  1718. _detail.BusName = "待增加";
  1719. /*
  1720. *费用所属
  1721. */
  1722. switch (entity.CTable)
  1723. {
  1724. case 76://酒店预订
  1725. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1726. if (hotelReservations != null)
  1727. {
  1728. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1729. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1730. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1731. string roomFeeStr = "", roomFeestr1 = "";
  1732. //是否比较房型价格
  1733. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1734. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1735. roomFeeStr += $"<br/>";
  1736. var roomTotal = 0.00M;
  1737. if (hotelReservations.SingleRoomPrice > 0)
  1738. {
  1739. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1740. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1741. __isSingle = true;
  1742. roomTotal += fee;
  1743. }
  1744. if (hotelReservations.DoubleRoomPrice > 0)
  1745. {
  1746. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1747. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1748. __isDouble = true;
  1749. roomTotal += fee;
  1750. }
  1751. if (hotelReservations.SuiteRoomPrice > 0)
  1752. {
  1753. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1754. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1755. __isSuite = true;
  1756. roomTotal += fee;
  1757. }
  1758. if (hotelReservations.OtherRoomPrice > 0)
  1759. {
  1760. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1761. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1762. __isOther = true;
  1763. roomTotal += fee;
  1764. }
  1765. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1766. else roomFeeStr += " 0.00 * 0";
  1767. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1768. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1769. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1770. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1771. /*
  1772. * 费用类型
  1773. * 1:房费
  1774. * 2:早餐
  1775. * 3:地税
  1776. * 4:城市税
  1777. * </summary>
  1778. */
  1779. //地税
  1780. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1781. if (governmentRentData != null)
  1782. {
  1783. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1784. governmentRentFee = governmentRentData.Price;
  1785. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1786. if (governmentRentCurrData != null)
  1787. {
  1788. governmentRentCode = governmentRentCurrData.Name;
  1789. governmentRentName = $"({governmentRentCurrData.Remark})";
  1790. }
  1791. }
  1792. //城市税
  1793. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1794. if (cityTaxData != null)
  1795. {
  1796. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1797. cityTaxFee = cityTaxData.Price;
  1798. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1799. if (cityTaxCurrData != null)
  1800. {
  1801. cityTaxCode = cityTaxCurrData.Name;
  1802. cityTaxName = $"({cityTaxCurrData.Remark})";
  1803. }
  1804. }
  1805. //酒店早餐
  1806. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1807. if (breakfastData != null)
  1808. {
  1809. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1810. breakfastFee = breakfastData.Price;
  1811. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1812. if (breakfastCurrData != null)
  1813. {
  1814. breakfastCode = breakfastCurrData.Name;
  1815. breakfastName = $"({breakfastCurrData.Remark})";
  1816. }
  1817. }
  1818. //房间费用
  1819. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1820. if (roomData != null)
  1821. {
  1822. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1823. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1824. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1825. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1826. roomFee = roomData.Price;
  1827. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1828. if (roomCurrData != null)
  1829. {
  1830. roomCode = roomCurrData.Name;
  1831. roomName = $"({roomCurrData.Remark})";
  1832. }
  1833. }
  1834. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1835. string hotelCostStr = "";
  1836. decimal hotelCsotTotal = 0.00M;
  1837. if (groupCost != null)
  1838. {
  1839. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1840. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1841. }
  1842. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1843. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1844. string hotelCost_day = "";
  1845. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1846. foreach (var item in hotelCostDetails1)
  1847. {
  1848. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1849. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1850. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1851. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1852. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1853. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1854. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1855. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1856. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1857. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1858. hotelCost_day += @$"<br/>";
  1859. }
  1860. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1861. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  1862. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  1863. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  1864. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1865. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1866. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1867. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1868. $"房间说明: {hotelReservations.Remark} <br/>" +
  1869. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  1870. $"{hotelBreakfastStr}" +
  1871. $"{hotelGovernmentRentStr}" +
  1872. $"{hotelCityTaxStr}";
  1873. _detail.PriceNameContent = hotelReservations.HotelName;
  1874. }
  1875. break;
  1876. case 79://车/导游地接
  1877. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1878. if (touristGuideGroundReservations != null)
  1879. {
  1880. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1881. {
  1882. _detail.BusName = touristGuideGroundReservations.BusName;
  1883. }
  1884. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1885. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1886. //if (isInt)
  1887. //{
  1888. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1889. // if (cityInfo != null)
  1890. // {
  1891. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1892. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1893. // if (carFeeItem != null)
  1894. // {
  1895. // nameContent += $@"({carFeeItem.Name})";
  1896. // }
  1897. // _detail.PriceNameContent = nameContent;
  1898. // }
  1899. //}
  1900. //else
  1901. //{
  1902. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1903. //}
  1904. var touristGuideGroundReservationsContents =
  1905. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1906. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1907. foreach (var item in touristGuideGroundReservationsContents)
  1908. {
  1909. string typeName = "Unknown";
  1910. string carCurrencyCode = "Unknown";
  1911. string carCurrencyName = "Unknown";
  1912. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1913. if (carTypeData != null) typeName = carTypeData.Name;
  1914. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1915. if (currencyData != null)
  1916. {
  1917. carCurrencyCode = currencyData.Name;
  1918. carCurrencyName = currencyData.Remark;
  1919. }
  1920. //op、成本 币种是否一致
  1921. bool IsCurrencyAgreement = false;
  1922. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1923. string opCostStr = string.Empty;
  1924. decimal opCostTypePrice = 0.00M;
  1925. #region 处理成本各项费用
  1926. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1927. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1928. if (opCost.Count > 0)
  1929. {
  1930. switch (item.SId)
  1931. {
  1932. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1933. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1934. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1935. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1936. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1937. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1938. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1939. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1940. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1941. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1942. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1943. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1944. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1945. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1946. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1947. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1948. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1949. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1950. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1951. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1952. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1953. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1954. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1955. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1956. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1957. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1958. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1959. }
  1960. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1961. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1962. }
  1963. #endregion
  1964. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1965. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1966. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1967. $"{opTypeStr} {opCostStr}<br/>" +
  1968. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1969. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1970. }
  1971. _detail.PriceMsgContent = priceMsg;
  1972. }
  1973. break;
  1974. case 80: //签证
  1975. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1976. if (visaInfo != null)
  1977. {
  1978. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1979. _detail.PriceNameContent = visaInfo.VisaDescription;
  1980. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1981. }
  1982. break;
  1983. case 81: //邀请/公务活动
  1984. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1985. if (_ioa != null)
  1986. {
  1987. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1988. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1989. sendCurrName = "Unknown", //快递费用币种 Name
  1990. sendCurrCode = "Unknown", //快递费用币种 Code
  1991. eventsCurrName = "Unknown", //公务活动费币种 Name
  1992. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1993. translateCurrName = "Unknown", //公务翻译费 Name
  1994. translateCurrCode = "Unknown"; //公务翻译费 Code
  1995. #region 处理费用币种
  1996. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1997. if (inviteCurrData != null)
  1998. {
  1999. inviteCurrName = inviteCurrData.Remark;
  2000. inviteCurrCode = inviteCurrData.Name;
  2001. }
  2002. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2003. if (sendCurrData != null)
  2004. {
  2005. sendCurrName = sendCurrData.Remark;
  2006. sendCurrCode = sendCurrData.Name;
  2007. }
  2008. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2009. if (eventsCurrData != null)
  2010. {
  2011. eventsCurrName = eventsCurrData.Remark;
  2012. eventsCurrCode = eventsCurrData.Name;
  2013. }
  2014. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2015. if (translateCurrData != null)
  2016. {
  2017. translateCurrName = translateCurrData.Remark;
  2018. translateCurrCode = translateCurrData.Name;
  2019. }
  2020. #endregion
  2021. _detail.PriceNameContent = _ioa.InviterArea;
  2022. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2023. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2024. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2025. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2026. $@"备注:" + _ioa.Remark + "<br/>";
  2027. }
  2028. break;
  2029. case 82: //团组客户保险
  2030. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2031. if (customers != null)
  2032. {
  2033. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2034. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2035. }
  2036. break;
  2037. case 85: //机票预订
  2038. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2039. if (jpRes != null)
  2040. {
  2041. string FlightsDescription = jpRes.FlightsDescription;
  2042. string PriceDescription = jpRes.PriceDescription;
  2043. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2044. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2045. }
  2046. break;
  2047. case 98://其他款项
  2048. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2049. if (gdpRes != null)
  2050. {
  2051. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2052. _detail.PriceNameContent = gdpRes.PriceName;
  2053. }
  2054. break;
  2055. case 285://收款退还
  2056. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2057. if (refundAndOtherMoney != null)
  2058. {
  2059. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2060. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2061. }
  2062. break;
  2063. case 751://酒店早餐
  2064. break;
  2065. case 1015://超支费用
  2066. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2067. if (groupExtraCost != null)
  2068. {
  2069. _detail.PriceNameContent = groupExtraCost.PriceName;
  2070. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2071. }
  2072. break;
  2073. default:
  2074. break;
  2075. }
  2076. /*
  2077. * 申请人
  2078. */
  2079. string operatorName = " - ";
  2080. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2081. if (_opUser != null)
  2082. {
  2083. operatorName = _opUser.CnName;
  2084. }
  2085. _detail.OperatorName = operatorName;
  2086. /*
  2087. * 审核人
  2088. */
  2089. string auditOperatorName = "Unknown";
  2090. if (entity.AuditGMOperate == 0)
  2091. auditOperatorName = " - ";
  2092. else if (entity.AuditGMOperate == 4)
  2093. auditOperatorName = "自动审核";
  2094. else
  2095. {
  2096. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2097. if (_adUser != null)
  2098. {
  2099. auditOperatorName = _adUser.CnName;
  2100. }
  2101. }
  2102. _detail.AuditOperatorName = auditOperatorName;
  2103. /*
  2104. * 超预算比例
  2105. */
  2106. string overBudgetStr = "";
  2107. if (entity.ExceedBudget == -1)
  2108. overBudgetStr = sdPriceName.Name + "尚无预算";
  2109. else if (entity.ExceedBudget == 0)
  2110. {
  2111. if (entity.CTable == 76 || entity.CTable == 79)
  2112. {
  2113. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2114. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2115. }
  2116. else
  2117. {
  2118. overBudgetStr = "未超预算";
  2119. }
  2120. }
  2121. else
  2122. overBudgetStr = entity.ExceedBudget.ToString("P");
  2123. _detail.OverBudget = overBudgetStr;
  2124. /*
  2125. * 已审核金额
  2126. */
  2127. decimal auditFee = 0.00M;
  2128. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2129. /*
  2130. * 费用总计
  2131. */
  2132. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2133. {
  2134. CurrencyId = entity.PaymentCurrency,
  2135. CurrencyName = PaymentCurrency_WaitPay,
  2136. AmountPayable = entity.PayMoney,
  2137. ThisPayment = OriginalCurrPay,
  2138. BalancePayment = BalanceStr,
  2139. AuditedFunds = auditFee
  2140. });
  2141. _detail.IsAuditGM = entity.IsAuditGM;
  2142. detailList.Add(_detail);
  2143. }
  2144. #endregion
  2145. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2146. /*
  2147. * 下方描述处理
  2148. */
  2149. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2150. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2151. if (ccpCurrencyPrice != null)
  2152. {
  2153. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2154. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2155. }
  2156. else
  2157. {
  2158. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2159. }
  2160. string amountPayableStr = string.Format(@"应付款总金额: ");
  2161. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2162. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2163. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2164. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2165. foreach (var item in nonDuplicat)
  2166. {
  2167. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2168. if (strs.Count > 0)
  2169. {
  2170. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2171. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2172. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2173. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2174. //单独处理此次付款金额
  2175. if (item.CurrencyId == 836) //人民币
  2176. {
  2177. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2178. }
  2179. else
  2180. {
  2181. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2182. }
  2183. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2184. //单独处理已审核费用
  2185. if (item.CurrencyId == 836) //人民币
  2186. {
  2187. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2188. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2189. }
  2190. else
  2191. {
  2192. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2193. }
  2194. }
  2195. }
  2196. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2197. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2198. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2199. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2200. _view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2201. var _view1 = new
  2202. {
  2203. PageFuncAuth = pageFunAuthView,
  2204. Data = _view
  2205. };
  2206. return Ok(JsonView(_view1));
  2207. }
  2208. catch (Exception ex)
  2209. {
  2210. return Ok(JsonView(false, ex.Message));
  2211. }
  2212. }
  2213. /// <summary>
  2214. /// 费用审核
  2215. /// 修改团组费用审核状态
  2216. /// </summary>
  2217. /// <param name="_dto">参数Json字符串</param>
  2218. /// <returns></returns>
  2219. [HttpPost]
  2220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2221. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2222. {
  2223. #region 参数验证
  2224. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2225. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2226. #endregion
  2227. #region 页面操作权限验证
  2228. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2229. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2230. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2231. #endregion
  2232. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2233. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2234. DateTime dtNow = DateTime.Now;
  2235. _groupRepository.BeginTran();
  2236. int rst = 0;
  2237. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2238. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2239. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2240. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2241. List<dynamic> msgDatas = new List<dynamic>();
  2242. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2243. foreach (var item in idList)
  2244. {
  2245. int CreditId = int.Parse(item);
  2246. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2247. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2248. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2249. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2250. .Where(s => s.Id == CreditId)
  2251. .ExecuteCommandAsync();
  2252. if (result < 1)
  2253. {
  2254. rst = -1;
  2255. _groupRepository.RollbackTran();
  2256. return Ok(JsonView(false, "操作失败并回滚!"));
  2257. }
  2258. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2259. if (creditData != null)
  2260. {
  2261. #region 应用通知配置
  2262. try
  2263. {
  2264. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2265. }
  2266. catch (Exception ex)
  2267. {
  2268. }
  2269. #endregion
  2270. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2271. string groupNameStr = string.Empty;
  2272. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2273. if (groupData != null) groupNameStr = groupData.TeamName;
  2274. string creditTypeStr = string.Empty;
  2275. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2276. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2277. string creditCurrency = string.Empty;
  2278. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2279. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2280. if (creditCurrency.Equals("CNY"))
  2281. {
  2282. creditData.DayRate = 1.0000M;
  2283. }
  2284. if (creditData.PayPercentage == 0.00M)
  2285. {
  2286. creditData.PayPercentage = 100M;
  2287. }
  2288. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2289. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2290. string msgContent = "";
  2291. if (creditCurrency.Equals("CNY"))
  2292. {
  2293. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2294. }
  2295. else
  2296. {
  2297. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2298. }
  2299. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2300. }
  2301. }
  2302. if (rst == 0)
  2303. {
  2304. _groupRepository.CommitTran();
  2305. foreach (var item in msgDatas)
  2306. {
  2307. //发送消息
  2308. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2309. }
  2310. #region 应用推送
  2311. try
  2312. {
  2313. foreach (var ccpId in dic_ccp_user.Keys)
  2314. {
  2315. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2316. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2317. }
  2318. }
  2319. catch (Exception)
  2320. {
  2321. }
  2322. #endregion
  2323. return Ok(JsonView(true, "操作成功!"));
  2324. }
  2325. return Ok(JsonView(false, "操作失败!"));
  2326. }
  2327. #endregion
  2328. #region 机票费用录入
  2329. /// <summary>
  2330. /// 机票录入当前登录人可操作团组
  2331. /// </summary>
  2332. /// <param name="dto"></param>
  2333. /// <returns></returns>
  2334. [HttpPost]
  2335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2336. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2337. {
  2338. try
  2339. {
  2340. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2341. if (groupData.Code != 0)
  2342. {
  2343. return Ok(JsonView(false, groupData.Msg));
  2344. }
  2345. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2346. }
  2347. catch (Exception ex)
  2348. {
  2349. return Ok(JsonView(false, "程序错误!"));
  2350. throw;
  2351. }
  2352. }
  2353. /// <summary>
  2354. /// 机票费用录入列表
  2355. /// </summary>
  2356. /// <param name="dto"></param>
  2357. /// <returns></returns>
  2358. [HttpPost]
  2359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2360. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2361. {
  2362. try
  2363. {
  2364. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2365. if (groupData.Code != 0)
  2366. {
  2367. return Ok(JsonView(false, groupData.Msg));
  2368. }
  2369. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2370. }
  2371. catch (Exception ex)
  2372. {
  2373. return Ok(JsonView(false, ex.Message));
  2374. throw;
  2375. }
  2376. }
  2377. /// <summary>
  2378. /// 根据id查询费用录入信息
  2379. /// </summary>
  2380. /// <param name="dto"></param>
  2381. /// <returns></returns>
  2382. [HttpPost]
  2383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2384. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2385. {
  2386. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2387. if (groupData.Code != 0)
  2388. {
  2389. return Ok(JsonView(false, groupData.Msg));
  2390. }
  2391. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2392. }
  2393. /// <summary>
  2394. /// 机票费用录入操作(Status:1.新增,2.修改)
  2395. /// </summary>
  2396. /// <param name="dto"></param>
  2397. /// <returns></returns>
  2398. [HttpPost]
  2399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2400. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2401. {
  2402. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2403. if (groupData.Code != 0)
  2404. {
  2405. return Ok(JsonView(false, groupData.Msg));
  2406. }
  2407. #region 应用推送
  2408. try
  2409. {
  2410. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2411. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2412. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2413. //2024-10-21 新增LZ UID
  2414. var userIds = new List<int>() { 21 };
  2415. string title = $"系统通知";
  2416. string content = "";
  2417. var diId = dto.AirTicketResOpData.DiId;
  2418. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2419. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2420. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2421. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2422. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2423. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2424. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2425. }
  2426. catch (Exception ex)
  2427. {
  2428. }
  2429. #endregion
  2430. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2431. }
  2432. /// <summary>
  2433. /// 根据舱位类型查询接团客户名单信息
  2434. /// </summary>
  2435. /// <param name="dto"></param>
  2436. /// <returns></returns>
  2437. [HttpPost]
  2438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2439. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2440. {
  2441. try
  2442. {
  2443. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2444. if (crm_Groups.Count != 0)
  2445. {
  2446. List<dynamic> Customer = new List<dynamic>();
  2447. foreach (var item in crm_Groups)
  2448. {
  2449. var data = new
  2450. {
  2451. Id = item.Id,
  2452. Pinyin = item.Pinyin,
  2453. Name = item.LastName + item.FirstName
  2454. };
  2455. Customer.Add(data);
  2456. }
  2457. return Ok(JsonView(true, "查询成功!", Customer));
  2458. }
  2459. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2460. }
  2461. catch (Exception ex)
  2462. {
  2463. return Ok(JsonView(false, "程序错误!"));
  2464. throw;
  2465. }
  2466. }
  2467. /// <summary>
  2468. /// 根据团号获取客户信息
  2469. /// </summary>
  2470. /// <param name="dto"></param>
  2471. /// <returns></returns>
  2472. [HttpPost]
  2473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2474. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2475. {
  2476. var jw = JsonView(false);
  2477. if (dto.DIID < 1)
  2478. {
  2479. jw.Msg += "请输入正确的diid";
  2480. return Ok(jw);
  2481. }
  2482. var arr = getSimplClientList(dto.DIID);
  2483. jw = JsonView(true, "获取成功!", arr);
  2484. return Ok(jw);
  2485. }
  2486. private List<SimplClientInfo> getSimplClientList(int diId)
  2487. {
  2488. 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);
  2489. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2490. foreach (var item in arr)
  2491. {
  2492. EncryptionProcessor.DecryptProperties(item);
  2493. }
  2494. return arr;
  2495. }
  2496. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2497. {
  2498. string result = origin;
  2499. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2500. {
  2501. string[] temparr = origin.Split(',');
  2502. string fistrStr = temparr[0];
  2503. int count = temparr.Count();
  2504. int tempId;
  2505. bool success = int.TryParse(fistrStr, out tempId);
  2506. if (success)
  2507. {
  2508. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2509. if (tempInfo != null)
  2510. {
  2511. if (count > 1)
  2512. {
  2513. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2514. }
  2515. else
  2516. {
  2517. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2518. }
  2519. }
  2520. }
  2521. }
  2522. return result;
  2523. }
  2524. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2525. {
  2526. string result = origin;
  2527. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2528. {
  2529. string[] temparr = origin.Split(',');
  2530. result = "";
  2531. foreach (var item in temparr)
  2532. {
  2533. int tempId;
  2534. bool success = int.TryParse(item, out tempId);
  2535. if (success)
  2536. {
  2537. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2538. if (tempInfo != null)
  2539. {
  2540. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2541. }
  2542. }
  2543. }
  2544. }
  2545. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2546. return result;
  2547. }
  2548. /// <summary>
  2549. /// 机票费用录入,删除
  2550. /// </summary>
  2551. /// <param name="dto"></param>
  2552. /// <returns></returns>
  2553. [HttpPost]
  2554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2555. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2556. {
  2557. try
  2558. {
  2559. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2560. if (res)
  2561. {
  2562. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2563. {
  2564. IsDel = 1,
  2565. DeleteUserId = dto.DeleteUserId,
  2566. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2567. }).ExecuteCommandAsync();
  2568. return Ok(JsonView(true, "删除成功!"));
  2569. }
  2570. return Ok(JsonView(false, "删除失败!"));
  2571. }
  2572. catch (Exception ex)
  2573. {
  2574. return Ok(JsonView(false, "程序错误!"));
  2575. throw;
  2576. }
  2577. }
  2578. /// <summary>
  2579. /// 导出机票录入报表
  2580. /// </summary>
  2581. /// <param name="dto"></param>
  2582. /// <returns></returns>
  2583. [HttpPost]
  2584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2585. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2586. {
  2587. try
  2588. {
  2589. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2590. if (groupData.Code != 0)
  2591. {
  2592. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2593. }
  2594. else
  2595. {
  2596. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2597. if (AirTicketReservations.Count != 0)
  2598. {
  2599. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2600. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2601. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2602. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2603. WorkbookDesigner designer = new WorkbookDesigner();
  2604. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2605. decimal countCost = 0;
  2606. foreach (var item in AirTicketReservations)
  2607. {
  2608. #region 处理客人姓名
  2609. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2610. item.ClientName = clientNames;
  2611. #endregion
  2612. if (item.BankType == "其他")
  2613. {
  2614. item.BankNo = "--";
  2615. }
  2616. else
  2617. {
  2618. if (!string.IsNullOrEmpty(item.BankType))
  2619. {
  2620. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2621. }
  2622. }
  2623. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2624. item.Price = System.Decimal.Round(item.Price, 2);
  2625. countCost += Convert.ToDecimal(item.Price);
  2626. }
  2627. designer.SetDataSource("Export", AirTicketReservations);
  2628. designer.SetDataSource("ExportDiCode", diCode);
  2629. designer.SetDataSource("ExportDiName", diName);
  2630. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2631. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2632. designer.Process();
  2633. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2634. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2635. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2636. return Ok(JsonView(true, "成功", url = rst));
  2637. }
  2638. else
  2639. {
  2640. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2641. }
  2642. }
  2643. }
  2644. catch (Exception ex)
  2645. {
  2646. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2647. throw;
  2648. }
  2649. }
  2650. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2651. /// <summary>
  2652. /// 行程单导出
  2653. /// </summary>
  2654. /// <param name="dto"></param>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2659. {
  2660. try
  2661. {
  2662. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2663. if (groupData.Code != 0)
  2664. {
  2665. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2666. }
  2667. else
  2668. {
  2669. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2670. if (dto.Language == "CN")
  2671. {
  2672. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2673. DocumentBuilder builder = new DocumentBuilder(doc);
  2674. int tableIndex = 0;//表格索引
  2675. //得到文档中的第一个表格
  2676. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2677. foreach (var item in _AirTicketReservations)
  2678. {
  2679. #region 处理固定数据
  2680. string[] FlightsCode = item.FlightsCode.Split('/');
  2681. if (FlightsCode.Length != 0)
  2682. {
  2683. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2684. if (_AirCompany != null)
  2685. {
  2686. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2687. }
  2688. else
  2689. {
  2690. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2691. }
  2692. }
  2693. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2694. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2695. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2696. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2697. string name = "";
  2698. foreach (string clientName in nameArray)
  2699. {
  2700. if (!name.Contains(clientName))
  2701. {
  2702. name += clientName + ",";
  2703. }
  2704. }
  2705. if (!string.IsNullOrWhiteSpace(name))
  2706. {
  2707. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2708. }
  2709. else
  2710. {
  2711. table.Range.Bookmarks["ClientName"].Text = "--";
  2712. }
  2713. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2714. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2715. table.Range.Bookmarks["JointTicket"].Text = "--";
  2716. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2717. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2718. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2719. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2720. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2721. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2722. #endregion
  2723. #region 循环数据处理
  2724. List<AirInfo> airs = new List<AirInfo>();
  2725. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2726. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2727. for (int i = 0; i < FlightsCode.Length; i++)
  2728. {
  2729. AirInfo air = new AirInfo();
  2730. string[] tempstr = DayArray[i]
  2731. .Replace("\r\n", string.Empty)
  2732. .Replace("\\r\\n", string.Empty)
  2733. .TrimStart().TrimEnd()
  2734. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2735. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2736. string starCity = "";
  2737. if (star_Three != null)
  2738. {
  2739. starCity = star_Three.AirPort;
  2740. }
  2741. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2742. string EndCity = "";
  2743. if (End_Three != null)
  2744. {
  2745. EndCity = End_Three.AirPort;
  2746. }
  2747. air.Destination = starCity + "/" + EndCity;
  2748. air.Flight = FlightsCode[i];
  2749. air.SeatingClass = item.CTypeName;
  2750. string dateTime = tempstr[2];
  2751. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2752. air.FlightDate = DateTemp;
  2753. air.DepartureTime = tempstr[5];
  2754. air.LandingTime = tempstr[6];
  2755. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2756. air.TicketStatus = "--";
  2757. air.Luggage = "--";
  2758. air.DepartureTerminal = "--";
  2759. air.LandingTerminal = "--";
  2760. airs.Add(air);
  2761. }
  2762. int row = 13;
  2763. for (int i = 0; i < airs.Count; i++)
  2764. {
  2765. if (airs.Count > 2)
  2766. {
  2767. for (int j = 0; j < airs.Count - 2; j++)
  2768. {
  2769. var CopyRow = table.Rows[12].Clone(true);
  2770. table.Rows.Add(CopyRow);
  2771. }
  2772. }
  2773. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2774. int index = 0;
  2775. foreach (PropertyInfo property in properties)
  2776. {
  2777. string value = property.GetValue(airs[i]).ToString();
  2778. Cell ishcel0 = table.Rows[row].Cells[index];
  2779. Paragraph p = new Paragraph(doc);
  2780. string s = value;
  2781. p.AppendChild(new Run(doc, s));
  2782. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2783. ishcel0.AppendChild(p);
  2784. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2785. index++;
  2786. }
  2787. row++;
  2788. }
  2789. #endregion
  2790. Paragraph lastParagraph = new Paragraph(doc);
  2791. //第一个表格末尾加段落
  2792. table.ParentNode.InsertAfter(lastParagraph, table);
  2793. //复制第一个表格
  2794. Table cloneTable = (Table)table.Clone(true);
  2795. //在文档末尾段落后面加入复制的表格
  2796. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2797. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2798. {
  2799. int rownewsIndex = 13;
  2800. for (int i = 0; i < 2; i++)
  2801. {
  2802. var CopyRow = table.Rows[12].Clone(true);
  2803. table.Rows.RemoveAt(13);
  2804. table.Rows.Add(CopyRow);
  2805. rownewsIndex++;
  2806. }
  2807. }
  2808. else
  2809. {
  2810. table.Rows.RemoveAt(12);
  2811. }
  2812. cloneTable.Rows.RemoveAt(12);
  2813. }
  2814. if (_AirTicketReservations.Count != 0)
  2815. {
  2816. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2817. if (FlightsCode.Length != 0)
  2818. {
  2819. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2820. if (_AirCompany != null)
  2821. {
  2822. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2823. }
  2824. else
  2825. {
  2826. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2827. }
  2828. }
  2829. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2830. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2831. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2832. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2833. string name = "";
  2834. foreach (string clientName in nameArray)
  2835. {
  2836. if (!name.Contains(clientName))
  2837. {
  2838. name += clientName + ",";
  2839. }
  2840. }
  2841. if (!string.IsNullOrWhiteSpace(name))
  2842. {
  2843. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2844. }
  2845. else
  2846. {
  2847. table.Range.Bookmarks["ClientName"].Text = "--";
  2848. }
  2849. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2850. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2851. table.Range.Bookmarks["JointTicket"].Text = "--";
  2852. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2853. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2854. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2855. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2856. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2857. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2858. }
  2859. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2860. //保存合并后的文档
  2861. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2862. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2863. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2864. return Ok(JsonView(true, "成功!", rst));
  2865. }
  2866. else
  2867. {
  2868. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2869. DocumentBuilder builder = new DocumentBuilder(doc);
  2870. int tableIndex = 0;//表格索引
  2871. //得到文档中的第一个表格
  2872. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2873. List<string> texts = new List<string>();
  2874. foreach (var item in _AirTicketReservations)
  2875. {
  2876. string[] FlightsCode = item.FlightsCode.Split('/');
  2877. if (FlightsCode.Length != 0)
  2878. {
  2879. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2880. if (_AirCompany != null)
  2881. {
  2882. if (!transDic.ContainsKey(_AirCompany.CnName))
  2883. {
  2884. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2885. }
  2886. }
  2887. else
  2888. {
  2889. if (!transDic.ContainsKey("--"))
  2890. {
  2891. transDic.Add("--", "--");
  2892. }
  2893. }
  2894. }
  2895. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2896. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2897. string name = "";
  2898. foreach (string clientName in nameArray)
  2899. {
  2900. name += clientName + ",";
  2901. }
  2902. if (!texts.Contains(name))
  2903. {
  2904. texts.Add(name);
  2905. }
  2906. List<AirInfo> airs = new List<AirInfo>();
  2907. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2908. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2909. for (int i = 0; i < FlightsCode.Length; i++)
  2910. {
  2911. AirInfo air = new AirInfo();
  2912. string[] tempstr = DayArray[i]
  2913. .Replace("\r\n", string.Empty)
  2914. .Replace("\\r\\n", string.Empty)
  2915. .TrimStart().TrimEnd()
  2916. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2917. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2918. if (star_Three != null)
  2919. {
  2920. if (!transDic.ContainsKey(star_Three.AirPort))
  2921. {
  2922. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2923. }
  2924. }
  2925. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2926. if (End_Three != null)
  2927. {
  2928. if (!transDic.ContainsKey(End_Three.AirPort))
  2929. {
  2930. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2931. }
  2932. }
  2933. if (!texts.Contains(item.CTypeName))
  2934. {
  2935. texts.Add(item.CTypeName);
  2936. }
  2937. }
  2938. }
  2939. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2940. if (transData.Count > 0)
  2941. {
  2942. foreach (TranslateResult item in transData)
  2943. {
  2944. if (!transDic.ContainsKey(item.Query))
  2945. {
  2946. transDic.Add(item.Query, item.Translation);
  2947. }
  2948. }
  2949. }
  2950. foreach (var item in _AirTicketReservations)
  2951. {
  2952. #region 处理固定数据
  2953. string[] FlightsCode = item.FlightsCode.Split('/');
  2954. if (FlightsCode.Length != 0)
  2955. {
  2956. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2957. if (_AirCompany != null)
  2958. {
  2959. string str = "--";
  2960. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2961. if (!string.IsNullOrEmpty(translateResult))
  2962. {
  2963. str = translateResult;
  2964. str = _airTicketResRep.Processing(str);
  2965. }
  2966. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2967. }
  2968. else
  2969. {
  2970. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2971. }
  2972. }
  2973. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2974. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2975. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2976. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2977. string names = "";
  2978. foreach (string clientName in nameArray)
  2979. {
  2980. names += clientName + ",";
  2981. }
  2982. if (!string.IsNullOrWhiteSpace(names))
  2983. {
  2984. string str = "--";
  2985. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2986. if (!string.IsNullOrEmpty(translateResult))
  2987. {
  2988. str = translateResult;
  2989. str = _airTicketResRep.Processing(str);
  2990. }
  2991. table.Range.Bookmarks["ClientName"].Text = str;
  2992. }
  2993. else
  2994. {
  2995. table.Range.Bookmarks["ClientName"].Text = "--";
  2996. }
  2997. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2998. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2999. table.Range.Bookmarks["JointTicket"].Text = "--";
  3000. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3001. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3002. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3003. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3004. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3005. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3006. #endregion
  3007. #region 循环数据处理
  3008. List<AirInfo> airs = new List<AirInfo>();
  3009. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3010. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3011. for (int i = 0; i < FlightsCode.Length; i++)
  3012. {
  3013. AirInfo air = new AirInfo();
  3014. string[] tempstr = DayArray[i]
  3015. .Replace("\r\n", string.Empty)
  3016. .Replace("\\r\\n", string.Empty)
  3017. .TrimStart().TrimEnd()
  3018. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3019. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3020. string starCity = "";
  3021. if (star_Three != null)
  3022. {
  3023. string str2 = "--";
  3024. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3025. if (!string.IsNullOrEmpty(translateResult2))
  3026. {
  3027. str2 = translateResult2;
  3028. str2 = _airTicketResRep.Processing(str2);
  3029. }
  3030. starCity = str2;
  3031. }
  3032. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3033. string EndCity = "";
  3034. if (End_Three != null)
  3035. {
  3036. string str1 = "--";
  3037. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3038. if (!string.IsNullOrEmpty(translateResult1))
  3039. {
  3040. str1 = translateResult1;
  3041. str1 = _airTicketResRep.Processing(str1);
  3042. }
  3043. EndCity = str1;
  3044. }
  3045. air.Destination = starCity + "/" + EndCity;
  3046. air.Flight = FlightsCode[i];
  3047. string str = "--";
  3048. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3049. if (!string.IsNullOrEmpty(translateResult))
  3050. {
  3051. str = translateResult;
  3052. str = _airTicketResRep.Processing(str);
  3053. }
  3054. air.SeatingClass = str;
  3055. string dateTime = tempstr[2];
  3056. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3057. air.FlightDate = DateTemp;
  3058. air.DepartureTime = tempstr[5];
  3059. air.LandingTime = tempstr[6];
  3060. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3061. air.TicketStatus = "--";
  3062. air.Luggage = "--";
  3063. air.DepartureTerminal = "--";
  3064. air.LandingTerminal = "--";
  3065. airs.Add(air);
  3066. }
  3067. int row = 13;
  3068. for (int i = 0; i < airs.Count; i++)
  3069. {
  3070. if (airs.Count > 2)
  3071. {
  3072. for (int j = 0; j < airs.Count - 2; j++)
  3073. {
  3074. var CopyRow = table.Rows[12].Clone(true);
  3075. table.Rows.Add(CopyRow);
  3076. }
  3077. }
  3078. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3079. int index = 0;
  3080. foreach (PropertyInfo property in properties)
  3081. {
  3082. string value = property.GetValue(airs[i]).ToString();
  3083. Cell ishcel0 = table.Rows[row].Cells[index];
  3084. Paragraph p = new Paragraph(doc);
  3085. string s = value;
  3086. p.AppendChild(new Run(doc, s));
  3087. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3088. ishcel0.AppendChild(p);
  3089. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3090. //ishcel0.CellFormat.VerticalAlignment=
  3091. index++;
  3092. }
  3093. row++;
  3094. }
  3095. #endregion
  3096. Paragraph lastParagraph = new Paragraph(doc);
  3097. //第一个表格末尾加段落
  3098. table.ParentNode.InsertAfter(lastParagraph, table);
  3099. //复制第一个表格
  3100. Table cloneTable = (Table)table.Clone(true);
  3101. //在文档末尾段落后面加入复制的表格
  3102. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3103. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3104. {
  3105. int rownewsIndex = 13;
  3106. for (int i = 0; i < 2; i++)
  3107. {
  3108. var CopyRow = table.Rows[12].Clone(true);
  3109. table.Rows.RemoveAt(13);
  3110. table.Rows.Add(CopyRow);
  3111. rownewsIndex++;
  3112. }
  3113. }
  3114. else
  3115. {
  3116. table.Rows.RemoveAt(12);
  3117. }
  3118. cloneTable.Rows.RemoveAt(12);
  3119. }
  3120. if (_AirTicketReservations.Count != 0)
  3121. {
  3122. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3123. if (FlightsCode.Length != 0)
  3124. {
  3125. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3126. if (_AirCompany != null)
  3127. {
  3128. string str = "--";
  3129. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3130. if (!string.IsNullOrEmpty(translateResult))
  3131. {
  3132. str = translateResult;
  3133. str = _airTicketResRep.Processing(str);
  3134. }
  3135. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3136. }
  3137. else
  3138. {
  3139. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3140. }
  3141. }
  3142. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3143. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3144. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3145. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3146. string names = "";
  3147. foreach (string clientName in nameArray)
  3148. {
  3149. names += clientName + ",";
  3150. }
  3151. if (!string.IsNullOrWhiteSpace(names))
  3152. {
  3153. string str = "--";
  3154. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3155. if (!string.IsNullOrEmpty(translateResult))
  3156. {
  3157. str = translateResult;
  3158. str = _airTicketResRep.Processing(str);
  3159. }
  3160. table.Range.Bookmarks["ClientName"].Text = str;
  3161. }
  3162. else
  3163. {
  3164. table.Range.Bookmarks["ClientName"].Text = "--";
  3165. }
  3166. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3167. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3168. table.Range.Bookmarks["JointTicket"].Text = "--";
  3169. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3170. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3171. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3172. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3173. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3174. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3175. }
  3176. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3177. //保存合并后的文档
  3178. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3179. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3180. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3181. return Ok(JsonView(true, "成功!", rst));
  3182. }
  3183. }
  3184. }
  3185. catch (Exception ex)
  3186. {
  3187. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3188. throw;
  3189. }
  3190. }
  3191. #endregion
  3192. #region 团组增减款项 --> 其他款项
  3193. /// <summary>
  3194. /// 团组增减款项下拉框绑定
  3195. /// </summary>
  3196. /// <param name="dto"></param>
  3197. /// <returns></returns>
  3198. [HttpPost]
  3199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3200. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3201. {
  3202. #region 参数验证
  3203. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3204. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3205. #endregion
  3206. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3207. }
  3208. /// <summary>
  3209. /// 根据团组Id查询团组增减款项
  3210. /// </summary>
  3211. /// <param name="dto"></param>
  3212. /// <returns></returns>
  3213. [HttpPost]
  3214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3215. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3216. {
  3217. #region 参数验证
  3218. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3219. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3220. #endregion
  3221. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3222. }
  3223. /// <summary>
  3224. /// 团组增减款项操作(Status:1.新增,2.修改)
  3225. /// </summary>
  3226. /// <param name="dto"></param>
  3227. /// <returns></returns>
  3228. [HttpPost]
  3229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3230. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3231. {
  3232. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3233. if (groupData.Code != 200)
  3234. {
  3235. return Ok(JsonView(false, groupData.Msg));
  3236. }
  3237. #region 应用推送
  3238. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3239. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3240. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3241. //自动审核
  3242. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3243. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3244. //2024-10-21 新增LZ UID
  3245. var userIds = new List<int>() { 21 };
  3246. string title = $"系统通知";
  3247. string content = "";
  3248. var diId = dto.DiId;
  3249. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3250. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3251. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3252. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3253. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3254. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3255. #endregion
  3256. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3257. }
  3258. /// <summary>
  3259. /// 团组增减款项操作 删除
  3260. /// </summary>
  3261. /// <param name="dto"></param>
  3262. /// <returns></returns>
  3263. [HttpPost]
  3264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3265. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3266. {
  3267. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3268. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3269. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3270. if (res.Code == 0)
  3271. {
  3272. return Ok(JsonView(true, "删除成功!"));
  3273. }
  3274. return Ok(JsonView(false, "删除失败!"));
  3275. }
  3276. /// <summary>
  3277. /// 根据团组增减款项Id查询
  3278. /// </summary>
  3279. /// <param name="dto"></param>
  3280. /// <returns></returns>
  3281. [HttpPost]
  3282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3283. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3284. {
  3285. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3286. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3287. }
  3288. /// <summary>
  3289. /// 查询供应商名称
  3290. /// </summary>
  3291. /// <param name="dto"></param>
  3292. /// <returns></returns>
  3293. [HttpPost]
  3294. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3295. {
  3296. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3297. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3298. ?? new List<Grp_DecreasePayments>();
  3299. dbResult = dbResult.Distinct(new
  3300. ProductComparer()).ToList();
  3301. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3302. {
  3303. x.Id,
  3304. x.SupplierAddress,
  3305. x.SupplierArea,
  3306. x.SupplierContact,
  3307. x.SupplierContactNumber,
  3308. x.SupplierEmail,
  3309. x.SupplierName,
  3310. x.SupplierSocialAccount,
  3311. x.SupplierTypeId,
  3312. }).ToList());
  3313. return Ok(jw);
  3314. }
  3315. /// <summary>
  3316. /// 团组增减款项 OTA匹配
  3317. /// </summary>
  3318. /// <param name="file"></param>
  3319. /// <returns></returns>
  3320. [HttpPost]
  3321. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3322. {
  3323. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3324. string fileName = file.FileName;
  3325. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3326. {
  3327. return Ok(JsonView(false, "请上传Excel文件!"));
  3328. }
  3329. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3330. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3331. if (!Directory.Exists(path))
  3332. {
  3333. Directory.CreateDirectory(path);
  3334. }
  3335. var filePath = @$"{path}/{fileName}";
  3336. //保存文件
  3337. using (FileStream fs = System.IO.File.Create(filePath))
  3338. {
  3339. file.CopyTo(fs);
  3340. fs.Flush();
  3341. }
  3342. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3343. //读取ExcelFile
  3344. DataTable dt = ConvertExcelToDataTable(filePath);
  3345. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3346. dt.TableName = "TB";
  3347. //修改table列名
  3348. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3349. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3350. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3351. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3352. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3353. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3354. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3355. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3356. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3357. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3358. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3359. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3360. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3361. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3362. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3363. var otaOrderNos = new List<string>();
  3364. foreach (DataRow item in dt.Rows)
  3365. {
  3366. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3367. }
  3368. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3369. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3370. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3371. .Select((dp, di) => new
  3372. {
  3373. dp.PriceName,
  3374. dp.OTAOrderNo,
  3375. dp.FeeTotal,
  3376. di.TeamName,
  3377. })
  3378. .ToListAsync();
  3379. foreach (DataRow item in dt.Rows)
  3380. {
  3381. var otaOrderNo = item["OTAOrderNo"].ToString();
  3382. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3383. if (oaData == null) continue;
  3384. item["GroupName"] = oaData.TeamName;
  3385. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3386. }
  3387. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3388. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3389. List<DataTable> datas = new List<DataTable>();
  3390. datas.Add(dt);
  3391. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3392. return Ok(JsonView(true, "操作成功", new { url = url }));
  3393. }
  3394. #region
  3395. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3396. {
  3397. // 创建Workbook对象
  3398. Workbook workbook = new Workbook(excelFilePath);
  3399. // 获取第一个工作表
  3400. Worksheet worksheet = workbook.Worksheets[0];
  3401. // 将工作表转换为DataTable
  3402. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3403. return dataTable;
  3404. }
  3405. #endregion
  3406. #endregion
  3407. #region 文件上传、删除
  3408. /// <summary>
  3409. /// region 文件上传 可以带参数
  3410. /// </summary>
  3411. /// <param name="file"></param>
  3412. /// <returns></returns>
  3413. [HttpPost]
  3414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3415. public async Task<IActionResult> UploadProject(IFormFile file)
  3416. {
  3417. //var TypeName = Request.Headers["TypeName"].ToString();
  3418. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3419. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3420. ////文件名称
  3421. //string projectFileName = file.FileName;
  3422. ////上传的文件的路径
  3423. //string filePath = $"{fileDir}/{projectFileName}";
  3424. //if (TypeName == "A")//A代表团组增减款项
  3425. //{
  3426. // filePath = fileDir + $@"\团组增减款项相关文件";
  3427. // if (!Directory.Exists(filePath))
  3428. // {
  3429. // Directory.CreateDirectory(filePath);
  3430. // }
  3431. // //上传的文件的路径
  3432. // filePath += $@"\{projectFileName}";
  3433. //}
  3434. //else if (TypeName == "B")//B代表商邀相关文件
  3435. //{
  3436. // //上传的文件的路径
  3437. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3438. // if (!Directory.Exists(filePath))
  3439. // {
  3440. // Directory.CreateDirectory(filePath);
  3441. // }
  3442. // //上传的文件的路径
  3443. // filePath = $@"\{projectFileName}";
  3444. //}
  3445. //try
  3446. //{
  3447. // using (FileStream fs = System.IO.File.Create(filePath))
  3448. // {
  3449. // file.CopyTo(fs);
  3450. // fs.Flush();
  3451. // }
  3452. //}
  3453. //catch (Exception ex)
  3454. //{
  3455. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3456. //}
  3457. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3458. try
  3459. {
  3460. var TypeName = Request.Headers["TypeName"].ToString();
  3461. if (file != null)
  3462. {
  3463. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3464. //文件名称
  3465. string projectFileName = file.FileName;
  3466. //上传的文件的路径
  3467. string filePath = $"{fileDir}/{projectFileName}";
  3468. if (TypeName == "A")//A代表团组增减款项
  3469. {
  3470. if (!Directory.Exists(fileDir))
  3471. {
  3472. Directory.CreateDirectory(fileDir);
  3473. }
  3474. //上传的文件的路径
  3475. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3476. }
  3477. else if (TypeName == "B")//B代表商邀相关文件
  3478. {
  3479. if (!Directory.Exists(fileDir))
  3480. {
  3481. Directory.CreateDirectory(fileDir);
  3482. }
  3483. //上传的文件的路径
  3484. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3485. }
  3486. using (FileStream fs = System.IO.File.Create(filePath))
  3487. {
  3488. file.CopyTo(fs);
  3489. fs.Flush();
  3490. }
  3491. return Ok(JsonView(true, "上传成功!", projectFileName));
  3492. }
  3493. else
  3494. {
  3495. return Ok(JsonView(false, "上传失败!"));
  3496. }
  3497. }
  3498. catch (Exception ex)
  3499. {
  3500. return Ok(JsonView(false, "程序错误!"));
  3501. }
  3502. }
  3503. /// <summary>
  3504. /// 删除指定文件
  3505. /// </summary>
  3506. /// <param name="dto"></param>
  3507. /// <returns></returns>
  3508. [HttpPost]
  3509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3510. public async Task<IActionResult> DelFile(DelFileDto dto)
  3511. {
  3512. try
  3513. {
  3514. var TypeName = Request.Headers["TypeName"].ToString();
  3515. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3516. string filePath = "";
  3517. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3518. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3519. int id = 0;
  3520. if (TypeName == "A")
  3521. {
  3522. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3523. // 删除该文件
  3524. System.IO.File.Delete(filePath);
  3525. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3526. .Where(a => a.Id == dto.Id)
  3527. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3528. .ExecuteCommandAsync();
  3529. }
  3530. else if (TypeName == "B")
  3531. {
  3532. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3533. // 删除该文件
  3534. System.IO.File.Delete(filePath);
  3535. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3536. if (info != null)
  3537. {
  3538. string[] files = new string[] { };
  3539. if (!string.IsNullOrEmpty(info.Attachment))
  3540. {
  3541. try
  3542. {
  3543. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3544. }
  3545. catch (Exception)
  3546. {
  3547. files = new List<string>() { info.Attachment }.ToArray();
  3548. }
  3549. }
  3550. if (files.Length > 0)
  3551. {
  3552. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3553. string filePath2 = string.Empty;
  3554. if (files1.Length > 0)
  3555. {
  3556. filePath2 = JsonConvert.SerializeObject(files1);
  3557. }
  3558. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3559. .Where(a => a.Id == dto.Id)
  3560. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3561. .ExecuteCommandAsync();
  3562. }
  3563. }
  3564. }
  3565. if (id != 0)
  3566. {
  3567. return Ok(JsonView(true, "成功!"));
  3568. }
  3569. else
  3570. {
  3571. return Ok(JsonView(false, "失败!"));
  3572. }
  3573. }
  3574. catch (Exception ex)
  3575. {
  3576. return Ok(JsonView(false, "程序错误!"));
  3577. throw;
  3578. }
  3579. }
  3580. /// <summary>
  3581. /// 文件上传多个文件 可以带参数
  3582. /// </summary>
  3583. /// <param name="file"></param>
  3584. /// <returns></returns>
  3585. [HttpPost]
  3586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3587. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3588. {
  3589. try
  3590. {
  3591. var TypeName = Request.Headers["TypeName"].ToString();
  3592. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3593. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3594. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3595. var filePahts = new List<string>();
  3596. foreach (var file in files)
  3597. {
  3598. //文件名称
  3599. string projectFileName = file.FileName;
  3600. //上传的文件的路径
  3601. string filePath = $"{fileDir}/{projectFileName}";
  3602. if (TypeName == "A")//A代表团组增减款项
  3603. {
  3604. if (!Directory.Exists(fileDir))
  3605. {
  3606. Directory.CreateDirectory(fileDir);
  3607. }
  3608. //上传的文件的路径
  3609. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3610. }
  3611. else if (TypeName == "B")//B代表商邀相关文件
  3612. {
  3613. if (!Directory.Exists(fileDir))
  3614. {
  3615. Directory.CreateDirectory(fileDir);
  3616. }
  3617. //上传的文件的路径
  3618. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3619. }
  3620. using (FileStream fs = System.IO.File.Create(filePath))
  3621. {
  3622. file.CopyTo(fs);
  3623. fs.Flush();
  3624. }
  3625. filePahts.Add(projectFileName);
  3626. }
  3627. return Ok(JsonView(true, "上传成功!", filePahts));
  3628. }
  3629. catch (Exception ex)
  3630. {
  3631. return Ok(JsonView(false, "程序错误!"));
  3632. }
  3633. }
  3634. #endregion
  3635. #region 商邀费用录入
  3636. /// <summary>
  3637. /// 根据团组Id查询商邀费用列表
  3638. /// </summary>
  3639. /// <param name="dto"></param>
  3640. /// <returns></returns>
  3641. [HttpPost]
  3642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3643. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3644. {
  3645. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3646. if (groupData.Code != 0)
  3647. {
  3648. return Ok(JsonView(false, groupData.Msg));
  3649. }
  3650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3651. }
  3652. /// <summary>
  3653. /// 商邀费用列表
  3654. /// 下载文件
  3655. /// </summary>
  3656. /// <param name="dto"></param>
  3657. /// <returns></returns>
  3658. [HttpGet("{id}")]
  3659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3660. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3661. {
  3662. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3663. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3664. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3665. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3666. var filePaths = new List<string>();
  3667. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3668. try
  3669. {
  3670. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3671. }
  3672. catch (Exception ex)
  3673. {
  3674. filePaths.Add(info.Attachment);
  3675. }
  3676. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3677. for (int i = 0; i < filePaths.Count; i++)
  3678. {
  3679. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3680. }
  3681. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3682. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3683. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3684. {
  3685. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3686. {
  3687. foreach (string filePath in filePaths)
  3688. {
  3689. if (System.IO.File.Exists(filePath))
  3690. {
  3691. // 获取文件名
  3692. string fileName = Path.GetFileName(filePath);
  3693. // 将文件添加到ZIP归档中
  3694. zipArchive.CreateEntryFromFile(filePath, fileName);
  3695. }
  3696. }
  3697. }
  3698. }
  3699. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3700. }
  3701. /// <summary>
  3702. /// 商邀费用 Info Page 基础数据源
  3703. /// </summary>
  3704. /// <param name="dto"></param>
  3705. /// <returns></returns>
  3706. [HttpPost]
  3707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3708. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3709. {
  3710. try
  3711. {
  3712. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3713. if (groupData.Code != 0)
  3714. {
  3715. return Ok(JsonView(false, groupData.Msg));
  3716. }
  3717. return Ok(JsonView(true, "操作成功", groupData.Data));
  3718. }
  3719. catch (Exception ex)
  3720. {
  3721. return Ok(JsonView(false, ex.Message));
  3722. throw;
  3723. }
  3724. }
  3725. /// <summary>
  3726. /// 根据商邀费用ID查询C表和商邀费用数据
  3727. /// </summary>
  3728. /// <param name="dto"></param>
  3729. /// <returns></returns>
  3730. [HttpPost]
  3731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3732. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3733. {
  3734. try
  3735. {
  3736. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3737. if (groupData.Code != 0)
  3738. {
  3739. return Ok(JsonView(false, groupData.Msg));
  3740. }
  3741. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3742. }
  3743. catch (Exception ex)
  3744. {
  3745. return Ok(JsonView(false, ex.Message));
  3746. throw;
  3747. }
  3748. }
  3749. /// <summary>
  3750. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3751. /// </summary>
  3752. /// <param name="dto"></param>
  3753. /// <returns></returns>
  3754. [HttpPost]
  3755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3756. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3757. {
  3758. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3759. if (groupData.Code != 0)
  3760. {
  3761. return Ok(JsonView(false, groupData.Msg));
  3762. }
  3763. #region 应用推送
  3764. try
  3765. {
  3766. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3767. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3768. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3769. //2024-10-21 新增LZ UID
  3770. var userIds = new List<int>() { 21 };
  3771. string title = $"系统通知";
  3772. string content = "";
  3773. var diId = dto.DiId;
  3774. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3775. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3776. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3777. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3778. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3779. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3780. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3781. }
  3782. catch (Exception ex)
  3783. {
  3784. }
  3785. #endregion
  3786. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3787. }
  3788. /// <summary>
  3789. /// 商邀删除
  3790. /// </summary>
  3791. /// <param name="dto"></param>
  3792. /// <returns></returns>
  3793. [HttpPost]
  3794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3795. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3796. {
  3797. try
  3798. {
  3799. _sqlSugar.BeginTran();
  3800. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3801. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3802. {
  3803. IsDel = 1,
  3804. DeleteUserId = dto.DeleteUserId,
  3805. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3806. })
  3807. .Where(it => it.Id == dto.Id)
  3808. .ExecuteCommand();
  3809. if (res1 > 0)
  3810. {
  3811. int _diId = 0;
  3812. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3813. if (_ioaInfo != null)
  3814. {
  3815. _diId = _ioaInfo.DiId;
  3816. }
  3817. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3818. .SetColumns(a => new Grp_CreditCardPayment()
  3819. {
  3820. IsDel = 1,
  3821. DeleteUserId = dto.DeleteUserId,
  3822. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3823. })
  3824. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3825. .ExecuteCommand();
  3826. if (res2 > 0)
  3827. {
  3828. _sqlSugar.CommitTran();
  3829. return Ok(JsonView(true, "删除成功!"));
  3830. }
  3831. }
  3832. _sqlSugar.RollbackTran();
  3833. return Ok(JsonView(false, "删除失败"));
  3834. }
  3835. catch (Exception ex)
  3836. {
  3837. _sqlSugar.RollbackTran();
  3838. return Ok(JsonView(false, ex.Message));
  3839. }
  3840. }
  3841. /// <summary>
  3842. /// 团组模块文件上传
  3843. /// </summary>
  3844. /// <param name="dto"></param>
  3845. /// <returns></returns>
  3846. [HttpPost]
  3847. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3848. {
  3849. var jw = JsonView(false);
  3850. long M = 1024 * 1024;
  3851. if (dto.Files == null || dto.Files.Count == 0)
  3852. {
  3853. jw.Msg = "无文件信息!";
  3854. return Ok(jw);
  3855. }
  3856. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3857. {
  3858. jw.Msg = "文件大小超过20M!";
  3859. return Ok(jw);
  3860. }
  3861. //var nameSp = dto.File.FileName.Split(".");
  3862. //if (nameSp.Length < 2)
  3863. //{
  3864. // jw.Msg = "拓展名称有误!";
  3865. // return Ok(jw);
  3866. //}
  3867. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3868. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3869. //{
  3870. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3871. // return Ok(jw);
  3872. //}
  3873. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3874. if (Ctable == null)
  3875. {
  3876. jw.Msg = "Ctable指向有误!";
  3877. return Ok(jw);
  3878. }
  3879. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3880. if (groupInfo == null)
  3881. {
  3882. jw.Msg = "团组信息不存在!";
  3883. return Ok(jw);
  3884. }
  3885. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3886. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3887. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3888. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3889. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3890. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3891. try
  3892. {
  3893. if (!Directory.Exists(fileBase))
  3894. {
  3895. Directory.CreateDirectory(fileBase);
  3896. }
  3897. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3898. foreach (var fileStream in dto.Files)
  3899. {
  3900. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3901. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3902. {
  3903. Cid = dto.Cid,
  3904. CreateTime = DateTime.Now,
  3905. CreateUserId = dto.Userid,
  3906. Ctable = dto.Ctable,
  3907. Diid = dto.Diid,
  3908. IsDel = 0,
  3909. FilePath = saveFilePath,
  3910. FileName = fileStream.FileName
  3911. };
  3912. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3913. {
  3914. fileStream.CopyTo(fs);
  3915. fs.Flush();
  3916. }
  3917. saveArr.Add(file);
  3918. }
  3919. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3920. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3921. jw = JsonView(true, "保存成功!", new
  3922. {
  3923. count = addResult,
  3924. filesName = saveArr.Select(x => x.FileName)
  3925. });
  3926. }
  3927. catch (Exception ex)
  3928. {
  3929. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3930. {
  3931. count = 0,
  3932. filesName = new string[0],
  3933. });
  3934. }
  3935. return Ok(jw);
  3936. }
  3937. /// <summary>
  3938. /// 查询各模块已保存文件
  3939. /// </summary>
  3940. /// <param name="dto"></param>
  3941. /// <returns></returns>
  3942. [HttpPost]
  3943. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3944. {
  3945. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3946. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3947. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3948. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3949. {
  3950. expression = Expressionable.Create<Grp_GroupModelFile>()
  3951. .And(x => visaIds.Contains(x.CreateUserId));
  3952. }
  3953. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3954. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3955. .Where(expression.ToExpression())
  3956. .ToList();
  3957. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3958. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3959. {
  3960. x.FileName,
  3961. x.Id,
  3962. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3963. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3964. })));
  3965. }
  3966. /// <summary>
  3967. /// 下载该团组下的所有文件
  3968. /// </summary>
  3969. /// <param name="dto"></param>
  3970. /// <returns></returns>
  3971. [HttpPost]
  3972. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3973. {
  3974. var jw = JsonView(false);
  3975. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3976. if (groupInfo == null)
  3977. {
  3978. jw.Msg = "团组信息不存在!";
  3979. return Ok(jw);
  3980. }
  3981. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3982. var isModule = Convert.ToBoolean(dto.isModule);
  3983. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3984. IOOperatorHelper io = new IOOperatorHelper();
  3985. if (isModule)
  3986. {
  3987. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3988. foreach (var moduleArr in moduleGroup)
  3989. {
  3990. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3991. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3992. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3993. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3994. foreach (var item in moduleArr)
  3995. {
  3996. if (System.IO.File.Exists(item.FilePath))
  3997. {
  3998. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3999. {
  4000. byte[] bytes = new byte[fileStream.Length];
  4001. fileStream.Read(bytes, 0, bytes.Length);
  4002. fileStream.Close();
  4003. Stream stream = new MemoryStream(bytes);
  4004. chiZips.Add(item.FileName, stream);
  4005. }
  4006. }
  4007. }
  4008. if (chiZips.Count > 0)
  4009. {
  4010. var byts = io.ConvertZipStream(chiZips);
  4011. Stream stream = new MemoryStream(byts);
  4012. Zips.Add(key.Name + "_.zip", stream);
  4013. }
  4014. }
  4015. }
  4016. else
  4017. {
  4018. foreach (var item in dbQuery)
  4019. {
  4020. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4021. {
  4022. byte[] bytes = new byte[fileStream.Length];
  4023. fileStream.Read(bytes, 0, bytes.Length);
  4024. fileStream.Close();
  4025. Stream stream = new MemoryStream(bytes);
  4026. while (Zips.Keys.Contains(item.FileName))
  4027. {
  4028. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4029. }
  4030. Zips.Add(item.FileName, stream);
  4031. }
  4032. }
  4033. }
  4034. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4035. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4036. if (Zips.Count > 0)
  4037. {
  4038. var byts = io.ConvertZipStream(Zips);
  4039. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4040. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4041. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4042. }
  4043. else
  4044. {
  4045. jw.Msg = "暂无生成文件!";
  4046. }
  4047. return Ok(jw);
  4048. }
  4049. /// <summary>
  4050. /// 下载该团组下此模块的所有文件
  4051. /// </summary>
  4052. /// <param name="dto"></param>
  4053. /// <returns></returns>
  4054. [HttpPost]
  4055. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4056. {
  4057. var jw = JsonView(false);
  4058. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4059. if (groupInfo == null)
  4060. {
  4061. jw.Msg = "团组信息不存在!";
  4062. return Ok(jw);
  4063. }
  4064. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4065. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4066. && x.IsDel == 0);
  4067. if (key == null)
  4068. {
  4069. jw.Msg = "Ctable指向错误!";
  4070. return Ok(jw);
  4071. }
  4072. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4073. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4074. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4075. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4076. IOOperatorHelper io = new IOOperatorHelper();
  4077. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4078. foreach (var item in dbQuery)
  4079. {
  4080. if (System.IO.File.Exists(item.FilePath))
  4081. {
  4082. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4083. {
  4084. byte[] bytes = new byte[fileStream.Length];
  4085. fileStream.Read(bytes, 0, bytes.Length);
  4086. fileStream.Close();
  4087. Stream stream = new MemoryStream(bytes);
  4088. while (Zips.Keys.Contains(item.FileName))
  4089. {
  4090. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4091. }
  4092. Zips.Add(item.FileName, stream);
  4093. }
  4094. }
  4095. }
  4096. if (Zips.Count > 0)
  4097. {
  4098. var byts = io.ConvertZipStream(Zips);
  4099. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4100. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4101. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4102. }
  4103. else
  4104. {
  4105. jw.Msg = "暂无生成文件!";
  4106. }
  4107. return Ok(jw);
  4108. }
  4109. /// <summary>
  4110. /// 删除该团组下的指定文件
  4111. /// </summary>
  4112. /// <param name="dto"></param>
  4113. /// <returns></returns>
  4114. [HttpPost]
  4115. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4116. {
  4117. var jw = JsonView(false);
  4118. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4119. if (sing == null)
  4120. {
  4121. jw.Msg = "暂无";
  4122. return Ok(jw);
  4123. }
  4124. if (System.IO.File.Exists(sing.FilePath))
  4125. {
  4126. try
  4127. {
  4128. System.IO.File.Delete(sing.FilePath);
  4129. }
  4130. catch (Exception ex)
  4131. {
  4132. jw.Msg = "删除失败!" + ex.Message;
  4133. return Ok(jw);
  4134. }
  4135. }
  4136. sing.IsDel = 1;
  4137. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4138. sing.DeleteUserId = dto.UserId;
  4139. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4140. jw = JsonView(true, "删除成功!");
  4141. return Ok(jw);
  4142. }
  4143. #endregion
  4144. #region 团组英文资料
  4145. /// <summary>
  4146. /// 查询团组英文所有资料
  4147. /// </summary>
  4148. /// <param name="dto"></param>
  4149. /// <returns></returns>
  4150. [HttpPost]
  4151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4152. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4153. {
  4154. try
  4155. {
  4156. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4157. if (groupData.Code != 0)
  4158. {
  4159. return Ok(JsonView(false, groupData.Msg));
  4160. }
  4161. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4162. }
  4163. catch (Exception ex)
  4164. {
  4165. return Ok(JsonView(false, "程序错误!"));
  4166. throw;
  4167. }
  4168. }
  4169. /// <summary>
  4170. /// 团组英文资料操作(Status:1.新增,2.修改)
  4171. /// </summary>
  4172. /// <param name="dto"></param>
  4173. /// <returns></returns>
  4174. [HttpPost]
  4175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4176. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4177. {
  4178. try
  4179. {
  4180. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4181. if (groupData.Code != 0)
  4182. {
  4183. return Ok(JsonView(false, groupData.Msg));
  4184. }
  4185. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4186. }
  4187. catch (Exception ex)
  4188. {
  4189. return Ok(JsonView(false, "程序错误!"));
  4190. throw;
  4191. }
  4192. }
  4193. /// <summary>
  4194. /// 团组英文资料Id查询数据
  4195. /// </summary>
  4196. /// <param name="dto"></param>
  4197. /// <returns></returns>
  4198. [HttpPost]
  4199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4200. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4201. {
  4202. try
  4203. {
  4204. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4205. if (_DelegationEnData != null)
  4206. {
  4207. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4208. }
  4209. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4210. }
  4211. catch (Exception ex)
  4212. {
  4213. return Ok(JsonView(false, "程序错误!"));
  4214. throw;
  4215. }
  4216. }
  4217. /// <summary>
  4218. /// 团组英文资料删除
  4219. /// </summary>
  4220. /// <param name="dto"></param>
  4221. /// <returns></returns>
  4222. [HttpPost]
  4223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4224. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4225. {
  4226. try
  4227. {
  4228. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4229. if (!res)
  4230. {
  4231. return Ok(JsonView(false, "删除失败"));
  4232. }
  4233. return Ok(JsonView(true, "删除成功!"));
  4234. }
  4235. catch (Exception ex)
  4236. {
  4237. return Ok(JsonView(false, "程序错误!"));
  4238. throw;
  4239. }
  4240. }
  4241. #endregion
  4242. #region 导出邀请函
  4243. /// <summary>
  4244. /// 导出邀请函页面初始化
  4245. /// </summary>
  4246. /// <param name="dto"></param>
  4247. /// <returns></returns>
  4248. [HttpPost]
  4249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4250. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4251. {
  4252. try
  4253. {
  4254. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4255. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4256. if (dto.DiId == 0)
  4257. {
  4258. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4259. }
  4260. else
  4261. {
  4262. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4263. }
  4264. return Ok(JsonView(true, "查询成功!", new
  4265. {
  4266. deleClient = crm_Deles,
  4267. delegations = grp_Delegations
  4268. }));
  4269. }
  4270. catch (Exception ex)
  4271. {
  4272. return Ok(JsonView(false, "程序错误!"));
  4273. throw;
  4274. }
  4275. }
  4276. /// <summary>
  4277. /// 导出邀请函
  4278. /// </summary>
  4279. /// <param name="dto"></param>
  4280. /// <returns></returns>
  4281. [HttpPost]
  4282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4283. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4284. {
  4285. #region 参数验证
  4286. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4287. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4288. #endregion
  4289. try
  4290. {
  4291. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4292. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4293. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4294. From Grp_TourClientList tcl
  4295. Left Join
  4296. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4297. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4298. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4299. From Crm_DeleClient dc
  4300. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4301. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4302. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4303. Where dc.IsDel = 0) temp
  4304. On temp.DcId =tcl.ClientId
  4305. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4306. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4307. List<string> texts = new List<string>();
  4308. if (datas.Count != 0)
  4309. {
  4310. foreach (TourClientListDetailsView item in datas)
  4311. {
  4312. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4313. {
  4314. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4315. }
  4316. else
  4317. {
  4318. string name = item.LastName + item.FirstName;
  4319. texts.Add(name);
  4320. }
  4321. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4322. {
  4323. if (!transDic.ContainsKey(item.Job))
  4324. {
  4325. texts.Add(item.Job);
  4326. }
  4327. }
  4328. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4329. {
  4330. texts.Add(item.CompanyFullName);
  4331. }
  4332. }
  4333. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4334. if (transData.Count > 0)
  4335. {
  4336. foreach (TranslateResult item in transData)
  4337. {
  4338. if (!transDic.ContainsKey(item.Query))
  4339. {
  4340. transDic.Add(item.Query, item.Translation);
  4341. }
  4342. }
  4343. }
  4344. List<GuestList> list = new List<GuestList>();
  4345. foreach (TourClientListDetailsView dele in datas)
  4346. {
  4347. GuestList guestList = new GuestList();
  4348. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4349. {
  4350. guestList.Name = dele.Pinyin;
  4351. }
  4352. else
  4353. {
  4354. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4355. guestList.Name = Name;
  4356. }
  4357. if (dele.Sex == 0)
  4358. {
  4359. guestList.Sex = "Male";
  4360. }
  4361. else if (dele.Sex == 1)
  4362. {
  4363. guestList.Sex = "Female";
  4364. }
  4365. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4366. if (!string.IsNullOrEmpty(dele.Job))
  4367. {
  4368. guestList.Job = dele.Job;
  4369. }
  4370. list.Add(guestList);
  4371. }
  4372. //载入模板
  4373. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4374. DocumentBuilder builder = new DocumentBuilder(doc);
  4375. //获取word里所有表格
  4376. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4377. //获取所填表格的序数
  4378. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4379. var rowStart = tableOne.Rows[0]; //获取第1行
  4380. //循环赋值
  4381. for (int i = 0; i < list.Count; i++)
  4382. {
  4383. builder.MoveToCell(0, i + 1, 0, 0);
  4384. builder.Write(list[i].Name.ToString());
  4385. builder.MoveToCell(0, i + 1, 1, 0);
  4386. builder.Write(list[i].Sex.ToString());
  4387. builder.MoveToCell(0, i + 1, 2, 0);
  4388. builder.Write(list[i].DOB.ToString());
  4389. builder.MoveToCell(0, i + 1, 3, 0);
  4390. builder.Write(list[i].Job.ToString());
  4391. }
  4392. //删除多余行
  4393. while (tableOne.Rows.Count > list.Count + 1)
  4394. {
  4395. tableOne.Rows.RemoveAt(list.Count + 1);
  4396. }
  4397. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4398. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4399. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4400. doc.Save(filePath);
  4401. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4402. return Ok(JsonView(true, "操作成功!", Url));
  4403. }
  4404. else
  4405. {
  4406. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4407. }
  4408. }
  4409. catch (Exception ex)
  4410. {
  4411. return Ok(JsonView(false, ex.Message));
  4412. throw;
  4413. }
  4414. }
  4415. #endregion
  4416. #region 团组经理模块 出入境费用
  4417. /// <summary>
  4418. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4419. /// </summary>
  4420. /// <returns></returns>
  4421. [HttpPost]
  4422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4423. public async Task<IActionResult> SetDayAndCostAreaChange()
  4424. {
  4425. try
  4426. {
  4427. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4428. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4429. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4430. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4431. foreach (var item in unite) //处理交集数据
  4432. {
  4433. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4434. }
  4435. foreach (var item in merge) //处理差集数据
  4436. {
  4437. int nationalTravelFeeId = 0;
  4438. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4439. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4440. else
  4441. {
  4442. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4443. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4444. }
  4445. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4446. }
  4447. //只更新dayAndCost 的 nationalTravelFeeId;
  4448. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4449. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4450. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4451. }
  4452. catch (Exception ex)
  4453. {
  4454. return Ok(JsonView(false, ex.Message));
  4455. throw;
  4456. }
  4457. }
  4458. /// <summary>
  4459. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4460. /// </summary>
  4461. /// <returns></returns>
  4462. [HttpPost]
  4463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4464. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4465. {
  4466. try
  4467. {
  4468. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4469. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4470. //SetDataInfoView
  4471. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4472. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4473. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4474. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4475. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4476. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4477. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4478. //默认币种显示
  4479. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4480. {
  4481. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4482. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4483. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4484. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4485. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4486. };
  4487. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4488. if (_currencyRate.Count > 0)
  4489. {
  4490. foreach (var item in _currencyInfos)
  4491. {
  4492. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4493. if (rateInfo != null)
  4494. {
  4495. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4496. rate1 *= 1.035M;
  4497. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4498. }
  4499. }
  4500. }
  4501. return Ok(JsonView(true, "查询成功!", new
  4502. {
  4503. GroupNameData = groupNameData.Data,
  4504. CurrencyData = _CurrencyData,
  4505. WordTypeData = _WordTypeData,
  4506. ExcelTypeData = _ExcelTypeData,
  4507. CurrencyInit = _currencyInfos
  4508. }));
  4509. }
  4510. catch (Exception ex)
  4511. {
  4512. return Ok(JsonView(false, ex.Message));
  4513. throw;
  4514. }
  4515. }
  4516. /// <summary>
  4517. /// 团组模块 - 出入境费用
  4518. /// 实时汇率 tips
  4519. /// 签证费用 tips
  4520. /// 机票费用 tips
  4521. /// </summary>
  4522. /// <returns></returns>
  4523. [HttpPost]
  4524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4525. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4526. {
  4527. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4528. //默认币种显示
  4529. var _currencyInfos = _currencyInit;
  4530. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4531. List<dynamic> reteInfos = new List<dynamic>();
  4532. if (_currencyRate.Count > 0)
  4533. {
  4534. foreach (var item in _currencyInfos)
  4535. {
  4536. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4537. if (rateInfo != null)
  4538. {
  4539. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4540. decimal rate1 = item.Rate;
  4541. rate1 *= 1.03M;
  4542. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4543. reteInfos.Add(new
  4544. {
  4545. currCode = item.CurrencyCode,
  4546. currName = item.CurrencyName,
  4547. rate = rate2,
  4548. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4549. });
  4550. }
  4551. }
  4552. }
  4553. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4554. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4555. return Ok(JsonView(true, "查询成功!", new
  4556. {
  4557. //GroupNameData = groupNameData.Data,
  4558. visaData = visaData.Data,
  4559. airData = airData.Data,
  4560. reteInfos = reteInfos
  4561. }));
  4562. }
  4563. /// <summary>
  4564. /// 团组模块 - 出入境费用 - Info
  4565. /// </summary>
  4566. /// <returns></returns>
  4567. [HttpPost]
  4568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4569. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4570. {
  4571. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4572. }
  4573. /// <summary>
  4574. /// 团组模块 - 出入境费用 - Add And Update
  4575. /// </summary>
  4576. /// <returns></returns>
  4577. [HttpPost]
  4578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4579. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4580. {
  4581. try
  4582. {
  4583. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4584. if (dto.DayOtherPriceData.Any())
  4585. {
  4586. var inserList = dto.DayOtherPriceData
  4587. .Where(x => x.Id == 0)
  4588. .Select(x => new Grp_DayOtherPrice
  4589. {
  4590. Cost = x.Cost,
  4591. Id = x.Id,
  4592. CreateTime = DateTime.Now,
  4593. CreateUserId = dto.UserId,
  4594. Currency = x.Currency,
  4595. Diid = x.DiId,
  4596. Index = x.Index,
  4597. IsDel = 0,
  4598. SetDataId = x.SetDataId,
  4599. SubTotal = x.SubTotal,
  4600. Remark = x.Remark
  4601. })
  4602. .ToList();
  4603. var updateList = dto.DayOtherPriceData
  4604. .Where(x => x.Id != 0)
  4605. .Select(x => new Grp_DayOtherPrice
  4606. {
  4607. Cost = x.Cost,
  4608. Id = x.Id,
  4609. CreateTime = DateTime.Now,
  4610. CreateUserId = dto.UserId,
  4611. Currency = x.Currency,
  4612. Diid = x.DiId,
  4613. Index = x.Index,
  4614. IsDel = 0,
  4615. SetDataId = x.SetDataId,
  4616. SubTotal = x.SubTotal,
  4617. Remark = x.Remark
  4618. })
  4619. .ToList();
  4620. //添加
  4621. _sqlSugar.BeginTran();
  4622. if (inserList.Any())
  4623. {
  4624. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4625. }
  4626. if (updateList.Any())
  4627. {
  4628. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4629. }
  4630. _sqlSugar.CommitTran();
  4631. }
  4632. if (data.Code != 0)
  4633. {
  4634. return Ok(JsonView(false, data.Msg));
  4635. }
  4636. //生成默认文件pdf并且通知人员
  4637. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4638. {
  4639. DiId = dto.DiId,
  4640. ExportType = 1,
  4641. SubTypeId = 1005
  4642. }, "pdf");
  4643. //发送通知
  4644. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4645. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4646. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4647. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4648. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4649. //汇率信息记录
  4650. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4651. return Ok(JsonView(true, data.Msg, data.Data));
  4652. }
  4653. catch (Exception ex)
  4654. {
  4655. return Ok(JsonView(false, ex.Message));
  4656. }
  4657. }
  4658. /// <summary>
  4659. /// 团组模块 - 出入境费用 - Confirm 费用
  4660. /// </summary>
  4661. /// <returns></returns>
  4662. [HttpPost]
  4663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4664. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4665. {
  4666. //TODO:测试完毕需把对应的用户ID更改
  4667. //1、数据表添加字段
  4668. //2、更改字段接口()
  4669. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4670. //3、确认成功 给财务发送消息
  4671. if (_view.Code == 200)
  4672. {
  4673. if (dto.Type == 1)
  4674. {
  4675. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4676. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4677. }
  4678. }
  4679. return Ok(_view);
  4680. }
  4681. /// <summary>
  4682. /// 团组模块 - 出入境费用 - File downlaod
  4683. /// </summary>
  4684. /// <param name="dto"></param>
  4685. /// <returns></returns>
  4686. [HttpPost]
  4687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4688. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4689. {
  4690. try
  4691. {
  4692. if (dto.DiId < 1)
  4693. {
  4694. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4695. }
  4696. if (dto.ExportType < 1)
  4697. {
  4698. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4699. }
  4700. if (dto.SubTypeId < 1)
  4701. {
  4702. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4703. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4704. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4705. 3 团组成员名单 1 团组成员名单", ""));
  4706. }
  4707. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4708. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4709. if (_EnterExitCosts == null)
  4710. {
  4711. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4712. }
  4713. //数据源
  4714. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4715. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4716. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4717. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4718. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4719. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4720. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4721. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4722. .Select((x, a, b) => new
  4723. {
  4724. x.Index,
  4725. itemName = a.Name,
  4726. CurrencyStr = b.Name,
  4727. x.Cost,
  4728. x.SubTotal,
  4729. x.Remark
  4730. })
  4731. .OrderBy((x) => x.Index)
  4732. .ToList(); //其他款项费用
  4733. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4734. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4735. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4736. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4737. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4738. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4739. .Select((tcl, dc, cc) => new ClientInfo
  4740. {
  4741. LastName = dc.LastName,
  4742. FirstName = dc.FirstName,
  4743. Sex = dc.Sex,
  4744. Birthday = dc.BirthDay,
  4745. Company = cc.CompanyFullName,
  4746. Job = dc.Job
  4747. })
  4748. .ToList();
  4749. foreach (var item in DeleClientList)
  4750. {
  4751. EncryptionProcessor.DecryptProperties(item);
  4752. }
  4753. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4754. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4755. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4756. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4757. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4758. if (dto.ExportType == 1) //明细表
  4759. {
  4760. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4761. {
  4762. //获取模板
  4763. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4764. //载入模板
  4765. Document doc = new Document(tempPath);
  4766. DocumentBuilder builder = new DocumentBuilder(doc);
  4767. //利用键值对存放数据
  4768. Dictionary<string, string> dic = new Dictionary<string, string>();
  4769. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4770. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4771. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4772. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4773. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4774. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4775. //境内费用(其他费用)
  4776. if (_EnterExitCosts.ChoiceOne == 1)
  4777. {
  4778. string row1_1 = "";
  4779. if (_EnterExitCosts.Visa > 0)
  4780. {
  4781. //insidePayTotal += _EnterExitCosts.Visa;
  4782. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4783. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4784. {
  4785. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4786. }
  4787. }
  4788. string row1_2 = "";
  4789. if (_EnterExitCosts.YiMiao > 0)
  4790. {
  4791. //insidePayTotal += _EnterExitCosts.YiMiao;
  4792. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4793. }
  4794. if (_EnterExitCosts.HeSuan > 0)
  4795. {
  4796. //insidePayTotal += _EnterExitCosts.HeSuan;
  4797. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4798. }
  4799. if (_EnterExitCosts.Service > 0)
  4800. {
  4801. //insidePayTotal += _EnterExitCosts.Service;
  4802. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4803. }
  4804. string row1_3 = "";
  4805. if (_EnterExitCosts.Safe > 0)
  4806. {
  4807. //insidePayTotal += _EnterExitCosts.Safe;
  4808. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4809. }
  4810. if (_EnterExitCosts.Ticket > 0)
  4811. {
  4812. //insidePayTotal += _EnterExitCosts.Ticket;
  4813. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4814. }
  4815. string row1 = "";
  4816. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4817. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4818. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4819. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4820. dic.Add("Row1Str", row1);
  4821. }
  4822. string airTotalStr = string.Empty,
  4823. airPriceStr = string.Empty;
  4824. //经济舱
  4825. if (_EnterExitCosts.SumJJC == 1)
  4826. {
  4827. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4828. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4829. }
  4830. //公务舱
  4831. if (_EnterExitCosts.SumGWC == 1)
  4832. {
  4833. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4834. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4835. }
  4836. //头等舱
  4837. if (_EnterExitCosts.SumTDC == 1)
  4838. {
  4839. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4840. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4841. }
  4842. dic.Add("AirTotalStr", airTotalStr);
  4843. dic.Add("AirPriceStr", airPriceStr);
  4844. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4845. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4846. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4847. int table1Row = 0,
  4848. table2Row = 0,
  4849. table3Row = 0,
  4850. table4Row = 0,
  4851. table5Row = 0;
  4852. //住宿费
  4853. if (_EnterExitCosts.ChoiceThree == 1)
  4854. {
  4855. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4856. table1Row = dac1.Count;
  4857. #region 填充word表格内容
  4858. for (int i = 0; i < dac1.Count; i++)
  4859. {
  4860. Grp_DayAndCost dac = dac1[i];
  4861. if (dac == null) continue;
  4862. builder.MoveToCell(0, i, 0, 0);
  4863. builder.Write("第" + dac.Days.ToString() + "晚:");
  4864. builder.MoveToCell(0, i, 1, 0);
  4865. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4866. //builder.Write(dac.Place == null ? "" : dac.Place);
  4867. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4868. builder.MoveToCell(0, i, 2, 0);
  4869. builder.Write("费用标准:");
  4870. string curr = "";
  4871. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4872. if (currData != null)
  4873. {
  4874. curr = currData.Name;
  4875. }
  4876. builder.MoveToCell(0, i, 3, 0);
  4877. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4878. builder.MoveToCell(0, i, 4, 0);
  4879. builder.Write("费用小计:");
  4880. builder.MoveToCell(0, i, 5, 0);
  4881. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4882. }
  4883. #endregion
  4884. }
  4885. else dic.Add("SubZS", "0.00");
  4886. //删除多余行
  4887. while (table1.Rows.Count > table1Row)
  4888. {
  4889. table1.Rows.RemoveAt(table1Row);
  4890. }
  4891. //伙食费
  4892. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4893. if (_EnterExitCosts.ChoiceFour == 1)
  4894. {
  4895. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4896. table2Row = dac2.Count;
  4897. #region 填充word表格内容
  4898. for (int i = 0; i < dac2.Count; i++)
  4899. {
  4900. Grp_DayAndCost dac = dac2[i];
  4901. if (dac == null) continue;
  4902. builder.MoveToCell(1, i, 0, 0);
  4903. builder.Write("第" + dac.Days.ToString() + "天:");
  4904. builder.MoveToCell(1, i, 1, 0);
  4905. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4906. builder.MoveToCell(1, i, 2, 0);
  4907. builder.Write("费用标准:");
  4908. string curr = "";
  4909. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4910. if (currData != null)
  4911. {
  4912. curr = currData.Name;
  4913. }
  4914. builder.MoveToCell(1, i, 3, 0);
  4915. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4916. builder.MoveToCell(1, i, 4, 0);
  4917. builder.Write("费用小计:");
  4918. builder.MoveToCell(1, i, 5, 0);
  4919. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4920. }
  4921. #endregion
  4922. }
  4923. else dic.Add("SubHS", "0.00");
  4924. //删除多余行
  4925. while (table2.Rows.Count > table2Row)
  4926. {
  4927. table2.Rows.RemoveAt(table2Row);
  4928. }
  4929. //公杂费
  4930. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4931. if (_EnterExitCosts.ChoiceFive == 1)
  4932. {
  4933. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4934. table3Row = dac3.Count;
  4935. #region 填充word表格内容
  4936. for (int i = 0; i < dac3.Count; i++)
  4937. {
  4938. Grp_DayAndCost dac = dac3[i];
  4939. if (dac == null) continue;
  4940. builder.MoveToCell(2, i, 0, 0);
  4941. builder.Write("第" + dac.Days.ToString() + "天:");
  4942. builder.MoveToCell(2, i, 1, 0);
  4943. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4944. builder.MoveToCell(2, i, 2, 0);
  4945. builder.Write("费用标准:");
  4946. string curr = "";
  4947. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4948. if (currData != null)
  4949. {
  4950. curr = currData.Name;
  4951. }
  4952. builder.MoveToCell(2, i, 3, 0);
  4953. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4954. builder.MoveToCell(2, i, 4, 0);
  4955. builder.Write("费用小计:");
  4956. builder.MoveToCell(2, i, 5, 0);
  4957. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4958. }
  4959. //删除多余行
  4960. while (table3.Rows.Count > table3Row)
  4961. {
  4962. table3.Rows.RemoveAt(table3Row);
  4963. }
  4964. #endregion
  4965. }
  4966. else dic.Add("SubGZF", "0.00");
  4967. //删除多余行
  4968. while (table3.Rows.Count > table3Row)
  4969. {
  4970. table3.Rows.RemoveAt(table3Row);
  4971. }
  4972. //培训费
  4973. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4974. if (_EnterExitCosts.ChoiceSix == 1)
  4975. {
  4976. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4977. dic.Add("SubPX", pxStr);
  4978. table4Row = dac4.Count;
  4979. #region 填充word表格内容
  4980. for (int i = 0; i < dac4.Count; i++)
  4981. {
  4982. Grp_DayAndCost dac = dac4[i];
  4983. if (dac == null) continue;
  4984. builder.MoveToCell(3, i, 0, 0);
  4985. builder.Write("第" + dac.Days.ToString() + "天:");
  4986. builder.MoveToCell(3, i, 1, 0);
  4987. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4988. builder.MoveToCell(3, i, 2, 0);
  4989. builder.Write("费用标准:");
  4990. string curr = "";
  4991. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4992. if (currData != null)
  4993. {
  4994. curr = currData.Name;
  4995. }
  4996. builder.MoveToCell(3, i, 3, 0);
  4997. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4998. builder.MoveToCell(3, i, 4, 0);
  4999. builder.Write("费用小计:");
  5000. builder.MoveToCell(3, i, 5, 0);
  5001. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5002. }
  5003. #endregion
  5004. }
  5005. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5006. //删除多余行
  5007. while (table4.Rows.Count > table4Row)
  5008. {
  5009. table4.Rows.RemoveAt(table4Row);
  5010. }
  5011. //其他费用
  5012. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5013. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5014. {
  5015. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5016. dic.Add("titleQi", qtStr);
  5017. table5Row = dac5.Count;
  5018. #region 填充word表格内容
  5019. for (int i = 0; i < dac5.Count; i++)
  5020. {
  5021. var dac = dac5[i];
  5022. if (dac == null) continue;
  5023. builder.MoveToCell(4, i, 0, 0);
  5024. builder.Write("第" + dac.Index.ToString() + "项:");
  5025. builder.MoveToCell(4, i, 1, 0);
  5026. builder.Write(dac.itemName);
  5027. builder.MoveToCell(4, i, 2, 0);
  5028. builder.Write("费用标准:");
  5029. builder.MoveToCell(4, i, 3, 0);
  5030. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5031. builder.MoveToCell(4, i, 4, 0);
  5032. builder.Write("费用小计:");
  5033. builder.MoveToCell(4, i, 5, 0);
  5034. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5035. builder.MoveToCell(4, i, 6, 0);
  5036. builder.Write("备注:");
  5037. builder.MoveToCell(4, i, 7, 0);
  5038. builder.Write(dac.Remark);
  5039. }
  5040. #endregion
  5041. }
  5042. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5043. //删除多余行
  5044. while (table5.Rows.Count > table5Row)
  5045. {
  5046. table5.Rows.RemoveAt(table5Row);
  5047. }
  5048. //加上其他费用
  5049. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5050. decimal subJJC = 0.00M,
  5051. subGWC = 0.00M,
  5052. subTDC = 0.00M;
  5053. //经济舱
  5054. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5055. //公务舱
  5056. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5057. //头等舱
  5058. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5059. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5060. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5061. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5062. #region 填充word模板书签内容
  5063. foreach (var key in dic.Keys)
  5064. {
  5065. Bookmark bookmark = doc.Range.Bookmarks[key];
  5066. if (bookmark != null)
  5067. {
  5068. builder.MoveToBookmark(key);
  5069. builder.Write(dic[key]);
  5070. }
  5071. }
  5072. #endregion
  5073. //文件名
  5074. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5075. AsposeHelper.removewatermark_v2180();
  5076. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5077. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5078. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5079. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5080. }
  5081. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5082. {
  5083. //获取模板
  5084. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5085. //载入模板
  5086. Document doc = new Document(tempPath);
  5087. DocumentBuilder builder = new DocumentBuilder(doc);
  5088. Dictionary<string, string> dic = new Dictionary<string, string>();
  5089. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5090. {
  5091. List<string> list = new List<string>();
  5092. try
  5093. {
  5094. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5095. foreach (var item in spilitArr)
  5096. {
  5097. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5098. var depCode = spDotandEmpty[2].Substring(0, 3);
  5099. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5100. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5101. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5102. list.Add(depName);
  5103. list.Add(arrName);
  5104. }
  5105. list = list.Distinct().ToList();
  5106. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5107. }
  5108. catch (Exception)
  5109. {
  5110. dic.Add("ReturnCode", "行程录入不正确!");
  5111. }
  5112. }
  5113. else
  5114. {
  5115. dic.Add("ReturnCode", "未录入行程!");
  5116. }
  5117. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5118. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5119. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5120. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5121. {
  5122. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5123. dic.Add("Day", sp.Days.ToString());
  5124. }
  5125. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5126. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5127. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5128. //dic.Add("Names", Names);
  5129. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5130. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5131. decimal dac1totalPrice = 0.00M;
  5132. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5133. foreach (var dac in dac1)
  5134. {
  5135. if (dac.SubTotal == 0.00M)
  5136. {
  5137. continue;
  5138. }
  5139. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5140. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5141. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5142. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5143. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5144. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5145. builder.Write(currency);//币种
  5146. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5147. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5148. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5149. builder.Write("");//人数
  5150. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5151. builder.Write("");//天数
  5152. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5153. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5154. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5155. decimal rate = 0.00M;
  5156. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5157. builder.Write(rate.ToString("#0.0000"));//汇率
  5158. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5159. decimal rbmPrice = dac.SubTotal;
  5160. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5161. accommodationStartIndex++;
  5162. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5163. }
  5164. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5165. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5166. {
  5167. table1.Rows.RemoveAt(i - 1);
  5168. foodandotherStartIndex--;
  5169. }
  5170. if (dac2.Count == dac3.Count)//国家 币种 金额
  5171. {
  5172. for (int i = 0; i < dac2.Count; i++)
  5173. {
  5174. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5175. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5176. }
  5177. }
  5178. decimal dac2totalPrice = 0.00M;
  5179. foreach (var dac in dac2)
  5180. {
  5181. if (dac.SubTotal == 0)
  5182. {
  5183. continue;
  5184. }
  5185. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5186. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5187. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5188. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5189. builder.Write(currency);//币种
  5190. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5191. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5192. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5193. builder.Write("");//人数
  5194. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5195. builder.Write("");//天数
  5196. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5197. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5198. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5199. decimal rate = 0.00M;
  5200. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5201. builder.Write(rate.ToString("#0.0000"));//汇率
  5202. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5203. decimal rbmPrice = dac.SubTotal;
  5204. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5205. foodandotherStartIndex++;
  5206. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5207. }
  5208. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5209. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5210. {
  5211. table1.Rows.RemoveAt(i - 1);
  5212. }
  5213. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5214. string otherFeeStr = "";
  5215. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5216. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5217. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5218. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5219. foreach (var otherInfo in dac5)
  5220. {
  5221. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5222. }
  5223. #endregion
  5224. if (otherFeeStr.Length > 0)
  5225. {
  5226. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5227. otherFeeStr = $"({otherFeeStr})";
  5228. dic.Add("OtherFeeStr", otherFeeStr);
  5229. }
  5230. //总计
  5231. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5232. //国际旅费
  5233. string outsideAir = string.Empty;
  5234. string allPriceAir = string.Empty;
  5235. if (_EnterExitCosts.SumJJC == 1)
  5236. {
  5237. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5238. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5239. }
  5240. if (_EnterExitCosts.SumGWC == 1)
  5241. {
  5242. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5243. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5244. }
  5245. if (_EnterExitCosts.SumTDC == 1)
  5246. {
  5247. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5248. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5249. }
  5250. dic.Add("InTravelPrice", $"({outsideAir})");
  5251. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5252. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5253. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5254. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5255. foreach (var key in dic.Keys)
  5256. {
  5257. builder.MoveToBookmark(key);
  5258. builder.Write(dic[key]);
  5259. }
  5260. //模板文件名
  5261. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5262. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5263. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5264. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5265. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5266. }
  5267. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5268. {
  5269. //获取模板
  5270. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5271. //载入模板
  5272. WorkbookDesigner designer = new WorkbookDesigner();
  5273. designer.Workbook = new Workbook(tempPath);
  5274. Dictionary<string, string> dic = new Dictionary<string, string>();
  5275. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5276. {
  5277. List<string> list = new List<string>();
  5278. try
  5279. {
  5280. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5281. foreach (var item in spilitArr)
  5282. {
  5283. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5284. var depCode = spDotandEmpty[2].Substring(0, 3);
  5285. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5286. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5287. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5288. list.Add(depName);
  5289. list.Add(arrName);
  5290. }
  5291. list = list.Distinct().ToList();
  5292. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5293. }
  5294. catch (Exception)
  5295. {
  5296. dic.Add("ReturnCode", "行程录入不正确!");
  5297. }
  5298. }
  5299. else
  5300. {
  5301. dic.Add("ReturnCode", "未录入行程!");
  5302. }
  5303. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5304. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5305. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5306. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5307. {
  5308. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5309. dic.Add("Day", sp.Days.ToString());
  5310. }
  5311. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5312. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5313. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5314. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5315. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5316. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5317. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5318. designer.SetDataSource("Name", Names);
  5319. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5320. designer.SetDataSource("Day", dic["Day"] + "天");
  5321. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5322. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5323. int startIndex = 10;
  5324. const int startIndexcopy = 10;
  5325. if (dac2.Count == dac3.Count)//国家 币种 金额
  5326. {
  5327. for (int i = 0; i < dac2.Count; i++)
  5328. {
  5329. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5330. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5331. }
  5332. }
  5333. DataTable dtdac1 = new DataTable();
  5334. List<string> place = new List<string>();
  5335. dtdac1.Columns.AddRange(new DataColumn[] {
  5336. new DataColumn(){ ColumnName = "city"},
  5337. new DataColumn(){ ColumnName = "curr"},
  5338. new DataColumn(){ ColumnName = "criterion"},
  5339. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5340. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5341. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5342. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5343. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5344. });
  5345. DataTable dtdac2 = new DataTable();
  5346. dtdac2.Columns.AddRange(new DataColumn[] {
  5347. new DataColumn(){ ColumnName = "city"},
  5348. new DataColumn(){ ColumnName = "curr"},
  5349. new DataColumn(){ ColumnName = "criterion"},
  5350. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5351. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5352. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5353. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5354. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5355. });
  5356. dtdac1.TableName = "tb1";
  5357. dtdac2.TableName = "tb2";
  5358. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5359. foreach (var item in dac1)
  5360. {
  5361. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5362. if (place.Contains(item.Place))
  5363. {
  5364. continue;
  5365. }
  5366. DataRow row = dtdac1.NewRow();
  5367. row["city"] = item.Place;
  5368. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5369. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5370. row["curr"] = currency;
  5371. row["rate"] = rate.ToString("#0.0000");
  5372. row["criterion"] = item.Cost.ToString("#0.00");
  5373. row["number"] = 1;
  5374. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5375. //row["costRMB"] = rbmPrice;
  5376. dtdac1.Rows.Add(row);
  5377. place.Add(item.Place);
  5378. }
  5379. place = new List<string>();
  5380. foreach (var item in dac2)
  5381. {
  5382. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5383. if (place.Contains(item.Place))
  5384. {
  5385. continue;
  5386. }
  5387. DataRow row = dtdac2.NewRow();
  5388. row["city"] = item.Place;
  5389. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5390. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5391. row["curr"] = currency;
  5392. row["rate"] = rate.ToString("#0.0000");
  5393. row["criterion"] = item.Cost.ToString("#0.00");
  5394. row["number"] = 1;
  5395. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5396. //row["cost"] = item.SubTotal;
  5397. //row["costRMB"] = rbmPrice;
  5398. dtdac2.Rows.Add(row);
  5399. place.Add(item.Place);
  5400. //dac2totalPrice += rbmPrice;
  5401. }
  5402. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5403. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5404. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5405. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5406. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5407. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5408. string cell4Str1 = string.Empty;
  5409. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5410. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5411. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5412. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5413. string cellStr = $" 5.其他费用(";
  5414. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5415. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5416. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5417. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5418. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5419. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5420. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5421. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5422. foreach (var otherInfo in dac5)
  5423. {
  5424. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5425. }
  5426. #endregion
  5427. if (cellStr.Length > 8)
  5428. {
  5429. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5430. }
  5431. cellStr += ")";
  5432. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5433. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5434. decimal pxFee = dac4.Sum(it => it.Cost);
  5435. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5436. string celllastStr1 = "";
  5437. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5438. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5439. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5440. celllastStr1 += $",国际旅费 元";
  5441. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5442. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5443. designer.SetDataSource("cell4Str", cell4Str);
  5444. designer.SetDataSource("cellStr", cellStr);
  5445. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5446. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5447. designer.SetDataSource("celllastStr", celllastStr);
  5448. Workbook wb = designer.Workbook;
  5449. var sheet = wb.Worksheets[0];
  5450. //绑定datatable数据集
  5451. designer.SetDataSource(dtdac1);
  5452. designer.SetDataSource(dtdac2);
  5453. designer.Process();
  5454. var rowStart = dtdac1.Rows.Count;
  5455. while (rowStart > 0)
  5456. {
  5457. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5458. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5459. startIndex++;
  5460. rowStart--;
  5461. }
  5462. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5463. startIndex += 1; //总计行
  5464. rowStart = dtdac2.Rows.Count;
  5465. while (rowStart > 0)
  5466. {
  5467. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5468. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5469. startIndex++;
  5470. rowStart--;
  5471. }
  5472. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5473. wb.CalculateFormula(true);
  5474. //模板文件名
  5475. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5476. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5477. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5478. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5479. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5480. }
  5481. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5482. {
  5483. //获取模板
  5484. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5485. //载入模板
  5486. Document doc = new Document(tempPath);
  5487. DocumentBuilder builder = new DocumentBuilder(doc);
  5488. Dictionary<string, string> dic = new Dictionary<string, string>();
  5489. dic.Add("GroupName", _DelegationInfo.TeamName);
  5490. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5491. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5492. string missionLeaderJob = "";//负责人job
  5493. int groupNumber = 0; //团人数
  5494. if (DeleClientList.Count > 0)
  5495. {
  5496. missionLeader = DeleClientList[0]?.Name ?? "";
  5497. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5498. }
  5499. dic.Add("MissionLeader", missionLeader); //团负责人
  5500. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5501. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5502. #region MyRegion
  5503. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5504. //{
  5505. // List<string> list = new List<string>();
  5506. // try
  5507. // {
  5508. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5509. // foreach (var item in spilitArr)
  5510. // {
  5511. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5512. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5513. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5514. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5515. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5516. // list.Add(depName);
  5517. // list.Add(arrName);
  5518. // }
  5519. // list = list.Distinct().ToList();
  5520. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5521. // }
  5522. // catch (Exception)
  5523. // {
  5524. // dic.Add("ReturnCode", "行程录入不正确!");
  5525. // }
  5526. //}
  5527. //else
  5528. //{
  5529. // dic.Add("ReturnCode", "未录入行程!");
  5530. //}
  5531. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5532. dic.Add("ReturnCode", string.Join("、", countrys));
  5533. #endregion
  5534. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5535. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5536. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5537. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5538. //{
  5539. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5540. // dic.Add("Day", sp.Days.ToString());
  5541. //}
  5542. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5543. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5544. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5545. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5546. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5547. //培训人员名单
  5548. int cultivateRowIndex = 7;
  5549. foreach (var item in DeleClientList)
  5550. {
  5551. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5552. builder.Write(item.Name);
  5553. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5554. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5555. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5556. string birthDay = "";
  5557. if (item.Birthday != null)
  5558. {
  5559. DateTime dt = Convert.ToDateTime(item.Birthday);
  5560. birthDay = $"{dt.Year}.{dt.Month}";
  5561. }
  5562. builder.Write(birthDay);
  5563. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5564. builder.Write(item.Company);
  5565. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5566. builder.Write(item.Job);
  5567. cultivateRowIndex++;
  5568. }
  5569. //删除多余行
  5570. //cultivateRowIndex -= 2;
  5571. int delRows = 10 + 7 - cultivateRowIndex;
  5572. if (delRows > 0)
  5573. {
  5574. for (int i = 0; i < delRows; i++)
  5575. {
  5576. table1.Rows.RemoveAt(cultivateRowIndex);
  5577. //cultivateRowIndex++;
  5578. }
  5579. }
  5580. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5581. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5582. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5583. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5584. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5585. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5586. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5587. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5588. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5589. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5590. //其他费用
  5591. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5592. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5593. //其他费用合计
  5594. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5595. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5596. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5597. //公务舱合计
  5598. //国际旅费
  5599. string outsideJJ = "";
  5600. string allPriceJJ = "";
  5601. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5602. {
  5603. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5604. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5605. }
  5606. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5607. {
  5608. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5609. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5610. }
  5611. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5612. {
  5613. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5614. dic.Add("AirFeeTotal", airFeeTotalStr);
  5615. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5616. dic.Add("FeeTotal", feeTotalStr);
  5617. }
  5618. foreach (var key in dic.Keys)
  5619. {
  5620. builder.MoveToBookmark(key);
  5621. builder.Write(dic[key]);
  5622. }
  5623. //模板文件名
  5624. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5625. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5626. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5627. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5628. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5629. }
  5630. }
  5631. else if (dto.ExportType == 2) //表格
  5632. {
  5633. //利用键值对存放数据
  5634. Dictionary<string, string> dic = new Dictionary<string, string>();
  5635. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5636. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5637. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5638. dic.Add("Day", sp.Days.ToString());
  5639. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5640. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5641. {
  5642. //获取模板
  5643. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5644. //载入模板
  5645. Document doc = new Document(tempPath);
  5646. DocumentBuilder builder = new DocumentBuilder(doc);
  5647. dic.Add("TeamName", _DelegationInfo.TeamName);
  5648. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5649. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5650. string missionLeaderName = "",
  5651. missionLeaderJob = "";
  5652. if (DeleClientList.Count > 0)
  5653. {
  5654. missionLeaderName = DeleClientList[0].Name;
  5655. missionLeaderJob = DeleClientList[0].Job;
  5656. }
  5657. dic.Add("MissionLeaderName", missionLeaderName);
  5658. dic.Add("MissionLeaderJob", missionLeaderJob);
  5659. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5660. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5661. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5662. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5663. int rowCount = 10;//总人数行
  5664. int startRowIndex = 7; //起始行
  5665. for (int i = 0; i < DeleClientList.Count; i++)
  5666. {
  5667. builder.MoveToCell(0, startRowIndex, 0, 0);
  5668. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5669. builder.MoveToCell(0, startRowIndex, 1, 0);
  5670. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5671. builder.Write(sex);//性别
  5672. builder.MoveToCell(0, startRowIndex, 2, 0);
  5673. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5674. builder.MoveToCell(0, startRowIndex, 3, 0);
  5675. builder.Write(DeleClientList[i].Company);//工作单位
  5676. builder.MoveToCell(0, startRowIndex, 4, 0);
  5677. builder.Write(DeleClientList[i].Job);//职务及级别
  5678. builder.MoveToCell(0, startRowIndex, 5, 0);
  5679. builder.Write("");//人员属性
  5680. builder.MoveToCell(0, startRowIndex, 6, 0);
  5681. builder.Write("");//上次出国时间
  5682. startRowIndex++;
  5683. }
  5684. int nullRow = rowCount - DeleClientList.Count;//空行
  5685. for (int i = 0; i < nullRow; i++)
  5686. {
  5687. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5688. }
  5689. foreach (var key in dic.Keys)
  5690. {
  5691. builder.MoveToBookmark(key);
  5692. builder.Write(dic[key]);
  5693. }
  5694. //模板文件名
  5695. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5696. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5697. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5698. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5699. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5700. }
  5701. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5702. {
  5703. //获取模板
  5704. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5705. //载入模板
  5706. Document doc = new Document(tempPath);
  5707. DocumentBuilder builder = new DocumentBuilder(doc);
  5708. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5709. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5710. dic.Add("Names", Names);
  5711. int accommodationRows = 12, foodandotherRows = 12;
  5712. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5713. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5714. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5715. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5716. int accommodationStartIndex = 6;
  5717. decimal dac1totalPrice = 0.00M;
  5718. foreach (var dac in dac1)
  5719. {
  5720. if (dac.SubTotal == 0)
  5721. {
  5722. continue;
  5723. }
  5724. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5725. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5726. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5727. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5728. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5729. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5730. builder.Write(currency);//币种
  5731. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5732. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5733. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5734. builder.Write("");//人数
  5735. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5736. builder.Write("");//天数
  5737. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5738. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5739. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5740. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5741. builder.Write(rate.ToString("#0.0000"));//汇率
  5742. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5743. decimal rbmPrice = rate * dac.SubTotal;
  5744. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5745. accommodationStartIndex++;
  5746. dac1totalPrice += rbmPrice;
  5747. }
  5748. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5749. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5750. builder.Write("小计");
  5751. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5752. builder.Write(dac1totalPrice.ToString("#0.00"));
  5753. accommodationStartIndex++;
  5754. int nullRow = accommodationRows - dac1.Count;
  5755. //删除空行
  5756. //if (nullRow > 0)
  5757. //{
  5758. // int rowIndex = accommodationStartIndex;
  5759. // for (int i = 0; i < nullRow; i++)
  5760. // {
  5761. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5762. // row.Remove();
  5763. // rowIndex++;
  5764. // }
  5765. //}
  5766. if (dac2.Count == dac3.Count)//国家 币种 金额
  5767. {
  5768. for (int i = 0; i < dac2.Count; i++)
  5769. {
  5770. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5771. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5772. }
  5773. }
  5774. int foodandotherStartIndex = 19;//
  5775. decimal dac2totalPrice = 0.00M;
  5776. foreach (var dac in dac2)
  5777. {
  5778. if (dac.SubTotal == 0)
  5779. {
  5780. continue;
  5781. }
  5782. //foodandotherStartIndex = 12;
  5783. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5784. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5785. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5786. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5787. builder.Write(currency);//币种
  5788. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5789. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5790. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5791. builder.Write("");//人数
  5792. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5793. builder.Write("");//天数
  5794. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5795. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5796. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5797. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5798. builder.Write(rate.ToString("#0.0000"));//汇率
  5799. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5800. decimal rbmPrice = rate * dac.SubTotal;
  5801. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5802. foodandotherStartIndex++;
  5803. dac2totalPrice += rbmPrice;
  5804. }
  5805. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5806. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5807. //删除空行
  5808. //if (dac2.Count < foodandotherRows)
  5809. //{
  5810. // while (table2.Rows.Count > dac2.Count)
  5811. // {
  5812. // table2.Rows.RemoveAt(dac2.Count);
  5813. // }
  5814. //}
  5815. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5816. string otherFeeStr = "";
  5817. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5818. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5819. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5820. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5821. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5822. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5823. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5824. foreach (var otherInfo in dac5)
  5825. {
  5826. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5827. }
  5828. #endregion
  5829. if (otherFeeStr.Length > 0)
  5830. {
  5831. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5832. otherFeeStr = $"({otherFeeStr})";
  5833. dic.Add("OtherFeeStr", otherFeeStr);
  5834. }
  5835. foreach (var key in dic.Keys)
  5836. {
  5837. builder.MoveToBookmark(key);
  5838. builder.Write(dic[key]);
  5839. }
  5840. //模板文件名
  5841. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5842. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5843. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5844. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5845. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5846. }
  5847. }
  5848. else if (dto.ExportType == 3)
  5849. {
  5850. if (dto.SubTypeId == 1) //团组成员名单
  5851. {
  5852. if (DeleClientList.Count < 1)
  5853. {
  5854. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5855. }
  5856. //获取模板
  5857. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5858. //载入模板
  5859. Document doc = new Document(tempPath);
  5860. DocumentBuilder builder = new DocumentBuilder(doc);
  5861. //获取word里所有表格
  5862. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5863. //获取所填表格的序数
  5864. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5865. var rowStart = tableOne.Rows[0]; //获取第1行
  5866. //循环赋值
  5867. for (int i = 0; i < DeleClientList.Count; i++)
  5868. {
  5869. builder.MoveToCell(0, i + 1, 0, 0);
  5870. builder.Write(DeleClientList[i].Name);
  5871. builder.MoveToCell(0, i + 1, 1, 0);
  5872. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5873. builder.Write(sex);
  5874. builder.MoveToCell(0, i + 1, 2, 0);
  5875. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5876. builder.MoveToCell(0, i + 1, 3, 0);
  5877. builder.Write(DeleClientList[i].Company);
  5878. builder.MoveToCell(0, i + 1, 4, 0);
  5879. builder.Write(DeleClientList[i].Job);
  5880. }
  5881. //删除多余行
  5882. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5883. {
  5884. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5885. }
  5886. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5887. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5888. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5889. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5890. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5891. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5892. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5893. }
  5894. }
  5895. return Ok(JsonView(400, "操作失败!", ""));
  5896. }
  5897. catch (Exception ex)
  5898. {
  5899. return Ok(JsonView(400, ex.Message, ""));
  5900. }
  5901. }
  5902. /// <summary>
  5903. /// 获取三公费用标准city
  5904. /// </summary>
  5905. /// <param name="placeData"></param>
  5906. /// <param name="nationalTravelFeeId"></param>
  5907. /// <returns></returns>
  5908. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5909. {
  5910. string _city = string.Empty;
  5911. if (placeData.Count < 1) return _city;
  5912. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5913. if (data == null) return _city;
  5914. string country = data.Country;
  5915. string city = data.City;
  5916. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5917. else _city = city;
  5918. return _city;
  5919. }
  5920. /// <summary>
  5921. /// 团组模块 - 出入境费用 - 明细表导出
  5922. /// </summary>
  5923. /// <returns></returns>
  5924. [HttpPost]
  5925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5926. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5927. {
  5928. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5929. if (data.Code != 0)
  5930. {
  5931. return Ok(JsonView(false, data.Msg));
  5932. }
  5933. return Ok(JsonView(true, data.Msg, data.Data));
  5934. }
  5935. /// <summary>
  5936. /// 团组模块 - 出入境费用 - 一键清空
  5937. /// </summary>
  5938. /// <returns></returns>
  5939. [HttpPost]
  5940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5941. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5942. {
  5943. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5944. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5945. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5946. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5947. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5948. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5949. .SetColumns(x => new Grp_DayOtherPrice
  5950. {
  5951. IsDel = 1,
  5952. DeleteUserId = dto.UserId,
  5953. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5954. })
  5955. .ExecuteCommandAsync();
  5956. if (_view.Code == 0)
  5957. {
  5958. return Ok(JsonView(true, "操作成功"));
  5959. }
  5960. return Ok(JsonView(false, "操作失败"));
  5961. }
  5962. /// <summary>
  5963. /// 团组模块 - 出入境费用 - 子项删除
  5964. /// </summary>
  5965. /// <returns></returns>
  5966. [HttpPost]
  5967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5968. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5969. {
  5970. try
  5971. {
  5972. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5973. if (data.Code != 0)
  5974. {
  5975. return Ok(JsonView(false, data.Msg));
  5976. }
  5977. return Ok(JsonView(true, "操作成功!", data.Data));
  5978. }
  5979. catch (Exception ex)
  5980. {
  5981. return Ok(JsonView(false, ex.Message));
  5982. }
  5983. }
  5984. /// <summary>
  5985. /// 删除三公其他费用
  5986. /// </summary>
  5987. /// <param name="dto"></param>
  5988. /// <returns></returns>
  5989. [HttpPost]
  5990. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5991. {
  5992. var jw = JsonView(false,"删除失败!");
  5993. var data = new Grp_DayOtherPrice()
  5994. {
  5995. Id = dto.Id,
  5996. IsDel = 1,
  5997. DeleteUserId = dto.DeleteUserId,
  5998. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  5999. };
  6000. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6001. if (del > 0)
  6002. {
  6003. jw.Code = 200;
  6004. jw.Msg = "删除成功!";
  6005. }
  6006. return Ok(jw);
  6007. }
  6008. /// <summary>
  6009. /// 团组模块 - 出入境国家费用标准 List
  6010. /// </summary>
  6011. /// <returns></returns>
  6012. [HttpPost]
  6013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6014. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6015. {
  6016. try
  6017. {
  6018. Stopwatch sw = new Stopwatch();
  6019. sw.Start();
  6020. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6021. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6022. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6023. Where gntf.Isdel = 0");
  6024. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6025. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6026. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6027. //foreach (var item in nationalTravel)
  6028. //{
  6029. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6030. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6031. // if (otherData != null)
  6032. // {
  6033. // cityData.Remove(otherData);
  6034. // cityData.Add(otherData);
  6035. // }
  6036. // nationalTravelFeeData1.Add(new
  6037. // {
  6038. // Country = item.Country,
  6039. // CityData = cityData
  6040. // });
  6041. //}
  6042. sw.Stop();
  6043. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6044. }
  6045. catch (Exception ex)
  6046. {
  6047. return Ok(JsonView(false, ex.Message));
  6048. throw;
  6049. }
  6050. }
  6051. /// <summary>
  6052. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6053. /// </summary>
  6054. /// <returns></returns>
  6055. [HttpPost]
  6056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6057. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6058. {
  6059. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6060. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6061. List<string> countryData = new List<string>();
  6062. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6063. countryData = countryData.Distinct().ToList();
  6064. List<dynamic> dataSource = new List<dynamic>();
  6065. foreach (var item in countryData)
  6066. {
  6067. List<string> cityData1 = new List<string>();
  6068. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6069. var countryData2 = new
  6070. {
  6071. CountryName = item,
  6072. CityData = cityData1
  6073. };
  6074. dataSource.Add(countryData2);
  6075. }
  6076. return Ok(JsonView(true, "查询成功!", dataSource));
  6077. }
  6078. /// <summary>
  6079. /// 团组模块 - 出入境国家费用标准 Page List
  6080. /// </summary>
  6081. /// <returns></returns>
  6082. [HttpPost]
  6083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6084. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6085. {
  6086. int portId = dto.PortType;
  6087. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6088. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6089. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6090. string whereSql = string.Empty;
  6091. if (!string.IsNullOrEmpty(dto.Country))
  6092. {
  6093. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6094. }
  6095. if (!string.IsNullOrEmpty(dto.City))
  6096. {
  6097. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6098. }
  6099. string pageSql = string.Format(@"Select * From (
  6100. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6101. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6102. From Grp_NationalTravelFee gntf
  6103. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6104. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6105. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6106. RefAsync<int> total = 0;
  6107. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6108. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6109. }
  6110. /// <summary>
  6111. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6112. /// </summary>
  6113. /// <returns></returns>
  6114. [HttpPost]
  6115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6116. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6117. {
  6118. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6119. int portId = dto.PortType;
  6120. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6121. string whereSql = string.Empty;
  6122. if (!string.IsNullOrEmpty(dto.Country))
  6123. {
  6124. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6125. }
  6126. if (!string.IsNullOrEmpty(dto.City))
  6127. {
  6128. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6129. }
  6130. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6131. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6132. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6133. From Grp_NationalTravelFee gntf
  6134. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6135. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6136. Where gntf.Isdel = 0 {0} ", whereSql);
  6137. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6138. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6139. }
  6140. /// <summary>
  6141. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6142. /// </summary>
  6143. /// <returns></returns>
  6144. [HttpPost]
  6145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6146. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6147. {
  6148. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6149. if (data.Code != 0)
  6150. {
  6151. return Ok(JsonView(false, data.Msg));
  6152. }
  6153. return Ok(JsonView(true, "操作成功!", data.Data));
  6154. }
  6155. /// <summary>
  6156. /// 团组模块 - 出入境国家费用标准 - Del
  6157. /// </summary>
  6158. /// <returns></returns>
  6159. [HttpPost]
  6160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6161. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6162. {
  6163. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6164. {
  6165. Id = dto.Id,
  6166. DeleteUserId = dto.DeleteUserId,
  6167. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6168. IsDel = 1
  6169. };
  6170. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6171. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6172. .WhereColumns(it => new { it.Id })
  6173. .ExecuteCommandAsync();
  6174. if (delStatus <= 0)
  6175. {
  6176. return Ok(JsonView(false, "删除失败!"));
  6177. }
  6178. return Ok(JsonView(true, "操作成功!"));
  6179. }
  6180. /// <summary>
  6181. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6182. /// 注:Get 请求Headers 加 Token
  6183. /// </summary>
  6184. /// <param name="groupId"></param>
  6185. /// <returns></returns>
  6186. [HttpGet("{groupId}")]
  6187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6188. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6189. {
  6190. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6191. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6192. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6193. data.ForEach(x =>
  6194. {
  6195. x.CreateUserId = _currUserInfo.UserId;
  6196. });
  6197. if (data.Count > 0)
  6198. {
  6199. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6200. if (add > 0)
  6201. {
  6202. return Ok(JsonView(true, "操作成功!"));
  6203. }
  6204. }
  6205. return Ok(JsonView(false, "未操作!"));
  6206. }
  6207. #endregion
  6208. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6209. /// <summary>
  6210. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6211. /// </summary>
  6212. /// <returns></returns>
  6213. [HttpPost]
  6214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6215. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6216. {
  6217. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6218. //SetDataInfoView
  6219. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6220. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6221. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6222. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6223. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6224. //默认币种显示
  6225. var _currencyInfos = _currencyInit;
  6226. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6227. if (_currencyRate.Count > 0)
  6228. {
  6229. foreach (var item in _currencyInfos)
  6230. {
  6231. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6232. if (rateInfo != null)
  6233. {
  6234. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6235. rate1 *= 1.035M;
  6236. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6237. }
  6238. }
  6239. }
  6240. return Ok(JsonView(true, "查询成功!", new
  6241. {
  6242. WordTypeData = _WordTypeData,
  6243. ExcelTypeData = _ExcelTypeData,
  6244. CurrencyInit = _currencyInfos
  6245. }));
  6246. }
  6247. /// <summary>
  6248. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6249. /// </summary>
  6250. /// <returns></returns>
  6251. [HttpPost]
  6252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6253. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6254. {
  6255. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6256. RefAsync<int> total = 0;
  6257. int diId = 0;
  6258. var status = int.TryParse(dto.GroupName, out diId);
  6259. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6260. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6261. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6262. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6263. .Select(x => new
  6264. {
  6265. Id = x.Id,
  6266. GroupName = x.TeamName
  6267. })
  6268. .OrderByDescending(x => x.Id)
  6269. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6270. return Ok(JsonView(true, "查询成功!", data, total));
  6271. }
  6272. /// <summary>
  6273. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6274. /// </summary>
  6275. /// <returns></returns>
  6276. [HttpPost]
  6277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6278. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6279. {
  6280. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6281. RefAsync<int> total = 0;
  6282. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6283. .Where(x => x.IsDel == 0 && x.STid == 66)
  6284. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6285. .Select(x => new
  6286. {
  6287. id = x.Id,
  6288. name = x.Name,
  6289. remark = x.Remark,
  6290. })
  6291. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6292. return Ok(JsonView(true, "查询成功!", data, total));
  6293. }
  6294. /// <summary>
  6295. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  6296. /// </summary>
  6297. /// <returns></returns>
  6298. [HttpPost]
  6299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6300. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6301. {
  6302. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6303. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6304. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6305. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6306. var groupOtherRateData = groupRateData.TeamRates;
  6307. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6308. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6309. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6310. groupOtherRateData = groupOtherRateData
  6311. .Select(x => new TeamRateDescAddCurrencyIdView {
  6312. CurrencyId = x.CurrencyId,
  6313. CurrencyName = x.CurrencyName,
  6314. CurrencyCode = x.CurrencyCode,
  6315. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6316. }).ToList();
  6317. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  6318. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  6319. }
  6320. /// <summary>
  6321. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6322. /// </summary>
  6323. /// <returns></returns>
  6324. [HttpPost]
  6325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6326. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6327. {
  6328. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6329. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6330. var tipsData = new List<int>() {1,2,3 };
  6331. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6332. if (dto.TipsType == 1)
  6333. {
  6334. //默认币种显示
  6335. var _currencyInfos = _currencyInit;
  6336. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6337. List<dynamic> reteInfos = new List<dynamic>();
  6338. if (_currencyRate.Count > 0)
  6339. {
  6340. foreach (var item in _currencyInfos)
  6341. {
  6342. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6343. if (rateInfo != null)
  6344. {
  6345. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6346. decimal rate1 = item.Rate;
  6347. rate1 *= 1.03M;
  6348. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6349. reteInfos.Add(new
  6350. {
  6351. currCode = item.CurrencyCode,
  6352. currName = item.CurrencyName,
  6353. rate = rate2,
  6354. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6355. });
  6356. }
  6357. }
  6358. }
  6359. return Ok(JsonView(true, "查询成功!", reteInfos));
  6360. }
  6361. else if (dto.TipsType == 2)
  6362. {
  6363. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6364. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6365. }
  6366. else if (dto.TipsType == 3)
  6367. {
  6368. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6369. return Ok(JsonView(true, "查询成功!", airData.Data));
  6370. }
  6371. return Ok(JsonView(false));
  6372. }
  6373. /// <summary>
  6374. /// 团组模块 - 出入境国家费用标准-移动端 List
  6375. /// </summary>
  6376. /// <returns></returns>
  6377. [HttpPost]
  6378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6379. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6380. {
  6381. Stopwatch sw = new Stopwatch();
  6382. sw.Start();
  6383. RefAsync<int> total = 0;
  6384. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6385. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6386. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6387. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6388. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6389. .Select((ntf, sd, u) => new
  6390. {
  6391. Id = ntf.Id,
  6392. Area = $"{ntf.Country}-{ntf.City}",
  6393. Currency = ntf.Currency,
  6394. CurrencyCode = sd.Name,
  6395. CurrencyName = sd.Remark,
  6396. RoomCost = ntf.RoomCost,
  6397. FoodCost = ntf.FoodCost,
  6398. PublicCost = ntf.PublicCost,
  6399. LastUpdateUserId = ntf.LastUpdateUserId,
  6400. LastUpdateUserName = u.CnName,
  6401. LastUpdateTime = ntf.LastUpdateTime,
  6402. })
  6403. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6404. sw.Stop();
  6405. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6406. }
  6407. /// <summary>
  6408. /// 团组模块 - 出入境费用-移动端 - Info
  6409. /// </summary>
  6410. /// <returns></returns>
  6411. [HttpPost]
  6412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6413. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6414. {
  6415. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6416. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6417. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6418. return Ok(data);
  6419. }
  6420. /// <summary>
  6421. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6422. /// </summary>
  6423. /// <returns></returns>
  6424. [HttpPost]
  6425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6426. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6427. {
  6428. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6429. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6430. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6431. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6432. if (eecInfo == null) return Ok(mobileInfo);
  6433. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6434. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6435. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6436. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6437. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6438. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6439. {
  6440. SubId = dac.Id,
  6441. DiId = dac.DiId,
  6442. Type = dac.Type,
  6443. Days = dac.Days,
  6444. NationalTravelFeeId = dac.NationalTravelFeeId,
  6445. Arae = $"{ntf.Country}-{ntf.City}",
  6446. Cost = dac.Cost,
  6447. Currency = dac.Currency,
  6448. CurrencyName = sd.Name,
  6449. SubTotal = dac.SubTotal,
  6450. })
  6451. .ToList();
  6452. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6453. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6454. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6455. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6456. mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  6457. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6458. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6459. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6460. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6461. //其他款项
  6462. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6463. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6464. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6465. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6466. .OrderBy((dop, sd1, sd2) => dop.Index)
  6467. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6468. {
  6469. SubId = dop.Id,
  6470. DiId = dop.Diid,
  6471. Index = dop.Index,
  6472. SetDataId = dop.SetDataId,
  6473. SetDataName = sd1.Name,
  6474. Cost = dop.Cost,
  6475. Currency = dop.Currency,
  6476. CurrencyName = sd2.Remark,
  6477. SubTotal = dop.SubTotal,
  6478. Remark = dop.Remark,
  6479. })
  6480. .ToArray();
  6481. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6482. return Ok(mobileInfo);
  6483. }
  6484. /// <summary>
  6485. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6486. /// </summary>
  6487. /// <returns></returns>
  6488. [HttpPost]
  6489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6490. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6491. {
  6492. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6493. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6494. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6495. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6496. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6497. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6498. var subType = dto.SubType;
  6499. if (subType == 1) //1:境内费用
  6500. {
  6501. var oneData = new ChoiceOneMobileSubInfoView()
  6502. {
  6503. Id = eecInfo.Id,
  6504. ChoiceOne = eecInfo.ChoiceOne,
  6505. ChoiceOneTotalCost = eecInfo.InsidePay,
  6506. Visa = eecInfo.Visa,
  6507. VisaRemark = eecInfo.VisaRemark,
  6508. YiMiao = eecInfo.YiMiao,
  6509. HeSuan = eecInfo.HeSuan,
  6510. Service = eecInfo.Service,
  6511. Ticket = eecInfo.Ticket,
  6512. Safe = eecInfo.Safe,
  6513. };
  6514. return Ok(JsonView(oneData));
  6515. }
  6516. else if (subType == 2) //2:国际旅费
  6517. {
  6518. var twoData = new ChoiceTwoMobileSubInfoView() {
  6519. Id = eecInfo.Id,
  6520. ChoiceTwoJJ = eecInfo.SumJJC,
  6521. OutsideJJPay = eecInfo.OutsideJJPay,
  6522. ChoiceTwoGW = eecInfo.SumGWC,
  6523. OutsideGWPay = eecInfo.OutsideGWPay,
  6524. ChoiceTwoTD = eecInfo.SumTDC,
  6525. OutsideTDPay = eecInfo.OutsideTDPay,
  6526. AirJJ = eecInfo.AirJJ,
  6527. AirGW = eecInfo.AirGW,
  6528. AirTD = eecInfo.AirTD,
  6529. CityTranffic = eecInfo.CityTranffic
  6530. };
  6531. return Ok(JsonView(twoData));
  6532. }
  6533. else if (subType == 3) //3:住宿费
  6534. {
  6535. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6536. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6537. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6538. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6539. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6540. {
  6541. SubId = dac.Id,
  6542. DiId = dac.DiId,
  6543. Type = dac.Type,
  6544. Days = dac.Days,
  6545. NationalTravelFeeId = dac.NationalTravelFeeId,
  6546. Arae = $"{ntf.Country}-{ntf.City}",
  6547. Cost = dac.Cost,
  6548. Currency = dac.Currency,
  6549. CurrencyName = sd.Name,
  6550. SubTotal = dac.SubTotal,
  6551. })
  6552. .ToArray();
  6553. var data = new ChoiceMobileSubInfo3To6View() {
  6554. ParentId = eecInfo.Id,
  6555. Choice = eecInfo.ChoiceThree,
  6556. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6557. Details = dayAndCostDatas
  6558. };
  6559. return Ok(JsonView(data));
  6560. }
  6561. else if (subType == 4) //4:伙食费
  6562. {
  6563. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6564. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6565. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6566. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6567. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6568. {
  6569. SubId = dac.Id,
  6570. DiId = dac.DiId,
  6571. Type = dac.Type,
  6572. Days = dac.Days,
  6573. NationalTravelFeeId = dac.NationalTravelFeeId,
  6574. Arae = $"{ntf.Country}-{ntf.City}",
  6575. Cost = dac.Cost,
  6576. Currency = dac.Currency,
  6577. CurrencyName = sd.Name,
  6578. SubTotal = dac.SubTotal,
  6579. })
  6580. .ToArray();
  6581. var data = new ChoiceMobileSubInfo3To6View()
  6582. {
  6583. ParentId = eecInfo.Id,
  6584. Choice = eecInfo.ChoiceFour,
  6585. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6586. Details = dayAndCostDatas
  6587. };
  6588. return Ok(JsonView(data));
  6589. }
  6590. else if (subType == 5) //5:公杂费
  6591. {
  6592. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6593. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6594. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6595. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6596. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6597. {
  6598. SubId = dac.Id,
  6599. DiId = dac.DiId,
  6600. Type = dac.Type,
  6601. Days = dac.Days,
  6602. NationalTravelFeeId = dac.NationalTravelFeeId,
  6603. Arae = $"{ntf.Country}-{ntf.City}",
  6604. Cost = dac.Cost,
  6605. Currency = dac.Currency,
  6606. CurrencyName = sd.Name,
  6607. SubTotal = dac.SubTotal,
  6608. })
  6609. .ToArray();
  6610. var data = new ChoiceMobileSubInfo3To6View()
  6611. {
  6612. ParentId = eecInfo.Id,
  6613. Choice = eecInfo.ChoiceFive,
  6614. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6615. Details = dayAndCostDatas
  6616. };
  6617. return Ok(JsonView(data));
  6618. }
  6619. else if (subType == 6) //6:培训费
  6620. {
  6621. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6622. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6623. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6624. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6625. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6626. {
  6627. SubId = dac.Id,
  6628. DiId = dac.DiId,
  6629. Type = dac.Type,
  6630. Days = dac.Days,
  6631. NationalTravelFeeId = dac.NationalTravelFeeId,
  6632. Arae = $"{ntf.Country}-{ntf.City}",
  6633. Cost = dac.Cost,
  6634. Currency = dac.Currency,
  6635. CurrencyName = sd.Name,
  6636. SubTotal = dac.SubTotal,
  6637. })
  6638. .ToArray();
  6639. var data = new ChoiceMobileSubInfo3To6View()
  6640. {
  6641. ParentId = eecInfo.Id,
  6642. Choice = eecInfo.ChoiceSix,
  6643. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6644. Details = dayAndCostDatas
  6645. };
  6646. return Ok(JsonView(data));
  6647. }
  6648. else if (subType == 7) //7:其他
  6649. {
  6650. //其他款项
  6651. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6652. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6653. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6654. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6655. .OrderBy((dop, sd1, sd2) => dop.Index)
  6656. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6657. {
  6658. SubId = dop.Id,
  6659. DiId = dop.Diid,
  6660. Index = dop.Index,
  6661. SetDataId = dop.SetDataId,
  6662. SetDataName = sd1.Name,
  6663. Cost = dop.Cost,
  6664. Currency = dop.Currency,
  6665. CurrencyName = sd2.Name,
  6666. SubTotal = dop.SubTotal,
  6667. Remark = dop.Remark,
  6668. })
  6669. .ToArray();
  6670. var data = new ChoiceSevenMobileSubInfoView()
  6671. {
  6672. ParentId = eecInfo.Id,
  6673. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6674. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6675. Details = otherData
  6676. };
  6677. return Ok(JsonView(data));
  6678. }
  6679. return Ok(JsonView(false));
  6680. }
  6681. #region op
  6682. /// <summary>
  6683. /// 移动端更新费用消息通知
  6684. /// </summary>
  6685. /// <param name="diid"></param>
  6686. /// <param name="id"></param>
  6687. /// <param name="currUserId"></param>
  6688. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6689. {
  6690. try
  6691. {
  6692. ////生成默认文件pdf并且通知人员
  6693. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6694. //{
  6695. // DiId = diid,
  6696. // ExportType = 1,
  6697. // SubTypeId = 1005
  6698. //}, "pdf");
  6699. ////发送通知
  6700. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6701. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6702. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6703. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6704. ////汇率信息记录
  6705. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6706. }
  6707. catch (Exception ex)
  6708. {
  6709. //记录日志
  6710. throw;
  6711. }
  6712. }
  6713. /// <summary>
  6714. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6715. /// </summary>
  6716. /// <returns></returns>
  6717. [HttpPost]
  6718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6719. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6720. {
  6721. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6722. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6723. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6724. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6725. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6726. int id = dto.Id;
  6727. if (id <= 0) //add
  6728. {
  6729. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6730. if (add < 1) return Ok(JsonView(false));
  6731. id = add;
  6732. }
  6733. else //update
  6734. {
  6735. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6736. if (upd < 1) return Ok(JsonView(false));
  6737. }
  6738. #region 汇率变更时更改币种相关费用
  6739. var opDayCosts = new List<Grp_DayAndCost>();
  6740. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6741. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6742. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6743. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6744. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6745. .Select((dac, sd) => new {
  6746. dac.Id,
  6747. dac.DiId,
  6748. CurrencyCode = sd.Name,
  6749. dac.Cost
  6750. })
  6751. .ToList();
  6752. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6753. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6754. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6755. .Select((dop, sd) => new {
  6756. dop.Id,
  6757. dop.Diid,
  6758. CurrencyCode = sd.Name,
  6759. dop.Cost
  6760. })
  6761. .ToList();
  6762. if (dayCosts.Count > 0)
  6763. {
  6764. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6765. foreach (var dc in new_dayCosts)
  6766. {
  6767. var thisCurrency = dc.Key.ToUpper();
  6768. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6769. if (thisRate == 0.00M) continue;
  6770. foreach (var dcSub in dc)
  6771. {
  6772. opDayCosts.Add(new Grp_DayAndCost() {
  6773. Id = dcSub.Id,
  6774. DiId = dcSub.DiId,
  6775. Cost = dcSub.Cost,
  6776. SubTotal = dcSub.Cost * thisRate,
  6777. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6778. });
  6779. }
  6780. }
  6781. if (opDayCosts.Count > 0)
  6782. {
  6783. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6784. }
  6785. }
  6786. if (dayOtherCosts.Count > 0)
  6787. {
  6788. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6789. foreach (var dc in new_dayOtherCosts)
  6790. {
  6791. var thisCurrency = dc.Key.ToUpper();
  6792. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6793. if (thisRate == 0.00M) continue;
  6794. foreach (var dcSub in dc)
  6795. {
  6796. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6797. {
  6798. Id = dcSub.Id,
  6799. Diid = dcSub.Diid,
  6800. Cost = dcSub.Cost,
  6801. SubTotal = dcSub.Cost * thisRate,
  6802. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6803. });
  6804. }
  6805. }
  6806. if (opDayOtherCosts.Count > 0)
  6807. {
  6808. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6809. }
  6810. }
  6811. #endregion
  6812. //消息通知
  6813. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6814. //汇率信息记录
  6815. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  6816. return Ok(JsonView(true));
  6817. }
  6818. /// <summary>
  6819. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6820. /// </summary>
  6821. /// <returns></returns>
  6822. [HttpPost]
  6823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6824. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6825. {
  6826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6827. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6829. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6830. int id = dto.Id;
  6831. if (id <= 0) //add
  6832. {
  6833. checkboxInfo.CreateUserId = dto.CurrUserId;
  6834. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6835. if (add < 1) return Ok(JsonView(false));
  6836. }
  6837. else //update
  6838. {
  6839. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6840. .UpdateColumns(x => new {
  6841. x.ChoiceOne,
  6842. x.ChoiceTwo,
  6843. x.SumJJC,
  6844. x.SumGWC,
  6845. x.SumTDC,
  6846. x.ChoiceThree,
  6847. x.ChoiceFour,
  6848. x.ChoiceFive,
  6849. x.ChoiceSix,
  6850. x.OtherExpenses_Checked
  6851. })
  6852. .Where(x => x.Id == id)
  6853. .ExecuteCommandAsync();
  6854. if (upd < 1) return Ok(JsonView(false));
  6855. }
  6856. return Ok(JsonView(true));
  6857. }
  6858. /// <summary>
  6859. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  6860. /// </summary>
  6861. /// <returns></returns>
  6862. [HttpPost]
  6863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6864. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  6865. {
  6866. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  6867. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  6868. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6869. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6870. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6871. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  6872. var checkboxInfo = new Grp_EnterExitCost() {
  6873. Id = id,
  6874. DiId = diId,
  6875. CreateUserId = currUserId
  6876. };
  6877. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  6878. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  6879. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  6880. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  6881. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  6882. if (id <= 0) //add
  6883. {
  6884. checkboxInfo.CreateUserId = dto.CurrUserId;
  6885. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6886. if (add < 1) return Ok(JsonView(false));
  6887. }
  6888. else //update
  6889. {
  6890. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  6891. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  6892. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  6893. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  6894. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  6895. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  6896. .Where(x => x.Id == id)
  6897. .ExecuteCommandAsync();
  6898. if (upd < 1) return Ok(JsonView(false));
  6899. }
  6900. return Ok(JsonView(true));
  6901. }
  6902. /// <summary>
  6903. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6904. /// </summary>
  6905. /// <returns></returns>
  6906. [HttpPost]
  6907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6908. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6909. {
  6910. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6911. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6912. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6913. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6914. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6915. int id = dto.Id;
  6916. if (id <= 0) //add
  6917. {
  6918. info.CreateUserId = dto.CurrUserId;
  6919. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  6920. if (add < 1) return Ok(JsonView(false));
  6921. id = add;
  6922. }
  6923. else //update
  6924. {
  6925. var upd = await _sqlSugar.Updateable(info)
  6926. .UpdateColumns(x => new {
  6927. x.ChoiceOne,
  6928. x.InsidePay,
  6929. x.VisaRemark,
  6930. x.Visa,
  6931. x.Service,
  6932. x.Safe,
  6933. x.Ticket,
  6934. x.HeSuan,
  6935. x.YiMiao,
  6936. })
  6937. .Where(x => x.Id == id)
  6938. .ExecuteCommandAsync();
  6939. if (upd < 1) return Ok(JsonView(false));
  6940. }
  6941. //消息通知
  6942. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6943. return Ok(JsonView(new { itemTotal = info.InsidePay }));
  6944. }
  6945. /// <summary>
  6946. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  6947. /// </summary>
  6948. /// <returns></returns>
  6949. [HttpPost]
  6950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6951. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  6952. {
  6953. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6954. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6955. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6956. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6957. info.AirJJC_Checked = dto.ChoiceTwoJJ;
  6958. info.AirGWC_Checked = dto.ChoiceTwoGW;
  6959. info.AirTDC_Checked = dto.ChoiceTwoTD;
  6960. int id = dto.Id;
  6961. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  6962. if (id <= 0) //add
  6963. {
  6964. info.CreateUserId = dto.CurrUserId;
  6965. var addInfo = await _sqlSugar.Insertable(info).ExecuteReturnEntityAsync();
  6966. if (addInfo == null) return Ok(JsonView(false));
  6967. id = addInfo.Id;
  6968. }
  6969. else //update
  6970. {
  6971. var upd = await _sqlSugar.Updateable(info)
  6972. .UpdateColumns(x => new {
  6973. x.AirJJC_Checked,
  6974. x.OutsideJJPay,
  6975. x.AirGWC_Checked,
  6976. x.OutsideGWPay,
  6977. x.AirTDC_Checked,
  6978. x.OutsideTDPay,
  6979. x.AirJJ,
  6980. x.AirGW,
  6981. x.AirTD,
  6982. x.CityTranffic
  6983. })
  6984. .Where(x => x.Id == id)
  6985. .ExecuteCommandAsync();
  6986. if (upd <1) return Ok(JsonView(false));
  6987. }
  6988. jjcItemTotal = info.AirJJ + info.CityTranffic;
  6989. gwcItemTotal = info.AirGW + info.CityTranffic;
  6990. tdcItemTotal = info.AirTD + info.CityTranffic;
  6991. //消息通知
  6992. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6993. return Ok(JsonView(new
  6994. {
  6995. choiceTwoJJ = dto.ChoiceTwoJJ,
  6996. jjcItemTotal = jjcItemTotal,
  6997. choiceTwoGW = dto.ChoiceTwoGW,
  6998. gwcItemTotal = gwcItemTotal,
  6999. choiceTwoTD = dto.ChoiceTwoTD,
  7000. tdcItemTotal = tdcItemTotal
  7001. }));
  7002. }
  7003. /// <summary>
  7004. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  7005. /// </summary>
  7006. /// <returns></returns>
  7007. [HttpPost]
  7008. [ApiExplorerSettings(IgnoreApi = true)]
  7009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7010. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  7011. {
  7012. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7013. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7014. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7015. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  7016. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7017. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7018. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  7019. var infos = infos1.Select(x => new Grp_DayAndCost
  7020. {
  7021. Id = x.Id,
  7022. DiId = dto.DiId,
  7023. Type = dto.FeeType,
  7024. Days = x.Days,
  7025. NationalTravelFeeId = x.NationalTravelFeeId,
  7026. Cost = x.Cost,
  7027. Currency = x.Currency,
  7028. SubTotal = x.SubTotal,
  7029. CreateUserId = dto.CurrUserId
  7030. })
  7031. .ToList();
  7032. var adds = infos.Where(x => x.Id <= 0).ToList();
  7033. var upds = infos.Where(x => x.Id > 0).ToList();
  7034. if (adds.Count > 0)
  7035. {
  7036. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7037. if (add < 1) return Ok(JsonView(false));
  7038. }
  7039. if (upds.Count > 0)
  7040. {
  7041. var upd = await _sqlSugar.Updateable(adds)
  7042. .UpdateColumns(x => new
  7043. {
  7044. x.Days,
  7045. x.NationalTravelFeeId,
  7046. x.Cost,
  7047. x.Currency,
  7048. x.SubTotal
  7049. })
  7050. .WhereColumns(x => new { x.Id })
  7051. .ExecuteCommandAsync();
  7052. if (upd < 1) return Ok(JsonView(false));
  7053. }
  7054. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7055. //消息通知
  7056. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7057. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7058. return Ok(JsonView(new { itemTotal = itemTotal }));
  7059. }
  7060. /// <summary>
  7061. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7062. /// </summary>
  7063. /// <returns></returns>
  7064. [HttpPost]
  7065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7066. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7067. {
  7068. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  7069. int subId = dto.SubId, feeType = dto.FeeType;
  7070. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7071. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7072. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7073. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7074. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7075. subInfo.Id = subId;
  7076. subInfo.DiId = dto.DiId;
  7077. if (feeType == 3) subInfo.Type = 1;
  7078. else if (feeType == 4) subInfo.Type = 1;
  7079. else if (feeType == 5) subInfo.Type = 1;
  7080. else if (feeType == 6) subInfo.Type = 1;
  7081. subInfo.CreateUserId = dto.CurrUserId;
  7082. //子表op
  7083. if (subId < 1)
  7084. {
  7085. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7086. if (subAdd < 1) return Ok(JsonView(false));
  7087. }
  7088. else
  7089. {
  7090. var subUpd = await _sqlSugar.Updateable(subInfo)
  7091. .UpdateColumns(x => new
  7092. {
  7093. x.Days,
  7094. x.NationalTravelFeeId,
  7095. x.Cost,
  7096. x.Currency,
  7097. x.SubTotal
  7098. })
  7099. .WhereColumns(x => new { x.Id })
  7100. .ExecuteCommandAsync();
  7101. if (subUpd < 1) return Ok(JsonView(false));
  7102. }
  7103. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  7104. //消息通知
  7105. var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First().Id;
  7106. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7107. return Ok(JsonView(new { itemTotal = itemTotal }));
  7108. }
  7109. /// <summary>
  7110. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7111. /// </summary>
  7112. /// <returns></returns>
  7113. [HttpPost]
  7114. [ApiExplorerSettings(IgnoreApi = true)]
  7115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7116. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7117. {
  7118. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7119. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7120. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7121. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7122. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7123. {
  7124. Id = x.Id,
  7125. Diid = dto.DiId,
  7126. SetDataId = x.SetDataId,
  7127. Index = x.Index,
  7128. Cost = x.Cost,
  7129. Currency = x.Currency,
  7130. SubTotal = x.SubTotal,
  7131. CreateUserId = dto.CurrUserId,
  7132. Remark = x.Remark
  7133. }).ToList();
  7134. var adds = infos.Where(x => x.Id <= 0).ToList();
  7135. var upds = infos.Where(x => x.Id > 0).ToList();
  7136. if (adds.Count > 0)
  7137. {
  7138. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7139. if (add < 1) return Ok(JsonView(false));
  7140. }
  7141. if (upds.Count > 0)
  7142. {
  7143. var upd = await _sqlSugar.Updateable(adds)
  7144. .UpdateColumns(x => new
  7145. {
  7146. x.Index,
  7147. x.SetDataId,
  7148. x.Cost,
  7149. x.Currency,
  7150. x.SubTotal,
  7151. x.Remark
  7152. })
  7153. .WhereColumns(x => new { x.Id })
  7154. .ExecuteCommandAsync();
  7155. if (upd < 1) return Ok(JsonView(false));
  7156. }
  7157. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7158. //消息通知
  7159. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7160. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7161. return Ok(JsonView(new { itemTotal = itemTotal }));
  7162. }
  7163. /// <summary>
  7164. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  7165. /// </summary>
  7166. /// <returns></returns>
  7167. [HttpPost]
  7168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7169. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7170. {
  7171. int subId = dto.SubId;
  7172. int diId = dto.Diid;
  7173. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7174. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7175. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7176. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7177. subInfo.Id = subId;
  7178. subInfo.Diid = dto.Diid;
  7179. subInfo.CreateUserId = dto.CurrUserId;
  7180. #region 子表op
  7181. if (subId < 1)//add
  7182. {
  7183. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7184. if (subAdd < 1) return Ok(JsonView(false));
  7185. }
  7186. else //upd
  7187. {
  7188. var subUpd = await _sqlSugar.Updateable(subInfo)
  7189. .UpdateColumns(x => new
  7190. {
  7191. x.Index,
  7192. x.SetDataId,
  7193. x.Cost,
  7194. x.Currency,
  7195. x.SubTotal,
  7196. x.Remark
  7197. })
  7198. .WhereColumns(x => new { x.Id })
  7199. .ExecuteCommandAsync();
  7200. if (subUpd < 1) return Ok(JsonView(false));
  7201. }
  7202. #endregion
  7203. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  7204. //消息通知
  7205. var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).First().Id;
  7206. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  7207. return Ok(JsonView(new { itemTotal = itemTotal }));
  7208. }
  7209. /// <summary>
  7210. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  7211. /// </summary>
  7212. /// <returns></returns>
  7213. [HttpPost]
  7214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7215. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  7216. {
  7217. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7218. if (data.Code != 0)
  7219. {
  7220. return Ok(JsonView(false, data.Msg));
  7221. }
  7222. return Ok(JsonView(true, "操作成功!", data.Data));
  7223. }
  7224. /// <summary>
  7225. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  7226. /// </summary>
  7227. /// <param name="dto"></param>
  7228. /// <returns></returns>
  7229. [HttpPost]
  7230. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  7231. {
  7232. var data = new Grp_DayOtherPrice()
  7233. {
  7234. Id = dto.Id,
  7235. IsDel = 1,
  7236. DeleteUserId = dto.DeleteUserId,
  7237. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7238. };
  7239. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7240. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  7241. return Ok(JsonView(false,"删除失败!"));
  7242. }
  7243. #endregion
  7244. #endregion
  7245. #region 签证费用录入
  7246. /// <summary>
  7247. /// 根据diid查询签证费用列表
  7248. /// </summary>
  7249. /// <param name="dto"></param>
  7250. /// <returns></returns>
  7251. [HttpPost]
  7252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7253. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7254. {
  7255. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7256. if (groupData.Code != 0)
  7257. {
  7258. return Ok(JsonView(false, groupData.Msg));
  7259. }
  7260. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7261. }
  7262. /// <summary>
  7263. /// 根据签证费用Id查询单条数据及c表数据
  7264. /// </summary>
  7265. /// <param name="dto"></param>
  7266. /// <returns></returns>
  7267. [HttpPost]
  7268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7269. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7270. {
  7271. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7272. if (groupData.Code != 0)
  7273. {
  7274. return Ok(JsonView(false, groupData.Msg));
  7275. }
  7276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7277. }
  7278. /// <summary>
  7279. /// 签证费用删除
  7280. /// </summary>
  7281. /// <param name="dto"></param>
  7282. /// <returns></returns>
  7283. [HttpPost]
  7284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7285. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7286. {
  7287. _sqlSugar.BeginTran();
  7288. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7289. if (!res)
  7290. {
  7291. _sqlSugar.RollbackTran();
  7292. return Ok(JsonView(false, "删除失败"));
  7293. }
  7294. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7295. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7296. .SetColumns(a => new Grp_CreditCardPayment()
  7297. {
  7298. IsDel = 1,
  7299. DeleteUserId = dto.DeleteUserId,
  7300. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7301. })
  7302. .ExecuteCommand();
  7303. if (resSub < 1)
  7304. {
  7305. _sqlSugar.RollbackTran();
  7306. return Ok(JsonView(false, "删除失败"));
  7307. }
  7308. _sqlSugar.CommitTran();
  7309. return Ok(JsonView(true, "删除成功!"));
  7310. }
  7311. /// <summary>
  7312. /// 签证费用录入下拉框初始化
  7313. /// </summary>
  7314. /// <returns></returns>
  7315. [HttpPost]
  7316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7317. public async Task<IActionResult> VisaPriceAddSelect()
  7318. {
  7319. //支付方式
  7320. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7321. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7322. //币种
  7323. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7324. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7325. //乘客类型
  7326. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7327. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7328. //卡类型
  7329. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7330. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7331. //代办费类型
  7332. var agencyFeeTypeData = new List<dynamic>() {
  7333. new { id = 0 , Text = "未选择" },
  7334. new { id = 1 , Text = "小公务" },
  7335. new { id = 2 , Text = "大公务" },
  7336. };
  7337. //签证费用标准国家Data
  7338. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7339. var data = new
  7340. {
  7341. Payment = _Payment,
  7342. CurrencyList = _CurrencyList,
  7343. PassengerType = _PassengerType,
  7344. BankCard = _BankCard,
  7345. AgencyFeeType = agencyFeeTypeData,
  7346. CountryFeeData = visaCountryFeeData
  7347. };
  7348. return Ok(JsonView(true, "查询成功!", data));
  7349. }
  7350. /// <summary>
  7351. /// 签证费用录入操作(Status:1.新增,2.修改)
  7352. /// </summary>
  7353. /// <param name="dto"></param>
  7354. /// <returns></returns>
  7355. [HttpPost]
  7356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7357. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7358. {
  7359. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7360. if (groupData.Code != 0)
  7361. {
  7362. return Ok(JsonView(false, groupData.Msg));
  7363. }
  7364. #region 应用推送
  7365. try
  7366. {
  7367. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7368. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7369. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7370. //2024-10-21 新增LZ UID
  7371. var userIds = new List<int>() { 21 };
  7372. string title = $"系统通知";
  7373. string content = "";
  7374. var diId = dto.DiId;
  7375. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7376. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7377. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7378. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7379. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7380. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7381. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7382. }
  7383. catch (Exception ex)
  7384. {
  7385. }
  7386. #endregion
  7387. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7388. }
  7389. #endregion
  7390. #region 签证提成录入
  7391. /// <summary>
  7392. /// 签证提成录入
  7393. /// 基础数据
  7394. /// </summary>
  7395. /// <param name="_dto"></param>
  7396. /// <returns></returns>
  7397. [HttpGet]
  7398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7399. public async Task<IActionResult> VisaCommissionInit()
  7400. {
  7401. return Ok(await _visaCommissionRep.Init());
  7402. }
  7403. /// <summary>
  7404. /// 签证提成录入
  7405. /// Item
  7406. /// </summary>
  7407. /// <param name="_dto"></param>
  7408. /// <returns></returns>
  7409. [HttpPost]
  7410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7411. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7412. {
  7413. var validator = new VisaCommissionItemDtoValidator();
  7414. var validatorRes = await validator.ValidateAsync(_dto);
  7415. if (!validatorRes.IsValid)
  7416. {
  7417. StringBuilder sb = new StringBuilder();
  7418. foreach (var item in validatorRes.Errors)
  7419. {
  7420. sb.AppendLine(item.ErrorMessage);
  7421. }
  7422. return Ok(JsonView(false, sb.ToString()));
  7423. }
  7424. return Ok(await _visaCommissionRep.Item(_dto));
  7425. }
  7426. /// <summary>
  7427. /// 签证提成录入
  7428. /// Save
  7429. /// </summary>
  7430. /// <param name="_dto"></param>
  7431. /// <returns></returns>
  7432. [HttpPost]
  7433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7434. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7435. {
  7436. //参数验证
  7437. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7438. foreach (var item in _dto.Items)
  7439. {
  7440. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7441. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7442. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7443. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7444. }
  7445. return Ok(await _visaCommissionRep.Save(_dto));
  7446. }
  7447. /// <summary>
  7448. /// 签证提成录入
  7449. /// Create
  7450. /// </summary>
  7451. /// <param name="_dto"></param>
  7452. /// <returns></returns>
  7453. [HttpPost]
  7454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7455. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7456. {
  7457. var validator = new VisaCommissionCreateDtoValidator();
  7458. var validatorRes = await validator.ValidateAsync(_dto);
  7459. if (!validatorRes.IsValid)
  7460. {
  7461. StringBuilder sb = new StringBuilder();
  7462. foreach (var item in validatorRes.Errors)
  7463. {
  7464. sb.AppendLine(item.ErrorMessage);
  7465. }
  7466. return Ok(JsonView(false, sb.ToString()));
  7467. }
  7468. return Ok(await _visaCommissionRep.Create(_dto));
  7469. }
  7470. /// <summary>
  7471. /// 签证提成录入
  7472. /// Put(编辑)
  7473. /// </summary>
  7474. /// <param name="id"></param>
  7475. /// <param name="_dto"></param>
  7476. /// <returns></returns>
  7477. [HttpPut]
  7478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7479. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7480. {
  7481. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7482. var validator = new VisaCommissionCreateDtoValidator();
  7483. var validatorRes = await validator.ValidateAsync(_dto);
  7484. if (!validatorRes.IsValid)
  7485. {
  7486. StringBuilder sb = new StringBuilder();
  7487. foreach (var item in validatorRes.Errors)
  7488. {
  7489. sb.AppendLine(item.ErrorMessage);
  7490. }
  7491. return Ok(JsonView(false, sb.ToString()));
  7492. }
  7493. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7494. }
  7495. /// <summary>
  7496. /// 签证提成录入
  7497. /// Del
  7498. /// </summary>
  7499. /// <param name="id"></param>
  7500. /// <param name="currUserId"></param>
  7501. /// <returns></returns>
  7502. [HttpPost]
  7503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7504. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7505. {
  7506. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7507. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7508. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7509. }
  7510. #endregion
  7511. #region op费用录入
  7512. /// <summary>
  7513. /// 根据diid查询op费用列表
  7514. /// </summary>
  7515. /// <param name="dto"></param>
  7516. /// <returns></returns>
  7517. [HttpPost]
  7518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7519. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7520. {
  7521. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7522. if (groupData.Code != 0)
  7523. {
  7524. return Ok(JsonView(false, groupData.Msg));
  7525. }
  7526. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7527. }
  7528. /// <summary>
  7529. /// 根据op费用Id查询单条数据及c表数据
  7530. /// </summary>
  7531. /// <param name="dto"></param>
  7532. /// <returns></returns>
  7533. [HttpPost]
  7534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7535. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7536. {
  7537. try
  7538. {
  7539. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7540. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7541. var data = new
  7542. {
  7543. CarTouristGuideGround = _groupData,
  7544. CreditCardPayment = _creditCardPayment
  7545. };
  7546. return Ok(JsonView(true, "查询成功!", data));
  7547. }
  7548. catch (Exception ex)
  7549. {
  7550. return Ok(JsonView(false, "程序错误!"));
  7551. }
  7552. }
  7553. /// <summary>
  7554. /// op费用删除
  7555. /// </summary>
  7556. /// <param name="dto"></param>
  7557. /// <returns></returns>
  7558. [HttpPost]
  7559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7560. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7561. {
  7562. try
  7563. {
  7564. _sqlSugar.BeginTran();
  7565. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7566. if (!res)
  7567. {
  7568. return Ok(JsonView(false, "删除失败"));
  7569. }
  7570. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7571. {
  7572. IsDel = 1,
  7573. DeleteUserId = dto.DeleteUserId,
  7574. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7575. }).ExecuteCommandAsync();
  7576. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7577. {
  7578. IsDel = 1,
  7579. DeleteUserId = dto.DeleteUserId,
  7580. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7581. }).ExecuteCommandAsync();
  7582. #region 删除超支相关数据
  7583. //删除导入的超支数据
  7584. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7585. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7586. {
  7587. IsDel = 1,
  7588. DeleteUserId = dto.DeleteUserId,
  7589. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7590. }).ExecuteCommand();
  7591. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7592. {
  7593. IsDel = 1,
  7594. DeleteUserId = dto.DeleteUserId,
  7595. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7596. }).ExecuteCommand();
  7597. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7598. {
  7599. IsDel = 1,
  7600. DeleteUserId = dto.DeleteUserId,
  7601. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7602. }).ExecuteCommand();
  7603. #endregion
  7604. _sqlSugar.CommitTran();
  7605. return Ok(JsonView(true, "删除成功!"));
  7606. }
  7607. catch (Exception ex)
  7608. {
  7609. _sqlSugar.RollbackTran();
  7610. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7611. }
  7612. }
  7613. /// <summary>
  7614. /// op费用录入操作(Status:1.新增,2.修改)
  7615. /// </summary>
  7616. /// <param name="dto"></param>
  7617. /// <returns></returns>
  7618. [HttpPost]
  7619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7620. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7621. {
  7622. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7623. if (groupData.Code != 0)
  7624. {
  7625. return Ok(JsonView(false, groupData.Msg));
  7626. }
  7627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7628. }
  7629. /// <summary>
  7630. /// 填写费用详细页面初始化绑定
  7631. /// </summary>
  7632. /// <param name="dto"></param>
  7633. /// <returns></returns>
  7634. [HttpPost]
  7635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7636. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7637. {
  7638. try
  7639. {
  7640. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7641. if (groupData.Code != 0)
  7642. {
  7643. return Ok(JsonView(false, groupData.Msg));
  7644. }
  7645. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7646. }
  7647. catch (Exception ex)
  7648. {
  7649. return Ok(JsonView(false, ex.Message));
  7650. }
  7651. }
  7652. /// <summary>
  7653. /// 根据op费用Id查询详细数据
  7654. /// </summary>
  7655. /// <param name="dto"></param>
  7656. /// <returns></returns>
  7657. [HttpPost]
  7658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7659. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7660. {
  7661. try
  7662. {
  7663. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7664. if (groupData.Code != 0)
  7665. {
  7666. return Ok(JsonView(false, groupData.Msg));
  7667. }
  7668. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7669. }
  7670. catch (Exception ex)
  7671. {
  7672. return Ok(JsonView(false, ex.Message));
  7673. }
  7674. }
  7675. /// <summary>
  7676. /// OP费用录入填写详情
  7677. /// </summary>
  7678. /// <param name="dto"></param>
  7679. /// <returns></returns>
  7680. [HttpPost]
  7681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7682. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7683. {
  7684. try
  7685. {
  7686. #region 参数校验
  7687. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7688. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7689. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7690. #endregion
  7691. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7692. if (groupData.Code != 0)
  7693. {
  7694. return Ok(JsonView(false, groupData.Msg));
  7695. }
  7696. //自动审核
  7697. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7698. #region 应用推送
  7699. try
  7700. {
  7701. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7702. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7703. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7704. //2024-10-21 新增LZ UID
  7705. var userIds = new List<int>() { 21 };
  7706. string title = $"系统通知";
  7707. var diId = dto.DiId;
  7708. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7709. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7710. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7711. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7712. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7713. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7714. }
  7715. catch (Exception ex)
  7716. {
  7717. }
  7718. #endregion
  7719. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7720. }
  7721. catch (Exception ex)
  7722. {
  7723. return Ok(JsonView(false, ex.Message));
  7724. }
  7725. }
  7726. /// <summary>
  7727. /// 获取三公详细所有城市
  7728. /// </summary>
  7729. /// <returns></returns>
  7730. [HttpGet]
  7731. public IActionResult OpCarCityResult()
  7732. {
  7733. var jw = JsonView(false);
  7734. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7735. {
  7736. x.Id,
  7737. x.Country,
  7738. x.City,
  7739. }).ToList();
  7740. if (data.Count > 0)
  7741. {
  7742. jw = JsonView(true, "获取成功!", data);
  7743. }
  7744. else
  7745. {
  7746. jw.Msg = "城市数据为空!";
  7747. jw.Data = new string[0];
  7748. }
  7749. return Ok(jw);
  7750. }
  7751. /// <summary>
  7752. /// 导出地接费用明细
  7753. /// </summary>
  7754. /// <param name="dto"></param>
  7755. /// <returns></returns>
  7756. [HttpPost]
  7757. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7758. {
  7759. var jw = JsonView(false);
  7760. if (dto.Diid < 1)
  7761. {
  7762. jw.Msg = "请输入正确的diid!";
  7763. return Ok(jw);
  7764. }
  7765. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7766. if (group == null)
  7767. {
  7768. jw.Msg = "未找到团组信息!";
  7769. return Ok(jw);
  7770. }
  7771. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7772. if (localGuideArr.Count == 0)
  7773. {
  7774. jw.Msg = "该团组暂无地接信息!";
  7775. return Ok(jw);
  7776. }
  7777. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7778. var overspendSoure = new Dictionary<int, int>
  7779. {
  7780. { 91, 982 }, //车
  7781. { 92 , 1059} ,//导游
  7782. { 994 , 1073}, //翻译
  7783. { 988 , 1074 }, //早餐
  7784. { 93 , 1075 }, //午餐
  7785. { 989 , 1076 }, //晚餐
  7786. };
  7787. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7788. foreach (var groupArr in localGroup)
  7789. {
  7790. var keyValue = groupArr.Key;
  7791. if (int.TryParse(keyValue, out int cityid))
  7792. {
  7793. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7794. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7795. }
  7796. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7797. foreach (var item in groupArr)
  7798. {
  7799. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7800. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7801. new Grp_CarTouristGuideGroundReservationsContentExtend
  7802. {
  7803. Count = a.Count,
  7804. CreateTime = a.CreateTime,
  7805. CreateUserId = a.CreateUserId,
  7806. CTGGRId = a.CTGGRId,
  7807. Currency = a.Currency,
  7808. DatePrice = a.DatePrice,
  7809. DeleteTime = a.DeleteTime,
  7810. DeleteUserId = a.DeleteUserId,
  7811. DiId = a.DiId,
  7812. Id = a.Id,
  7813. IsDel = a.IsDel,
  7814. Price = a.Price,
  7815. PriceContent = a.PriceContent,
  7816. Remark = a.Remark,
  7817. SId = a.SId,
  7818. SidName = b.Name,
  7819. Units = a.Units,
  7820. }
  7821. ).ToList();
  7822. if (content.Count > 0)
  7823. {
  7824. contentArr.Add(content);
  7825. }
  7826. }
  7827. //open excel
  7828. //set excel
  7829. //save excel
  7830. try
  7831. {
  7832. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7833. IWorkbook workbook;
  7834. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7835. {
  7836. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7837. }
  7838. else
  7839. {
  7840. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7841. }
  7842. ISheet sheet = workbook.GetSheetAt(0);
  7843. var rowStartIndex = 2;
  7844. var clounmCount = 10;
  7845. var initStyleRow = sheet.GetRow(2);
  7846. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7847. //var overspendArrDetail =
  7848. var existsId = new List<CarCompare>();
  7849. var lastElem = arr.Last();
  7850. var thisSid = -1;
  7851. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7852. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7853. {
  7854. Name = "未知币种!",
  7855. Remark = "未知币种!",
  7856. };
  7857. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7858. Action cloneRowFn = () =>
  7859. {
  7860. rowStartIndex++;
  7861. var cloneRow = sheet.CreateRow(rowStartIndex);
  7862. // 复制样式
  7863. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7864. {
  7865. ICell sourceCell = initStyleRow.GetCell(i);
  7866. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7867. // 确保单元格存在样式
  7868. if (sourceCell.CellStyle != null)
  7869. {
  7870. targetCell.CellStyle = sourceCell.CellStyle;
  7871. }
  7872. }
  7873. };
  7874. var mergeRow = () =>
  7875. {
  7876. for (int i = 2; i < sheet.LastRowNum; i++)
  7877. {
  7878. var row = sheet.GetRow(i);
  7879. var cellFirst = row.GetCell(0);
  7880. var thisIndex = i + 1;
  7881. while (thisIndex < sheet.LastRowNum)
  7882. {
  7883. var nextRow = sheet.GetRow(thisIndex);
  7884. var nextCellFirst = nextRow.GetCell(0);
  7885. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7886. {
  7887. thisIndex++;
  7888. }
  7889. else
  7890. {
  7891. break;
  7892. }
  7893. }
  7894. thisIndex--;
  7895. if (thisIndex != i)
  7896. {
  7897. //合并row
  7898. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7899. i, // 起始行索引(0-based)
  7900. thisIndex, // 结束行索引(0-based)
  7901. 0, // 起始列索引(0-based)
  7902. 0 // 结束列索引(0-based)
  7903. );
  7904. sheet.AddMergedRegion(cellRangeAddress);
  7905. i = thisIndex;
  7906. }
  7907. }
  7908. };
  7909. var chaoshiNumber = 0;
  7910. var totalNumber = 0.00M;
  7911. string lastStr = "";
  7912. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7913. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7914. {
  7915. b.IsAuditGM,
  7916. x.Id,
  7917. x.Area,
  7918. b.PayPercentage,
  7919. b.PayMoney,
  7920. }).ToList();
  7921. string yesPayment = "", noPayment = "";
  7922. foreach (var item in queryCarArrByCityAndDiid)
  7923. {
  7924. if (item.IsAuditGM == 1)
  7925. {
  7926. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7927. }
  7928. else
  7929. {
  7930. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7931. }
  7932. }
  7933. lastStr = yesPayment + noPayment;
  7934. foreach (var item in arr)
  7935. {
  7936. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  7937. {
  7938. if (thisSid != item.SId)
  7939. {
  7940. if (thisSid == -1)
  7941. {
  7942. thisSid = item.SId;
  7943. }
  7944. else
  7945. {
  7946. //合并小计行
  7947. //创建合并区域的实例
  7948. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7949. rowStartIndex, // 起始行索引(0-based)
  7950. rowStartIndex, // 结束行索引(0-based)
  7951. 0, // 起始列索引(0-based)
  7952. 3 // 结束列索引(0-based)
  7953. );
  7954. sheet.AddMergedRegion(cellRangeAddress);
  7955. var CellStyle = workbook.CreateCellStyle();
  7956. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7957. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7958. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7959. for (int i = 0; i <= clounmCount; i++)
  7960. {
  7961. if (i > 6)
  7962. {
  7963. var CellStyle1 = workbook.CreateCellStyle();
  7964. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7965. IFont Font = workbook.CreateFont(); // 创建字体
  7966. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7967. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7968. CellStyle1.SetFont(Font);
  7969. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7970. }
  7971. else
  7972. {
  7973. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7974. }
  7975. }
  7976. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7977. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7978. //超时合计
  7979. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7980. //超时数
  7981. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7982. //超时合计费用
  7983. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7984. thisSid = item.SId;
  7985. cloneRowFn();
  7986. chaoshiNumber = 0;
  7987. totalNumber = 0;
  7988. }
  7989. }
  7990. IRow row = sheet.GetRow(rowStartIndex);
  7991. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7992. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  7993. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  7994. if (isOpenOverspendSoure)
  7995. {
  7996. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7997. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  7998. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  7999. }
  8000. for (int i = 0; i <= clounmCount; i++)
  8001. {
  8002. var cell = row.GetCell(i);
  8003. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  8004. if (cell == null)
  8005. {
  8006. cell = row.CreateCell(i);
  8007. }
  8008. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  8009. fontRed.CloneStyleFrom(cell.CellStyle);
  8010. IFont Font = workbook.CreateFont(); // 创建字体
  8011. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8012. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8013. fontRed.SetFont(Font);
  8014. byte[] rgb = new byte[3] { 255, 242, 204 };
  8015. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8016. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8017. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8018. if (workbook is XSSFWorkbook)
  8019. {
  8020. BackgroundColor255_242_204.FillForegroundColor = 0;
  8021. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8022. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8023. }
  8024. else
  8025. {
  8026. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8027. }
  8028. if (i == 1 || i > 6)
  8029. {
  8030. if (i > 6)
  8031. {
  8032. fontRed.FillForegroundColor = 0;
  8033. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8034. fontRed.FillPattern = FillPattern.SolidForeground;
  8035. }
  8036. cell.CellStyle = fontRed;
  8037. }
  8038. if (i > 2 && i < 7)
  8039. {
  8040. cell.CellStyle = BackgroundColor255_242_204;
  8041. }
  8042. cell.SetCellValue(setCellValue); //写入单元格
  8043. }
  8044. if (overspendSoure.ContainsKey(thisSid))
  8045. {
  8046. var overspendId = overspendSoure[thisSid];
  8047. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8048. }
  8049. cloneRowFn();
  8050. existsId.Add(new CarCompare
  8051. {
  8052. DataPrice = item.DatePrice.ObjToDate(),
  8053. Sid = item.SId
  8054. });
  8055. }
  8056. if (item.Equals(lastElem))
  8057. {
  8058. //合并小计行
  8059. //创建合并区域的实例
  8060. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8061. rowStartIndex, // 起始行索引(0-based)
  8062. rowStartIndex, // 结束行索引(0-based)
  8063. 0, // 起始列索引(0-based)
  8064. 3 // 结束列索引(0-based)
  8065. );
  8066. sheet.AddMergedRegion(cellRangeAddress);
  8067. var CellStyle = workbook.CreateCellStyle();
  8068. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8069. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8070. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8071. for (int i = 0; i <= clounmCount; i++)
  8072. {
  8073. if (i > 6)
  8074. {
  8075. var CellStyle1 = workbook.CreateCellStyle();
  8076. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8077. IFont Font = workbook.CreateFont(); // 创建字体
  8078. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8079. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8080. CellStyle1.SetFont(Font);
  8081. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8082. }
  8083. else
  8084. {
  8085. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8086. }
  8087. }
  8088. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8089. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8090. //超时合计
  8091. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8092. //超时数
  8093. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8094. //超时合计费用
  8095. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8096. cloneRowFn();
  8097. // 创建合并区域的实例
  8098. cellRangeAddress = new CellRangeAddress(
  8099. rowStartIndex, // 起始行索引(0-based)
  8100. rowStartIndex, // 结束行索引(0-based)
  8101. 0, // 起始列索引(0-based)
  8102. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8103. );
  8104. // 添加合并区域
  8105. sheet.AddMergedRegion(cellRangeAddress);
  8106. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8107. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8108. }
  8109. }
  8110. mergeRow();
  8111. // 保存修改后的Excel文件到新文件
  8112. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8113. // new FileStream(newFilePath, FileMode.CreateNew)
  8114. using (var stream = new MemoryStream())
  8115. {
  8116. workbook.Write(stream, true);
  8117. stream.Flush();
  8118. stream.Seek(0, SeekOrigin.Begin);
  8119. MemoryStream memoryStream = new MemoryStream();
  8120. stream.CopyTo(memoryStream);
  8121. memoryStream.Seek(0, SeekOrigin.Begin);
  8122. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8123. }
  8124. workbook.Close();
  8125. workbook.Dispose();
  8126. }
  8127. catch (Exception ex)
  8128. {
  8129. jw.Msg = "出现异常!" + ex.Message;
  8130. return Ok(jw);
  8131. }
  8132. }
  8133. if (Zips.Count > 0)
  8134. {
  8135. IOOperatorHelper io = new IOOperatorHelper();
  8136. var byts = io.ConvertZipStream(Zips);
  8137. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8138. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8139. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8140. }
  8141. else
  8142. {
  8143. jw.Msg = "暂无生成文件!";
  8144. }
  8145. return Ok(jw);
  8146. }
  8147. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8148. {
  8149. string outStr = string.Empty;
  8150. switch (i)
  8151. {
  8152. case 0:
  8153. outStr = arr[0].SidName;
  8154. break;
  8155. case 1:
  8156. outStr = arr[0].DataPriceStr;
  8157. break;
  8158. case 2:
  8159. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8160. break;
  8161. case 4:
  8162. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8163. break;
  8164. case 7:
  8165. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8166. {
  8167. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8168. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8169. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8170. }
  8171. break;
  8172. case 8:
  8173. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8174. {
  8175. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8176. }
  8177. break;
  8178. case 9:
  8179. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8180. {
  8181. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8182. }
  8183. break;
  8184. case 10:
  8185. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8186. {
  8187. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8188. }
  8189. break;
  8190. }
  8191. return outStr;
  8192. }
  8193. #region OP行程单
  8194. /// <summary>
  8195. /// OP行程单初始化
  8196. /// </summary>
  8197. /// <param name="dto"></param>
  8198. /// <returns></returns>
  8199. [HttpPost]
  8200. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8201. {
  8202. var jw = JsonView(false);
  8203. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8204. var group = groupList.First();
  8205. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8206. if (group == null)
  8207. {
  8208. jw.Msg = "暂无团组!";
  8209. return Ok(jw);
  8210. }
  8211. group = groupList.Find(x => x.Id == diid);
  8212. if (group == null)
  8213. {
  8214. jw.Msg = "请输入正确的团组ID!";
  8215. return Ok(jw);
  8216. }
  8217. string city = string.Empty;
  8218. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8219. if (blackCode.Count > 0)
  8220. {
  8221. var black = blackCode.First();
  8222. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8223. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8224. if (blackSp.Length > 0)
  8225. {
  8226. try
  8227. {
  8228. var cityArrCode = new List<string>(20);
  8229. foreach (var item in blackSp)
  8230. {
  8231. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8232. var IndexSelect = itemSp[2];
  8233. var cityArrCodeLength = cityArrCode.Count - 1;
  8234. var startCity = IndexSelect.Substring(0, 3);
  8235. if (cityArrCodeLength > 0)
  8236. {
  8237. var arrEndCity = cityArrCode[cityArrCodeLength];
  8238. if (arrEndCity != startCity)
  8239. {
  8240. cityArrCode.Add(startCity.ToUpper());
  8241. }
  8242. }
  8243. else
  8244. {
  8245. cityArrCode.Add(startCity.ToUpper());
  8246. }
  8247. var endCity = IndexSelect.Substring(3, 3);
  8248. cityArrCode.Add(endCity.ToUpper());
  8249. }
  8250. var cityThree = string.Empty;
  8251. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8252. cityThree = cityThree.TrimEnd(',');
  8253. if (string.IsNullOrWhiteSpace(cityThree))
  8254. {
  8255. throw new
  8256. Exception("error");
  8257. }
  8258. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8259. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8260. foreach (var item in cityArrCode)
  8261. {
  8262. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8263. if (find != null)
  8264. {
  8265. city += find.City + "/";
  8266. }
  8267. else
  8268. {
  8269. city += item + "三字码未收入/";
  8270. }
  8271. }
  8272. city = city.TrimEnd('/');
  8273. }
  8274. catch (Exception e)
  8275. {
  8276. city = "黑屏代码格式不正确!";
  8277. }
  8278. }
  8279. }
  8280. else
  8281. {
  8282. city = "未录入黑屏代码";
  8283. }
  8284. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8285. {
  8286. Date = x.Date,
  8287. Days = x.Days,
  8288. Diffgroup = x.Diffgroup,
  8289. Diid = x.Diid,
  8290. Traffic_First = x.Traffic_First,
  8291. Traffic_Second = x.Traffic_Second,
  8292. Trip = x.Trip,
  8293. WeekDay = x.WeekDay,
  8294. Id = x.Id
  8295. }).ToList();
  8296. jw.Data = new
  8297. {
  8298. groupList = groupList.Select(x => new
  8299. {
  8300. x.Id,
  8301. x.TeamName,
  8302. x.TourCode
  8303. }).ToList(),
  8304. groupInfo = new
  8305. {
  8306. group.VisitDays,
  8307. group.TourCode,
  8308. group.VisitPNumber,
  8309. group.TeamName,
  8310. city
  8311. },
  8312. OpTravelList
  8313. };
  8314. jw.Code = 200;
  8315. jw.Msg = "操作成功!";
  8316. return Ok(jw);
  8317. }
  8318. /// <summary>
  8319. /// 删除团组行程单
  8320. /// </summary>
  8321. /// <returns></returns>
  8322. [HttpPost]
  8323. public IActionResult DelTravel(DelOpTravelDto dto)
  8324. {
  8325. var jw = JsonView(false);
  8326. if (dto.UserId <= 0 || dto.Diid <= 0)
  8327. {
  8328. jw.Msg = "请输入正确的参数!";
  8329. return Ok(jw);
  8330. }
  8331. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8332. .SetColumns(x => new Grp_TravelList
  8333. {
  8334. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8335. DeleteUserId = dto.UserId,
  8336. IsDel = 1,
  8337. }).ExecuteCommand();
  8338. jw = JsonView(true);
  8339. return Ok(jw);
  8340. }
  8341. /// <summary>
  8342. /// 行程单保存
  8343. /// </summary>
  8344. /// <returns></returns>
  8345. [HttpPost]
  8346. public IActionResult TravelSave(TravelSaveDto dto)
  8347. {
  8348. var jw = JsonView(false);
  8349. if (dto.Arr.Count > 0)
  8350. {
  8351. try
  8352. {
  8353. _sqlSugar.BeginTran();
  8354. foreach (var item in dto.Arr)
  8355. {
  8356. if (item.Id == 0)
  8357. {
  8358. throw new Exception("请传入正确的Id");
  8359. }
  8360. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8361. .SetColumns(x => new Grp_TravelList
  8362. {
  8363. Trip = item.Trip
  8364. }).ExecuteCommand();
  8365. }
  8366. _sqlSugar.CommitTran();
  8367. jw = JsonView(true);
  8368. }
  8369. catch (Exception ex)
  8370. {
  8371. _sqlSugar.RollbackTran();
  8372. jw.Msg = "程序异常!" + ex.Message;
  8373. }
  8374. }
  8375. else
  8376. {
  8377. jw.Msg = "请传入正确的参数!";
  8378. }
  8379. return Ok(jw);
  8380. }
  8381. /// <summary>
  8382. /// 导出行程单
  8383. /// </summary>
  8384. /// <param name="dto"></param>
  8385. /// <returns></returns>
  8386. [HttpPost]
  8387. public IActionResult ExportTravel(ExportTravelDto dto)
  8388. {
  8389. var jw = JsonView(false);
  8390. jw.Data = "";
  8391. int diid = 0;
  8392. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8393. if (Find == null)
  8394. {
  8395. jw.Msg = "请选择正确的团组!";
  8396. return Ok(jw);
  8397. }
  8398. else
  8399. {
  8400. diid = Find.Id;
  8401. }
  8402. //数据源
  8403. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8404. DataTable dtBlack = null;
  8405. try
  8406. {
  8407. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8408. }
  8409. catch (Exception)
  8410. {
  8411. jw.Msg = "机票黑屏代码有误!";
  8412. return Ok(jw);
  8413. }
  8414. string CityStr = string.Empty;
  8415. if (dtBlack.Rows.Count == 0)
  8416. {
  8417. jw.Msg = "机票黑屏代码有误!";
  8418. return Ok(jw);
  8419. }
  8420. else
  8421. {
  8422. foreach (DataRow row in dtBlack.Rows)
  8423. {
  8424. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8425. {
  8426. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8427. return Ok(jw);
  8428. }
  8429. }
  8430. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8431. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8432. }
  8433. //创建数据源Table
  8434. DataTable dtSource = new DataTable();
  8435. dtSource.Columns.Add("Days", typeof(string));
  8436. dtSource.Columns.Add("Date", typeof(string));
  8437. dtSource.Columns.Add("Week", typeof(string));
  8438. dtSource.Columns.Add("Traffic", typeof(string));
  8439. dtSource.Columns.Add("Trip", typeof(string));
  8440. //获取数据,放到datatable
  8441. foreach (var item in _travelList)
  8442. {
  8443. DataRow dr = dtSource.NewRow();
  8444. dr["Days"] = item.Days;
  8445. dr["Date"] = item.Date;
  8446. dr["Week"] = item.WeekDay;
  8447. dr["Traffic"] = item.Traffic_First
  8448. + "\r\n"
  8449. + item.Traffic_Second;
  8450. dr["Trip"] = item.Trip;
  8451. dtSource.Rows.Add(dr);
  8452. }
  8453. Dictionary<string, string> dic = new Dictionary<string, string>();
  8454. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8455. dic.Add("City", CityStr);
  8456. dic.Add("Days", Find.VisitDays.ToString());
  8457. dic.Add("DeleCode", Find.TourCode);
  8458. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8459. //模板路径
  8460. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8461. //载入模板
  8462. Document doc = null;
  8463. DocumentBuilder builder = null;
  8464. try
  8465. {
  8466. //载入模板
  8467. doc = new Document(tempPath);
  8468. builder = new DocumentBuilder(doc);
  8469. }
  8470. catch (Exception)
  8471. {
  8472. jw.Msg = "模板位置不存在!";
  8473. return Ok(jw);
  8474. }
  8475. foreach (var key in dic.Keys)
  8476. {
  8477. Bookmark bookmark = doc.Range.Bookmarks[key];
  8478. if (bookmark != null)
  8479. {
  8480. builder.MoveToBookmark(key);
  8481. builder.Write(dic[key]);
  8482. }
  8483. }
  8484. //获取word里所有表格
  8485. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8486. //获取所填表格的序数
  8487. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8488. try
  8489. {
  8490. //循环赋值
  8491. for (int i = 0; i < dtSource.Rows.Count; i++)
  8492. {
  8493. builder.MoveToCell(0, i + 1, 0, 0);
  8494. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8495. builder.MoveToCell(0, i + 1, 1, 0);
  8496. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8497. builder.MoveToCell(0, i + 1, 2, 0);
  8498. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8499. var trip = dtSource.Rows[i]["Trip"].ToString();
  8500. builder.MoveToCell(0, i + 1, 3, 0);
  8501. builder.Write(trip);
  8502. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8503. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8504. // 获取特定索引的段落
  8505. Paragraph paragraph = (Paragraph)paragraphs[0];
  8506. Run run = paragraph.Runs[0];
  8507. Aspose.Words.Font font = run.Font;
  8508. font.Name = "黑体";
  8509. //设置双休红色
  8510. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8511. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8512. paragraph = (Paragraph)paragraphs[1];
  8513. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8514. {
  8515. run = paragraph.Runs[0];
  8516. font = run.Font;
  8517. font.Color = Color.Red;
  8518. }
  8519. }
  8520. }
  8521. catch (Exception ex)
  8522. {
  8523. }
  8524. //删除多余行
  8525. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8526. {
  8527. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8528. }
  8529. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8530. if (!Directory.Exists(savePath))
  8531. {
  8532. try
  8533. {
  8534. Directory.CreateDirectory(savePath);
  8535. }
  8536. catch
  8537. {
  8538. }
  8539. }
  8540. string path = savePath + Find.TeamName + "出访日程";
  8541. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8542. try
  8543. {
  8544. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8545. string postfix = ".docx";
  8546. if (dto.IsPDF == 1)
  8547. {
  8548. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8549. postfix = ".pdf";
  8550. }
  8551. doc.Save(path + postfix, saveFormat);
  8552. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8553. }
  8554. catch (Exception)
  8555. {
  8556. jw = JsonView(false);
  8557. }
  8558. return Ok(jw);
  8559. }
  8560. /// <summary>
  8561. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8562. /// </summary>
  8563. /// <param name="num"></param>
  8564. /// <returns></returns>
  8565. string GetNum(string num)
  8566. {
  8567. string str = "";
  8568. switch (num)
  8569. {
  8570. case "1":
  8571. str = "一";
  8572. break;
  8573. case "2":
  8574. str = "二";
  8575. break;
  8576. case "3":
  8577. str = "三";
  8578. break;
  8579. case "4":
  8580. str = "四";
  8581. break;
  8582. case "5":
  8583. str = "五";
  8584. break;
  8585. case "6":
  8586. str = "六";
  8587. break;
  8588. case "7":
  8589. str = "七";
  8590. break;
  8591. case "8":
  8592. str = "八";
  8593. break;
  8594. case "9":
  8595. str = "九";
  8596. break;
  8597. case "10":
  8598. str = "十";
  8599. break;
  8600. case "11":
  8601. str = "十一";
  8602. break;
  8603. case "12":
  8604. str = "十二";
  8605. break;
  8606. case "一":
  8607. str = "1";
  8608. break;
  8609. case "二":
  8610. str = "2";
  8611. break;
  8612. case "三":
  8613. str = "3";
  8614. break;
  8615. case "四":
  8616. str = "4";
  8617. break;
  8618. case "五":
  8619. str = "5";
  8620. break;
  8621. case "六":
  8622. str = "6";
  8623. break;
  8624. case "七":
  8625. str = "7";
  8626. break;
  8627. case "八":
  8628. str = "8";
  8629. break;
  8630. case "九":
  8631. str = "9";
  8632. break;
  8633. case "十":
  8634. str = "10";
  8635. break;
  8636. case "十一":
  8637. str = "11";
  8638. break;
  8639. case "十二":
  8640. str = "12";
  8641. break;
  8642. }
  8643. return str;
  8644. }
  8645. #endregion
  8646. #endregion
  8647. #region 团组成本
  8648. /// <summary>
  8649. /// 团组成本数据初始化
  8650. /// </summary>
  8651. /// <param name="dto"></param>
  8652. /// <returns></returns>
  8653. [HttpPost]
  8654. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8655. {
  8656. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8657. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8658. WHEN COUNT(*) >= 0 THEN 'True'
  8659. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8660. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8661. ").ToList(); //团组列表
  8662. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8663. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8664. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8665. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8666. if (groupinfoValue != null)
  8667. {
  8668. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8669. var spArr = new string[1] { countryArr };
  8670. if (countryArr.Contains("|"))
  8671. {
  8672. spArr = countryArr.Split("|");
  8673. }
  8674. else if (countryArr.Contains("、"))
  8675. {
  8676. spArr = countryArr.Split("、");
  8677. }
  8678. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8679. {
  8680. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8681. if (dbQueryCountry != null)
  8682. {
  8683. visaCountryInfoArr.Add(dbQueryCountry);
  8684. }
  8685. }
  8686. }
  8687. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8688. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8689. var create = _GroupCostRepository.
  8690. CreateGroupCostByBlackCode(dto.Diid);
  8691. if (groupCost.Count == 0 && create.Code == 0)
  8692. {
  8693. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8694. }
  8695. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8696. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8697. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8698. groupCostMap = groupCostMap.Select(x =>
  8699. {
  8700. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8701. {
  8702. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8703. }
  8704. return x;
  8705. }).ToList();
  8706. //GroupCostParameter.Add(new
  8707. // Grp_GroupCostParameter());
  8708. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8709. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8710. return Ok(JsonView(new
  8711. {
  8712. groupList,
  8713. groupInfo,
  8714. groupChecks,
  8715. groupCost = groupCostMap,
  8716. hotelNumber,
  8717. GroupCostParameter = GroupCostParameterMap,
  8718. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8719. {
  8720. x.VisaCountry,
  8721. x.VisaPrice,
  8722. x.Id,
  8723. }).ToList(),
  8724. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8725. blackCodeIsTrue = create.Code == 0 ? true : false,
  8726. hotelIsTrue = hotelIsTrue,
  8727. }));
  8728. }
  8729. /// <summary>
  8730. /// 团组成本信息保存
  8731. /// </summary>
  8732. /// <param name="dto"></param>
  8733. /// <returns></returns>
  8734. [HttpPost]
  8735. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8736. {
  8737. if (dto.Diid <= 0 || dto.Userid <= 0)
  8738. {
  8739. return Ok(JsonView(false));
  8740. }
  8741. JsonView jw = null;
  8742. bool isTrue = false;
  8743. #region 复制团组成本
  8744. //if (dto.Diid == 2581)
  8745. //{
  8746. // dto.Diid = 2599;
  8747. // dto.CheckBoxs.ForEach(x =>
  8748. // {
  8749. // x.Diid = 2599;
  8750. // });
  8751. // dto.GroupCosts.ForEach(x =>
  8752. // {
  8753. // x.Diid = 2599;
  8754. // });
  8755. // dto.CostTypeHotelNumbers.ForEach(x =>
  8756. // {
  8757. // x.Diid = 2599;
  8758. // });
  8759. // dto.GroupCostParameters.ForEach(x =>
  8760. // {
  8761. // x.DiId = 2599;
  8762. // });
  8763. //}
  8764. #endregion
  8765. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8766. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8767. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8768. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8769. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8770. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8771. try
  8772. {
  8773. _sqlSugar.BeginTran();
  8774. isTrue = await _GroupCostRepository.
  8775. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8776. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8777. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8778. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8779. _sqlSugar.CommitTran();
  8780. jw = JsonView(true, "保存成功!", isTrue);
  8781. }
  8782. catch (Exception)
  8783. {
  8784. _sqlSugar.RollbackTran();
  8785. jw = JsonView(false);
  8786. }
  8787. return Ok(jw);
  8788. }
  8789. /// <summary>
  8790. /// 司兼导数据
  8791. /// </summary>
  8792. /// <param name="dto"></param>
  8793. /// <returns></returns>
  8794. [HttpPost]
  8795. public IActionResult GetCarGuides(CarGuidesDto dto)
  8796. {
  8797. JsonView jw = null;
  8798. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8799. jw = JsonView(true, "获取成功!", Data);
  8800. return Ok(jw);
  8801. }
  8802. /// <summary>
  8803. /// 导游数据
  8804. /// </summary>
  8805. /// <param name="dto"></param>
  8806. /// <returns></returns>
  8807. [HttpPost]
  8808. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8809. {
  8810. JsonView jw = null;
  8811. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8812. // 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
  8813. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8814. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8815. jw = JsonView(true, "获取成功!", Data);
  8816. return Ok(jw);
  8817. }
  8818. /// <summary>
  8819. /// 成本车数据
  8820. /// </summary>
  8821. /// <param name="dto"></param>
  8822. /// <returns></returns>
  8823. [HttpPost]
  8824. public IActionResult GetCarInfo(CarGuidesDto dto)
  8825. {
  8826. JsonView jw = null;
  8827. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8828. jw = JsonView(true, "获取成功!", Data);
  8829. return Ok(jw);
  8830. }
  8831. /// <summary>
  8832. /// 景点数据
  8833. /// </summary>
  8834. /// <param name="dto"></param>
  8835. /// <returns></returns>
  8836. [HttpPost]
  8837. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8838. {
  8839. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8840. return Ok(JsonView(true, "获取成功!", Data));
  8841. }
  8842. /// <summary>
  8843. /// 成本通知
  8844. /// </summary>
  8845. /// <param name="dto"></param>
  8846. /// <returns></returns>
  8847. [HttpPost]
  8848. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8849. {
  8850. if (dto.Diid < 0)
  8851. {
  8852. return Ok(JsonView(false));
  8853. }
  8854. JsonView jw = null;
  8855. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8856. if (GroupCostParameter != null)
  8857. {
  8858. int IsShare = 0;
  8859. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8860. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8861. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8862. string msg = string.Empty;
  8863. if (isTrue)
  8864. {
  8865. if (IsShare == 0)
  8866. {
  8867. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8868. }
  8869. else
  8870. {
  8871. #region 企微通知对应岗位用户
  8872. try
  8873. {
  8874. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8875. }
  8876. catch (Exception ex)
  8877. {
  8878. }
  8879. #endregion
  8880. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8881. }
  8882. jw = JsonView(isTrue, msg, new { IsShare });
  8883. }
  8884. else
  8885. {
  8886. msg = "修改失败!";
  8887. jw = JsonView(isTrue, msg);
  8888. }
  8889. }
  8890. else
  8891. {
  8892. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8893. }
  8894. return Ok(jw);
  8895. }
  8896. /// <summary>
  8897. /// 导出报价单
  8898. /// </summary>
  8899. /// <param name="dto"></param>
  8900. /// <returns></returns>
  8901. [HttpPost]
  8902. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8903. {
  8904. if (dto.Diid == 0)
  8905. {
  8906. return Ok(JsonView(false, "请传递团组id"));
  8907. }
  8908. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8909. if (deleInfo.Code != 0)
  8910. {
  8911. return Ok(JsonView(false, "团组信息查询失败!"));
  8912. }
  8913. var di = deleInfo.Data as DelegationInfoWebView;
  8914. if (di != null)
  8915. {
  8916. di.TeamName = di.TeamName.Replace("|", "、");
  8917. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8918. //文件名
  8919. string strFileName = di.TeamName + "-收款账单.doc";
  8920. //获取模板
  8921. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8922. //载入模板
  8923. Document doc = new Document(tmppath);
  8924. decimal TotalPrice = 0.00M;
  8925. string itemStr = string.Empty;
  8926. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8927. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8928. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8929. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8930. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8931. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8932. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8933. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  8934. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  8935. foreach (var cost in groupCostType)
  8936. {
  8937. var List = cost.ToList();
  8938. if (cost.Key == "A")
  8939. {
  8940. foreach (var ListItem in List)
  8941. {
  8942. if (ListItem.number > 0)
  8943. {
  8944. if (ListItem.code.Contains("TBR"))
  8945. {
  8946. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8947. }
  8948. else
  8949. {
  8950. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8951. }
  8952. TotalPrice += (ListItem.number * ListItem.price);
  8953. }
  8954. }
  8955. }
  8956. else
  8957. {
  8958. itemStr = itemStr.Insert(0, "A段\r\n");
  8959. itemStr += "B段\r\n";
  8960. foreach (var ListItem in List)
  8961. {
  8962. if (ListItem.number > 0)
  8963. {
  8964. if (ListItem.code.Contains("TBR"))
  8965. {
  8966. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8967. }
  8968. else
  8969. {
  8970. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8971. }
  8972. TotalPrice += (ListItem.number * ListItem.price);
  8973. }
  8974. }
  8975. }
  8976. }
  8977. #region 替换Word模板书签内容
  8978. Dictionary<string, string> marks = new Dictionary<string, string>();
  8979. marks.Add("To", di.ClientUnit);//付款方
  8980. marks.Add("ToTel", di.TellPhone);//付款方电话
  8981. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  8982. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  8983. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  8984. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  8985. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  8986. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  8987. marks.Add("PayItemContent", itemStr);//详细信息
  8988. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  8989. #endregion
  8990. ////注
  8991. //if (doc.Range.Bookmarks["Attention"] != null)
  8992. //{
  8993. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  8994. // mark.Text = frList[0].Attention;
  8995. //}
  8996. foreach (var item in marks.Keys)
  8997. {
  8998. if (doc.Range.Bookmarks[item] != null)
  8999. {
  9000. Bookmark mark = doc.Range.Bookmarks[item];
  9001. mark.Text = marks[item];
  9002. }
  9003. }
  9004. byte[] bytes = null;
  9005. using (MemoryStream stream = new MemoryStream())
  9006. {
  9007. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9008. bytes = stream.ToArray();
  9009. }
  9010. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9011. return Ok(JsonView(true, "", new
  9012. {
  9013. Data = bytes,
  9014. strFileName,
  9015. }));
  9016. }
  9017. else
  9018. {
  9019. return Ok(JsonView(false, "团组信息不存在!"));
  9020. }
  9021. }
  9022. /// <summary>
  9023. /// 导出团组成本
  9024. /// </summary>
  9025. /// <param name="dto"></param>
  9026. /// <returns></returns>
  9027. [HttpPost]
  9028. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9029. {
  9030. var jw = JsonView(false);
  9031. if (dto.Diid == 0)
  9032. {
  9033. return Ok(JsonView(false, "请传递团组id"));
  9034. }
  9035. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9036. if (deleInfo.Code != 0)
  9037. {
  9038. return Ok(JsonView(false, "团组信息查询失败!"));
  9039. }
  9040. var di = deleInfo.Data as DelegationInfoWebView;
  9041. if (di == null)
  9042. {
  9043. return Ok(JsonView(false, "团组信息查询失败!"));
  9044. }
  9045. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9046. WorkbookDesigner designer = new WorkbookDesigner();
  9047. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9048. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9049. for (int i = 0; i < List_GC.Count; i++)
  9050. {
  9051. GroupCost_Excel gc = new GroupCost_Excel();
  9052. gc.Id = List_GC[i].Id;
  9053. gc.Diid = List_GC[i].Diid.ToString();
  9054. gc.DAY = List_GC[i].DAY;
  9055. string week = "";
  9056. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9057. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9058. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9059. gc.ITIN = List_GC[i].ITIN;
  9060. gc.CarType = List_GC[i].CarType;
  9061. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9062. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9063. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9064. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9065. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9066. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9067. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9068. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9069. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9070. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9071. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9072. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9073. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9074. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9075. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9076. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9077. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9078. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9079. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9080. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9081. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9082. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9083. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9084. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9085. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9086. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9087. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9088. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9089. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9090. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9091. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9092. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9093. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9094. List_GC1.Add(gc);
  9095. }
  9096. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9097. dt.TableName = "TB";
  9098. //报表标题等不用dt的值
  9099. designer.SetDataSource("TeamName", dto.title.TeamName);
  9100. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9101. designer.SetDataSource("Tax", dto.title.Tax);
  9102. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9103. designer.SetDataSource("Currency", dto.title.Currency);
  9104. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9105. designer.SetDataSource("Rate", dto.title.Rate);
  9106. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9107. var Aparams = hotels.Find(x => x.Type == "Default");
  9108. if (Aparams == null)
  9109. {
  9110. return Ok(jw);
  9111. }
  9112. //酒店数量
  9113. var txtSGRNumber = Aparams.SGR.ToString();
  9114. var txtTBRNumber = Aparams.TBR.ToString();
  9115. var txtJSESNumber = Aparams.JSES.ToString();
  9116. var txtSUITENumbe = Aparams.SUITE.ToString();
  9117. if (dto.costType == "B")
  9118. {
  9119. Aparams = hotels.Find(x => x.Type == "A");
  9120. var Bparams = hotels.Find(x => x.Type == "B");
  9121. if (Aparams == null || Bparams == null)
  9122. {
  9123. return Ok(jw);
  9124. }
  9125. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9126. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9127. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9128. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9129. }
  9130. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9131. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9132. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9133. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9134. var ws = designer.Workbook.Worksheets[0];
  9135. int Row = List_GC.Count;
  9136. int startIndex = 11;
  9137. int HideRows = 0;
  9138. List<int> hideRowsList = new List<int>();
  9139. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9140. #region A段left数据
  9141. var left = dto.leftInfo.Find(x => x.Type == "A");
  9142. if (left == null)
  9143. {
  9144. return Ok(jw);
  9145. }
  9146. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9147. if (leftBindData != null)
  9148. {
  9149. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9150. designer.SetDataSource("VisaRS", leftBindData.rs);
  9151. designer.SetDataSource("VisaXS", leftBindData.xs);
  9152. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9153. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9154. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9155. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9156. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9157. }
  9158. else
  9159. {
  9160. hideRowsList.Add(Row + startIndex + HideRows);
  9161. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9162. }
  9163. HideRows += 2;
  9164. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9165. if (leftBindData != null)
  9166. {
  9167. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9168. designer.SetDataSource("BXRS", leftBindData.rs);
  9169. designer.SetDataSource("BXXS", leftBindData.xs);
  9170. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9171. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9172. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9173. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9174. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9175. }
  9176. else
  9177. {
  9178. hideRowsList.Add(Row + startIndex + HideRows);
  9179. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9180. }
  9181. HideRows += 2;
  9182. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9183. if (leftBindData != null)
  9184. {
  9185. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9186. designer.SetDataSource("HSRS", leftBindData.rs);
  9187. designer.SetDataSource("HSXS", leftBindData.xs);
  9188. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9189. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9190. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9191. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9192. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9193. }
  9194. else
  9195. {
  9196. hideRowsList.Add(Row + startIndex + HideRows);
  9197. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9198. }
  9199. HideRows += 2;
  9200. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9201. if (leftBindData != null)
  9202. {
  9203. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9204. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9205. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9206. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9207. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9208. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9209. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9210. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9211. }
  9212. else
  9213. {
  9214. hideRowsList.Add(Row + startIndex + HideRows);
  9215. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9216. }
  9217. HideRows += 2;
  9218. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9219. if (leftBindData != null)
  9220. {
  9221. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9222. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9223. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9224. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9225. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9226. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9227. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9228. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9229. }
  9230. else
  9231. {
  9232. hideRowsList.Add(Row + startIndex + HideRows);
  9233. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9234. }
  9235. HideRows += 2;
  9236. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9237. if (leftBindData != null)
  9238. {
  9239. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9240. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9241. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9242. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9243. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9244. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9245. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9246. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9247. }
  9248. else
  9249. {
  9250. hideRowsList.Add(Row + startIndex + HideRows);
  9251. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9252. }
  9253. HideRows += 2;
  9254. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9255. if (leftBindData != null)
  9256. {
  9257. ////TBR
  9258. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9259. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9260. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9261. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9262. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9263. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9264. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9265. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9266. }
  9267. else
  9268. {
  9269. hideRowsList.Add(Row + startIndex + HideRows);
  9270. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9271. }
  9272. HideRows += 2;
  9273. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9274. if (leftBindData != null)
  9275. {
  9276. ////SGR
  9277. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9278. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9279. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9280. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9281. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9282. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9283. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9284. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9285. }
  9286. else
  9287. {
  9288. hideRowsList.Add(Row + startIndex + HideRows);
  9289. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9290. }
  9291. HideRows += 2;
  9292. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9293. if (leftBindData != null)
  9294. {
  9295. ////JS/ES
  9296. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9297. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9298. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9299. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9300. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9301. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9302. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9303. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9304. }
  9305. else
  9306. {
  9307. hideRowsList.Add(Row + startIndex + HideRows);
  9308. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9309. }
  9310. HideRows += 2;
  9311. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9312. if (leftBindData != null)
  9313. {
  9314. ////SUITE
  9315. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9316. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9317. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9318. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9319. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9320. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9321. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9322. designer.SetDataSource("HotelSUITEZLR", ((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("地接"));
  9331. if (leftBindData != null)
  9332. {
  9333. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9334. designer.SetDataSource("DJRS", leftBindData.rs);
  9335. designer.SetDataSource("DJXS", leftBindData.xs);
  9336. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9337. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9338. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9339. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9340. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9341. }
  9342. else
  9343. {
  9344. hideRowsList.Add(Row + startIndex + HideRows);
  9345. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9346. }
  9347. HideRows += 2;
  9348. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9349. if (leftBindData != null)
  9350. {
  9351. designer.SetDataSource("HCPCB", leftBindData.cb);
  9352. designer.SetDataSource("HCPRS", leftBindData.rs);
  9353. designer.SetDataSource("HCPXS", leftBindData.xs);
  9354. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9355. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9356. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9357. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9358. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9359. }
  9360. else
  9361. {
  9362. hideRowsList.Add(Row + startIndex + HideRows);
  9363. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9364. }
  9365. HideRows += 2;
  9366. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9367. if (leftBindData != null)
  9368. {
  9369. designer.SetDataSource("CPCB", leftBindData.cb);
  9370. designer.SetDataSource("CPRS", leftBindData.rs);
  9371. designer.SetDataSource("CPXS", leftBindData.xs);
  9372. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9373. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9374. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9375. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9376. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9377. }
  9378. else
  9379. {
  9380. hideRowsList.Add(Row + startIndex + HideRows);
  9381. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9382. }
  9383. HideRows += 2;
  9384. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9385. if (leftBindData != null)
  9386. {
  9387. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9388. designer.SetDataSource("GWRS", leftBindData.rs);
  9389. designer.SetDataSource("GWXS", leftBindData.xs);
  9390. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9391. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9392. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9393. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9394. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9395. }
  9396. else
  9397. {
  9398. hideRowsList.Add(Row + startIndex + HideRows);
  9399. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9400. }
  9401. HideRows += 2;
  9402. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9403. if (leftBindData != null)
  9404. {
  9405. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9406. designer.SetDataSource("LYJRS", leftBindData.rs);
  9407. designer.SetDataSource("LYJXS", leftBindData.xs);
  9408. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9409. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9410. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9411. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9412. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9413. }
  9414. else
  9415. {
  9416. hideRowsList.Add(Row + startIndex + HideRows);
  9417. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9418. }
  9419. #endregion
  9420. #region A段Right信息
  9421. var right = dto.rightInfo.Find(x => x.Type == "A");
  9422. if (right == null)
  9423. {
  9424. return Ok(jw);
  9425. }
  9426. HideRows += 4;
  9427. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9428. if (rightBindData != null)
  9429. {
  9430. //经济舱 + 双人间 TBR
  9431. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9432. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9433. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9434. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9435. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9436. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9437. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9438. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9439. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9440. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9441. }
  9442. else
  9443. {
  9444. hideRowsList.Add(Row + startIndex + HideRows);
  9445. }
  9446. HideRows += 2;
  9447. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9448. if (rightBindData != null)
  9449. {
  9450. //经济舱 + 单人间 SGR
  9451. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9452. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9453. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9454. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9455. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9456. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9457. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9458. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9459. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9460. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9461. }
  9462. else
  9463. {
  9464. hideRowsList.Add(Row + startIndex + HideRows);
  9465. }
  9466. HideRows += 2;
  9467. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9468. if (rightBindData != null)
  9469. {
  9470. //公务舱 + 单人间 SGR
  9471. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9472. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9473. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9474. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9475. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9476. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9477. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9478. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9479. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9480. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9481. }
  9482. else
  9483. {
  9484. hideRowsList.Add(Row + startIndex + HideRows);
  9485. }
  9486. HideRows += 2;
  9487. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9488. if (rightBindData != null)
  9489. {
  9490. //公务舱 + 小套房 JSES
  9491. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9492. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9493. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9494. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9495. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9496. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9497. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9498. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9499. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9500. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9501. }
  9502. else
  9503. {
  9504. hideRowsList.Add(Row + startIndex + HideRows);
  9505. }
  9506. HideRows += 2;
  9507. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9508. if (rightBindData != null)
  9509. {
  9510. //公务舱 + 小套房 JSES
  9511. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9512. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9513. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9514. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9515. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9516. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9517. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9518. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9519. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9520. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9521. }
  9522. else
  9523. {
  9524. hideRowsList.Add(Row + startIndex + HideRows);
  9525. }
  9526. HideRows += 2;
  9527. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9528. if (rightBindData != null)
  9529. {
  9530. //经济舱 + 大套房
  9531. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9532. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9533. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9534. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9535. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9536. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9537. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9538. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9539. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9540. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9541. }
  9542. else
  9543. {
  9544. hideRowsList.Add(Row + startIndex + HideRows);
  9545. }
  9546. HideRows += 2;
  9547. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9548. if (rightBindData != null)
  9549. {
  9550. //头等舱 + 小套房 JSES
  9551. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9552. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9553. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9554. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9555. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9556. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9557. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9558. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9559. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9560. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9561. }
  9562. else
  9563. {
  9564. hideRowsList.Add(Row + startIndex + HideRows);
  9565. }
  9566. HideRows += 2;
  9567. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9568. if (rightBindData != null)
  9569. {
  9570. //头等舱 + 大套房
  9571. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9572. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9573. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9574. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9575. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9576. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9577. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9578. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9579. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9580. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9581. }
  9582. else
  9583. {
  9584. hideRowsList.Add(Row + startIndex + HideRows);
  9585. }
  9586. #endregion
  9587. #region B段标题清空
  9588. designer.SetDataSource("CostBDRCB", "");
  9589. designer.SetDataSource("CostBRS", "");
  9590. designer.SetDataSource("CostBXS", "");
  9591. designer.SetDataSource("CostBZCB", "");
  9592. designer.SetDataSource("CostBDRBJ", "");
  9593. designer.SetDataSource("CostBZBJ", "");
  9594. designer.SetDataSource("CostBDRLR", "");
  9595. designer.SetDataSource("CostBZLR", "");
  9596. designer.SetDataSource("CostBDRCBOM", "");
  9597. designer.SetDataSource("CostBRSOM", "");
  9598. designer.SetDataSource("CostBZCBOM", "");
  9599. designer.SetDataSource("CostBDRBJOM", "");
  9600. designer.SetDataSource("CostBZBJOM", "");
  9601. designer.SetDataSource("CostBDRLROM", "");
  9602. designer.SetDataSource("CostBZLROM", "");
  9603. #endregion
  9604. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9605. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9606. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9607. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9608. designer.SetDataSource("DJName", "地接(CNY)");
  9609. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9610. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9611. designer.SetDataSource("GWName", "公务(CNY)");
  9612. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9613. designer.SetDataSource("LYJName", "零用金(CNY)");
  9614. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9615. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9616. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9617. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9618. designer.SetDataSource("BXName", "保险(CNY)");
  9619. designer.SetDataSource("VisaName", "签证(CNY)");
  9620. #region B段基本数据
  9621. if (dto.costType == "B")
  9622. {
  9623. left = dto.leftInfo.Find(x => x.Type == "B");
  9624. if (left == null)
  9625. {
  9626. return Ok(jw);
  9627. }
  9628. #region B段left数据
  9629. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9630. if (leftBindData != null)
  9631. {
  9632. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9633. designer.SetDataSource("BHSRS", leftBindData.rs);
  9634. designer.SetDataSource("BHSXS", leftBindData.xs);
  9635. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9636. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9637. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9638. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9639. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9640. }
  9641. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9642. if (leftBindData != null)
  9643. {
  9644. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9645. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9646. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9647. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9648. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9649. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9650. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9651. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9652. }
  9653. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9654. if (leftBindData != null)
  9655. {
  9656. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9657. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9658. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9659. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9660. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9661. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9662. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9663. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9664. }
  9665. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9666. if (leftBindData != null)
  9667. {
  9668. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9669. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9670. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9671. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9672. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9673. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9674. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9675. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9676. }
  9677. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9678. if (leftBindData != null)
  9679. {
  9680. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9681. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9682. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9683. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9684. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9685. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9686. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9687. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9688. }
  9689. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9690. if (leftBindData != null)
  9691. {
  9692. designer.SetDataSource("BCPCB", leftBindData.cb);
  9693. designer.SetDataSource("BCPRS", leftBindData.rs);
  9694. designer.SetDataSource("BCPXS", leftBindData.xs);
  9695. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9696. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9697. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9698. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9699. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9700. }
  9701. //TBR
  9702. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9703. if (leftBindData != null)
  9704. {
  9705. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9706. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9707. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9708. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9709. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9710. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9711. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9712. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9713. }
  9714. //SGR
  9715. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9716. if (leftBindData != null)
  9717. {
  9718. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9719. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9720. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9721. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9722. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9723. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9724. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9725. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9726. }
  9727. //JS/ES
  9728. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9729. if (leftBindData != null)
  9730. {
  9731. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9732. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9733. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9734. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9735. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9736. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9737. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9738. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9739. }
  9740. //SUITE
  9741. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9742. if (leftBindData != null)
  9743. {
  9744. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9745. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9746. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9747. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9748. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9749. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9750. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9751. designer.SetDataSource("BHotelSUITEZLR", ((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("BDJDRCB", leftBindData.cb);
  9757. designer.SetDataSource("BDJRS", leftBindData.rs);
  9758. designer.SetDataSource("BDJXS", leftBindData.xs);
  9759. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9760. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9761. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9762. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9763. designer.SetDataSource("BDJZLR", ((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("BGWDRCD", leftBindData.cb);
  9769. designer.SetDataSource("BGWRS", leftBindData.rs);
  9770. designer.SetDataSource("BGWXS", leftBindData.xs);
  9771. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9772. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9773. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9774. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9775. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9776. }
  9777. #region 优化方案
  9778. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9779. //excelBind.Add("零用金", new {
  9780. //cb="",
  9781. //rs="",
  9782. //xs ="",
  9783. //zcb = "",
  9784. //});
  9785. #endregion
  9786. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9787. if (leftBindData != null)
  9788. {
  9789. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9790. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9791. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9792. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9793. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9794. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9795. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9796. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9797. }
  9798. #endregion
  9799. #region B段Right信息
  9800. right = dto.rightInfo.Find(x => x.Type == "B");
  9801. if (right == null)
  9802. {
  9803. return Ok(jw);
  9804. }
  9805. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9806. if (rightBindData != null)
  9807. {
  9808. //经济舱 + 双人间 TBR
  9809. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9810. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9811. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9812. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9813. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9814. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9815. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9816. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9817. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9818. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9819. }
  9820. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9821. if (rightBindData != null)
  9822. {
  9823. //经济舱 + 单人间 SGR
  9824. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9825. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9826. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9827. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9828. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9829. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9830. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9831. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9832. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9833. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9834. }
  9835. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9836. if (rightBindData != null)
  9837. {
  9838. //公务舱 + 单人间 SGR
  9839. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9840. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9841. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9842. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9843. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9844. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9845. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9846. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9847. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9848. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9849. }
  9850. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9851. if (rightBindData != null)
  9852. {
  9853. //公务舱 + 小套房 JSES
  9854. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9855. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9856. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9857. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9858. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9859. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9860. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9861. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9862. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9863. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9864. }
  9865. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9866. if (rightBindData != null)
  9867. {
  9868. //公务舱 + 小套房 JSES
  9869. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9870. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9871. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9872. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9873. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9874. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9875. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9876. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9877. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9878. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9879. }
  9880. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9881. if (rightBindData != null)
  9882. {
  9883. //经济舱 + 大套房
  9884. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9885. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9886. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9887. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9888. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9889. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9890. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9891. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9892. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9893. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9894. }
  9895. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9896. if (rightBindData != null)
  9897. {
  9898. //头等舱 + 小套房 JSES
  9899. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9900. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9901. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9902. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9903. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9904. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9905. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9906. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9907. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9908. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9909. }
  9910. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9911. if (rightBindData != null)
  9912. {
  9913. //头等舱 + 大套房
  9914. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9915. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9916. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9917. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9918. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9919. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9920. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9921. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9922. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9923. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9924. }
  9925. #endregion
  9926. #region 标题
  9927. designer.SetDataSource("CostBDRCB", "单人成本");
  9928. designer.SetDataSource("CostBRS", "人数");
  9929. designer.SetDataSource("CostBXS", "系数");
  9930. designer.SetDataSource("CostBZCB", "总成本");
  9931. designer.SetDataSource("CostBDRBJ", "单人报价");
  9932. designer.SetDataSource("CostBZBJ", "总报价");
  9933. designer.SetDataSource("CostBDRLR", "单人利润");
  9934. designer.SetDataSource("CostBZLR", "总利润");
  9935. designer.SetDataSource("CostBDRCBOM", "单人成本");
  9936. designer.SetDataSource("CostBRSOM", "人数");
  9937. designer.SetDataSource("CostBZCBOM", "总成本");
  9938. designer.SetDataSource("CostBDRBJOM", "单人报价");
  9939. designer.SetDataSource("CostBZBJOM", "总报价");
  9940. designer.SetDataSource("CostBDRLROM", "单人利润");
  9941. designer.SetDataSource("CostBZLROM", "总利润");
  9942. #endregion
  9943. }
  9944. #endregion
  9945. designer.SetDataSource("TzZCB2", TzZCB2);
  9946. designer.SetDataSource("TzZBJ2", TzZBJ2);
  9947. designer.SetDataSource("TzZLR2", TzZLR2);
  9948. string[] dataSourceKeys = new string[]
  9949. {
  9950. "VF",
  9951. "TGS",
  9952. "TGOF",
  9953. "TGM",
  9954. "TGA",
  9955. "TGTF",
  9956. "TGEF",
  9957. "CFM",
  9958. "CFOF",
  9959. "B",
  9960. "L",
  9961. "D",
  9962. "TBR",
  9963. "SGR",
  9964. "JSES",
  9965. "Suite",
  9966. "TV",
  9967. "1L",
  9968. "IF",
  9969. "EF",
  9970. "BRF",
  9971. "TE",
  9972. "TGT",
  9973. "DRVT",
  9974. "PC",
  9975. "TLF",
  9976. "ECT"
  9977. };
  9978. foreach (var item in dataSourceKeys)
  9979. {
  9980. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  9981. if (find != null)
  9982. {
  9983. designer.SetDataSource(item, find.text);
  9984. }
  9985. else
  9986. {
  9987. designer.SetDataSource(item, 0);
  9988. }
  9989. }
  9990. designer.SetDataSource(dt);
  9991. //根据数据源处理生成报表内容
  9992. designer.Process();
  9993. designer.Workbook.Worksheets[0].Name = "清单";
  9994. Worksheet sheet = designer.Workbook.Worksheets[0];
  9995. foreach (var Rowindex in hideRowsList)
  9996. {
  9997. ws.Cells.HideRows(Rowindex, 2);
  9998. }
  9999. byte[] bytes = null;
  10000. string strFileName = di.TeamName + "-团组-成本.xls";
  10001. using (MemoryStream stream = new MemoryStream())
  10002. {
  10003. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  10004. bytes = stream.ToArray();
  10005. }
  10006. return Ok(JsonView(true, "", new
  10007. {
  10008. Data = bytes,
  10009. strFileName,
  10010. }));
  10011. }
  10012. /// <summary>
  10013. /// 导出客户报表
  10014. /// </summary>
  10015. /// <returns></returns>
  10016. [HttpPost]
  10017. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10018. {
  10019. var jw = JsonView(false);
  10020. if (dto.Diid == 0)
  10021. {
  10022. return Ok(JsonView(false, "请传递团组id"));
  10023. }
  10024. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10025. if (deleInfo.Code != 0)
  10026. {
  10027. return Ok(JsonView(false, "团组信息查询失败!"));
  10028. }
  10029. var di = deleInfo.Data as DelegationInfoWebView;
  10030. if (di == null)
  10031. {
  10032. return Ok(JsonView(false, "团组信息查询失败!"));
  10033. }
  10034. //文件名
  10035. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10036. //获取模板
  10037. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10038. //载入模板
  10039. Document doc = new Document(tmppath);
  10040. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10041. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10042. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10043. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10044. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10045. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10046. if (AParameter == null)
  10047. {
  10048. return Ok(JsonView(false, "系数不存在!"));
  10049. }
  10050. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10051. , TzAirDesc, TzZCost;
  10052. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10053. = TzAirDesc = TzZCost = string.Empty;
  10054. TzNumber = AParameter.CostTypenumber.ToString();
  10055. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10056. CarGuides1 = dto.CarGuides1;
  10057. Meal = dto.Meal;
  10058. SubsidizedMeals = dto.SubsidizedMeals;
  10059. NightRepair = dto.NightRepair;
  10060. AttractionsTickets = dto.AttractionsTickets;
  10061. MiscellaneousFees = dto.MiscellaneousFees;
  10062. ATip = dto.ATip;
  10063. TzHotelDesc = "";
  10064. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10065. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10066. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10067. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10068. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10069. TzAirDesc = "";
  10070. TzZCost = dto.TzZCost;
  10071. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10072. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10073. var index = 1;
  10074. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10075. foreach (var item in TzHotelDescArr)
  10076. {
  10077. if (AinfoArr != null)
  10078. {
  10079. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10080. if (Ainfo != null)
  10081. {
  10082. if (int.Parse(Ainfo.rs) <= 0)
  10083. {
  10084. continue;
  10085. }
  10086. var hotelText = string.Empty;
  10087. switch (item)
  10088. {
  10089. case "SGR":
  10090. hotelText = "单人间";
  10091. break;
  10092. case "JSES":
  10093. hotelText = "小套房";
  10094. break;
  10095. case "SUITE":
  10096. hotelText = "套房";
  10097. break;
  10098. case "TBR":
  10099. hotelText = "双人间";
  10100. break;
  10101. }
  10102. if (item != "TBR")
  10103. {
  10104. 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";
  10105. }
  10106. else
  10107. {
  10108. 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";
  10109. }
  10110. index++;
  10111. }
  10112. }
  10113. }
  10114. index = 1;
  10115. foreach (var item in TzAirDescArr)
  10116. {
  10117. if (AinfoArr != null)
  10118. {
  10119. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10120. if (Ainfo != null)
  10121. {
  10122. if (int.Parse(Ainfo.rs) <= 0)
  10123. {
  10124. continue;
  10125. }
  10126. 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";
  10127. index++;
  10128. }
  10129. }
  10130. }
  10131. if (dto.costType == "B")
  10132. {
  10133. if (BParameter == null)
  10134. {
  10135. return Ok(JsonView(false, "B段系数不存在!"));
  10136. }
  10137. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10138. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10139. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10140. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10141. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10142. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10143. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10144. foreach (var item in TzHotelDescArr)
  10145. {
  10146. if (AinfoArr != null)
  10147. {
  10148. TzHotelDesc += "B段信息 \r\n";
  10149. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10150. if (Ainfo != null)
  10151. {
  10152. if (int.Parse(Ainfo.rs) <= 0)
  10153. {
  10154. continue;
  10155. }
  10156. var hotelText = string.Empty;
  10157. switch (item)
  10158. {
  10159. case "SGR":
  10160. hotelText = "单人间";
  10161. break;
  10162. case "JSES":
  10163. hotelText = "小套房";
  10164. break;
  10165. case "SUITE":
  10166. hotelText = "套房";
  10167. break;
  10168. case "TBR":
  10169. hotelText = "双人间";
  10170. break;
  10171. }
  10172. if (item != "TBR")
  10173. {
  10174. 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";
  10175. }
  10176. else
  10177. {
  10178. 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";
  10179. }
  10180. index++;
  10181. }
  10182. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10183. }
  10184. }
  10185. index = 1;
  10186. foreach (var item in TzAirDescArr)
  10187. {
  10188. if (AinfoArr != null)
  10189. {
  10190. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10191. if (Ainfo != null)
  10192. {
  10193. if (int.Parse(Ainfo.rs) <= 0)
  10194. {
  10195. continue;
  10196. }
  10197. 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";
  10198. index++;
  10199. }
  10200. }
  10201. }
  10202. }
  10203. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10204. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10205. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10206. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10207. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10208. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10209. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10210. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10211. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10212. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10213. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10214. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10215. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10216. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10217. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10218. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10219. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10220. DickeyValue.Add("TzZCost", TzZCost);
  10221. foreach (var key in DickeyValue.Keys)
  10222. {
  10223. if (doc.Range.Bookmarks[key] != null)
  10224. {
  10225. Bookmark mark = doc.Range.Bookmarks[key];
  10226. mark.Text = DickeyValue[key];
  10227. }
  10228. }
  10229. byte[] bytes = null;
  10230. string strFileName = di.TeamName + "-客户报价.doc";
  10231. using (MemoryStream stream = new MemoryStream())
  10232. {
  10233. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10234. bytes = stream.ToArray();
  10235. }
  10236. return Ok(JsonView(true, "", new
  10237. {
  10238. Data = bytes,
  10239. strFileName,
  10240. }));
  10241. }
  10242. /// <summary>
  10243. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10244. /// </summary>
  10245. /// <param name="dto"></param>
  10246. /// <returns></returns>
  10247. [HttpPost]
  10248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10249. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10250. {
  10251. try
  10252. {
  10253. #region 参数验证
  10254. if (dto.DiId < 0)
  10255. {
  10256. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10257. }
  10258. List<int> cTableIds = new List<int>() {
  10259. 76 ,//酒店预订
  10260. 77 ,//行程
  10261. 79 ,//车/导游地接
  10262. 80 ,//签证
  10263. 81 ,//邀请/公务活
  10264. 82 ,//团组客户保险
  10265. 85 ,//机票预订
  10266. 98 ,//其他款项
  10267. 285 ,//收款退还
  10268. 751 ,//酒店早餐
  10269. 1015 // 超支费用
  10270. };
  10271. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10272. {
  10273. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10274. }
  10275. #endregion
  10276. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10277. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10278. if (_GroupCostParameters.Count <= 0)
  10279. {
  10280. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10281. }
  10282. if (_GroupCostParameters[0].IsShare == 0)
  10283. {
  10284. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10285. }
  10286. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10287. //处理date为空问题
  10288. if (_GroupCosts.Count > 0)
  10289. {
  10290. for (int i = 0; i < _GroupCosts.Count; i++)
  10291. {
  10292. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10293. {
  10294. if (i > 0)
  10295. {
  10296. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10297. }
  10298. }
  10299. }
  10300. }
  10301. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10302. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10303. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10304. string currCode = "";
  10305. #region currCode 验证
  10306. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10307. if (isInt)
  10308. {
  10309. var currData = currDatas.Find(it => it.Id == intCurrency);
  10310. if (currData != null)
  10311. {
  10312. currCode = currData.Name;
  10313. }
  10314. }
  10315. else
  10316. {
  10317. currCode = _GroupCostParameters[0].Currency.Trim();
  10318. }
  10319. #endregion
  10320. //op,酒店单段模式存储
  10321. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10322. {
  10323. CurrencyCode = currCode,
  10324. Rate = _GroupCostParameters[0].Rate,
  10325. CostType = _GroupCostParameters[0].CostType,
  10326. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10327. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10328. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10329. };
  10330. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10331. if (_GroupCostParameters.Count == 2)
  10332. {
  10333. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10334. }
  10335. foreach (var item in _GroupCostParameters)
  10336. {
  10337. decimal _rate = 1;
  10338. decimal _rate1 = item.Rate;
  10339. decimal _scale = 1;
  10340. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10341. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10342. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10343. //if (userInfo != null)
  10344. //{
  10345. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10346. // {
  10347. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10348. // {
  10349. // _scale = 1.00M;
  10350. // }
  10351. // }
  10352. //}
  10353. #endregion
  10354. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10355. {
  10356. CurrencyCode = currCode,
  10357. Rate = _rate1,
  10358. CostType = item.CostType,
  10359. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10360. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10361. CostTypeNumber = item.CostTypenumber
  10362. };
  10363. if (_GroupCostParameters.Count > 1)
  10364. {
  10365. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10366. }
  10367. else
  10368. {
  10369. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10370. }
  10371. if (dto.CTable == 79)//
  10372. {
  10373. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10374. modulePromptInfo.TotalCost = item.DJCB;
  10375. }
  10376. List<string> costTypes = new List<string>() { "A", "B" };
  10377. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10378. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10379. if (_GroupCostsDuplicates.Count() == 1)
  10380. {
  10381. _GroupCostsTypeData = _GroupCosts;
  10382. }
  10383. else
  10384. {
  10385. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10386. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10387. }
  10388. /*
  10389. * 76 酒店预订
  10390. * 77 行程
  10391. * 79 车/导游地接
  10392. * 80 签证
  10393. * 81 邀请/公务活动
  10394. * 82 团组客户保险
  10395. * 85 机票预订
  10396. * 98 其他款项
  10397. * 285 收款退还
  10398. * 751 酒店早餐
  10399. * 1015 超支费用
  10400. */
  10401. switch (dto.CTable)
  10402. {
  10403. case 76: // 酒店预订
  10404. _ModuleSubPromptInfo.AddRange(
  10405. _GroupCostsTypeData.Select(it => new
  10406. {
  10407. it.DAY,
  10408. it.Date,
  10409. it.ACCON,
  10410. it.ITIN,
  10411. it.SGR,
  10412. it.TBR,
  10413. it.JS_ES,
  10414. it.Suite
  10415. })
  10416. );
  10417. break;
  10418. case 79: // 车/导游地接
  10419. _ModuleSubPromptInfo.AddRange(
  10420. _GroupCostsTypeData.Select(it => new
  10421. {
  10422. Date = it.Date, //日期
  10423. CarFee = it.CarCost * _rate * _scale, //车费用
  10424. CarType = it.CarType, //车型
  10425. DriverFee = it.CFS * _rate * _scale, //司机工资
  10426. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10427. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10428. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10429. GuideFee = it.TGS * _rate * _scale, //导游费用
  10430. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10431. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10432. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10433. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10434. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10435. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10436. Breakfast = it.B * _rate * _scale, //早餐费
  10437. Lunch = it.L * _rate * _scale, //午餐费
  10438. Dinner = it.D * _rate * _scale, //晚餐费
  10439. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10440. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10441. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10442. TicketFee = it.EF * _rate * _scale, //门票费
  10443. TicketRemark = it.EFR, //门票费描述
  10444. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10445. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10446. SpentCash = it.PC * _rate * _scale, //零用金
  10447. LeadersFee = it.TLF * _rate * _scale, //领队费
  10448. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10449. })
  10450. );
  10451. break;
  10452. case 85: // 机票
  10453. List<dynamic> datas = new List<dynamic>();
  10454. datas.Add(
  10455. new
  10456. {
  10457. AirType = "经济舱",
  10458. AirNum = item.JJCRS,
  10459. AirDRCB = item.JJCCB,
  10460. AirZCB = (item.JJCRS * item.JJCCB)
  10461. }
  10462. );
  10463. datas.Add(
  10464. new
  10465. {
  10466. AirType = "公务舱",
  10467. AirNum = item.GWCRS,
  10468. AirDRCB = item.GWCCB,
  10469. AirZCB = (item.GWCRS * item.GWCCB)
  10470. }
  10471. );
  10472. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10473. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10474. modulePromptInfo.Data = new
  10475. {
  10476. airFeeData = datas,
  10477. airInitData = initDatas
  10478. };
  10479. _ModulePromptInfos.Add(modulePromptInfo);
  10480. break;
  10481. default:
  10482. break;
  10483. }
  10484. }
  10485. if (dto.CTable != 85)
  10486. {
  10487. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10488. _ModulePromptInfos.Add(_ModulePromptInfo);
  10489. }
  10490. _view.ModulePromptInfos = _ModulePromptInfos;
  10491. return Ok(JsonView(true, "操作成功!", _view));
  10492. }
  10493. catch (Exception ex)
  10494. {
  10495. return Ok(JsonView(false, ex.Message));
  10496. }
  10497. }
  10498. /// <summary>
  10499. /// 根据黑屏代码重新生成行程
  10500. /// </summary>
  10501. /// <param name="dto"></param>
  10502. /// <returns></returns>
  10503. [HttpPost]
  10504. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10505. {
  10506. var jw = JsonView(false);
  10507. var Create = _GroupCostRepository.
  10508. CreateGroupCostByBlackCode(dto.Diid);
  10509. jw.Msg = Create.Msg;
  10510. if (Create.Code == 0)
  10511. {
  10512. jw.Code = 200;
  10513. jw.Data = new
  10514. {
  10515. groupCost = Create.Data,
  10516. blackCodeIsTrue = true
  10517. };
  10518. }
  10519. else
  10520. {
  10521. jw.Code = 400;
  10522. jw.Data = new
  10523. {
  10524. groupCost = Create.Data,
  10525. blackCodeIsTrue = false,
  10526. };
  10527. }
  10528. return Ok(jw);
  10529. }
  10530. /// <summary>
  10531. /// 成本获取OP历史车费用
  10532. /// </summary>
  10533. /// <param name="dto"></param>
  10534. /// <returns></returns>
  10535. [HttpPost]
  10536. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10537. {
  10538. var jw = JsonView(false);
  10539. try
  10540. {
  10541. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10542. //获取现有所有车的数据
  10543. if (!dto.Param.IsNullOrWhiteSpace())
  10544. {
  10545. string sql = $@"
  10546. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10547. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10548. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10549. 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
  10550. AND gctggr.ServiceEndTime is not NULL
  10551. ORDER by gctggrc.id DESC
  10552. ";
  10553. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10554. var numeberResult = await Task.Run(() =>
  10555. {
  10556. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10557. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10558. return numberArr;
  10559. });
  10560. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10561. foreach (var item in numeberResult)
  10562. {
  10563. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10564. {
  10565. Country = "数据异常!",
  10566. City = string.Empty,
  10567. };
  10568. item.Area = find.Country + " " + find.City;
  10569. }
  10570. dbResult.AddRange(numeberResult);
  10571. if (dto.Param.Contains("、"))
  10572. {
  10573. var sp = dto.Param.Split("、");
  10574. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10575. .Where(x =>
  10576. {
  10577. return System.Array.Exists(sp, e =>
  10578. {
  10579. bool where = false;
  10580. if (x.Area != null)
  10581. {
  10582. where = x.Area.Contains(e);
  10583. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10584. {
  10585. return false;
  10586. }
  10587. }
  10588. if (x.PriceName != null && !where)
  10589. {
  10590. where = x.PriceName.Contains(e);
  10591. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10592. {
  10593. return false;
  10594. }
  10595. }
  10596. return where;
  10597. });
  10598. }).ToList();
  10599. }
  10600. else
  10601. {
  10602. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10603. .Where(x =>
  10604. {
  10605. bool where = false;
  10606. if (x.Area != null)
  10607. {
  10608. where = x.Area.Contains(dto.Param);
  10609. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10610. {
  10611. return false;
  10612. }
  10613. }
  10614. if (x.PriceName != null && !where)
  10615. {
  10616. where = x.PriceName.Contains(dto.Param);
  10617. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10618. {
  10619. return false;
  10620. }
  10621. }
  10622. return where;
  10623. }
  10624. )
  10625. .ToList();
  10626. }
  10627. }
  10628. var view = dbResult.Select(x =>
  10629. {
  10630. decimal dp = 0.00M;
  10631. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10632. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10633. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10634. {
  10635. if (startB && endB)
  10636. {
  10637. var timesp = endD.Subtract(startD);
  10638. if ((timesp.Days + 1) != 0)
  10639. {
  10640. dp = x.Price / (timesp.Days + 1);
  10641. }
  10642. }
  10643. }
  10644. else
  10645. {
  10646. dp = x.Price;
  10647. }
  10648. return new
  10649. {
  10650. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10651. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10652. x.Area,
  10653. x.id,
  10654. price = x.Price.ToString("F2"),
  10655. x.PriceName,
  10656. x.PriceContent,
  10657. x.TeamName,
  10658. x.DatePrice,
  10659. dayPrice = dp.ToString("F2"),
  10660. };
  10661. }).OrderByDescending(x => x.id).ToList();
  10662. jw = JsonView(true, "获取成功!", view);
  10663. }
  10664. catch (Exception e)
  10665. {
  10666. jw = JsonView(false, e.Message);
  10667. }
  10668. return Ok(jw);
  10669. }
  10670. #endregion
  10671. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10672. /// <summary>
  10673. /// 酒店预订
  10674. /// 酒店费用列表 根据团组Id查询
  10675. /// </summary>
  10676. /// <param name="_dto"></param>
  10677. /// <returns></returns>
  10678. [HttpPost]
  10679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10680. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10681. {
  10682. #region 参数验证
  10683. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10684. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10685. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10686. #region 团组操作权限验证 76 酒店预定模块
  10687. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10688. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10689. #endregion
  10690. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10691. #region 页面操作权限验证
  10692. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10693. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10694. #endregion
  10695. #endregion
  10696. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10697. }
  10698. /// <summary>
  10699. /// 酒店预订
  10700. /// 基础数据
  10701. /// </summary>
  10702. /// <param name="_dto"></param>
  10703. /// <returns></returns>
  10704. [HttpPost]
  10705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10706. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10707. {
  10708. #region 参数验证
  10709. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10710. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10711. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10712. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10713. #region 页面操作权限验证
  10714. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10715. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10716. #endregion
  10717. #region 团组操作权限验证 76 酒店预定模块
  10718. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10719. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10720. #endregion
  10721. #endregion
  10722. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10723. }
  10724. /// <summary>
  10725. /// 酒店预订
  10726. /// 创建 入住卷号码
  10727. /// </summary>
  10728. /// <param name="_dto"></param>
  10729. /// <returns></returns>
  10730. [HttpPost]
  10731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10732. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10733. {
  10734. #region 参数验证
  10735. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10736. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10737. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10738. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10739. #region 页面操作权限验证
  10740. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10741. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10742. #endregion
  10743. #region 团组操作权限验证 76 酒店预定模块
  10744. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10745. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10746. #endregion
  10747. #endregion
  10748. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10749. if (data.Code != 0)
  10750. {
  10751. return Ok(JsonView(false, data.Msg));
  10752. }
  10753. return Ok(JsonView(true, data.Msg, data.Data));
  10754. }
  10755. /// <summary>
  10756. /// 酒店预订
  10757. /// 详情
  10758. /// </summary>
  10759. /// <param name="_dto"></param>
  10760. /// <returns></returns>
  10761. [HttpPost]
  10762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10763. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10764. {
  10765. #region 参数验证
  10766. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10767. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10768. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10769. #region 团组操作权限验证 76 酒店预定模块
  10770. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10771. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10772. #endregion
  10773. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10774. #region 页面操作权限验证
  10775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10776. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10777. #endregion
  10778. #endregion
  10779. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10780. }
  10781. /// <summary>
  10782. /// 酒店预订
  10783. /// Add Or Edit
  10784. /// </summary>
  10785. /// <param name="_dto"></param>
  10786. /// <returns></returns>
  10787. [HttpPost]
  10788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10789. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10790. {
  10791. #region 参数验证
  10792. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10793. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10794. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10795. #region 团组操作权限验证 76 酒店预定模块
  10796. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10797. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10798. #endregion
  10799. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10800. #region 页面操作权限验证
  10801. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10802. if (_dto.Id == 0) // Add
  10803. {
  10804. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10805. }
  10806. else if (_dto.Id > 1) // Edit
  10807. {
  10808. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10809. }
  10810. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10811. #endregion
  10812. #endregion
  10813. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10814. if (_view.Code != 200)
  10815. {
  10816. return Ok(_view);
  10817. }
  10818. #region 成本无酒店价格数据进入超支
  10819. _sqlSugar.BeginTran();
  10820. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10821. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10822. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10823. for (int i = 0; i < groupCost.Count; i++)
  10824. {
  10825. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10826. {
  10827. groupCost[i].Date = groupCost[i - 1].Date;
  10828. }
  10829. }
  10830. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10831. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10832. List<Fin_GroupExtraCostDto_OP>();
  10833. if (start_Bool && end_Bool)
  10834. {
  10835. while (start_Time < end_Time)
  10836. {
  10837. foreach (var item in groupCost_Grp)
  10838. {
  10839. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10840. {
  10841. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10842. {
  10843. extraCostList.Add(new
  10844. Fin_GroupExtraCostDto_OP
  10845. {
  10846. Area = _dto.AreaId,
  10847. coefficient = 1.5M,
  10848. createUser = _dto.UserId,
  10849. currency = _dto.CardPriceCurrency,
  10850. diId = _dto.DiId,
  10851. ManagerConfirm = 0,
  10852. SupervisorConfirm = 0,
  10853. SYsupervisorConfirm = 0,
  10854. editType = 1,
  10855. PortType = 1,
  10856. price = _dto.CardPrice,
  10857. PriceCount = 1,
  10858. priceType = 1027,
  10859. priceDetailType = 1044,
  10860. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10861. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10862. });
  10863. }
  10864. }
  10865. }
  10866. start_Time = start_Time.AddDays(1);
  10867. }
  10868. }
  10869. if (extraCostList.Any())
  10870. {
  10871. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10872. }
  10873. _sqlSugar.CommitTran();
  10874. #endregion
  10875. #region 应用推送
  10876. try
  10877. {
  10878. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10879. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10880. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10881. var diId = _dto.DiId;
  10882. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10883. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10884. #region 操作记录
  10885. var opInfo = new Crm_TableOperationRecord() {
  10886. TableName = "Grp_HotelReservations",
  10887. PortType = _dto.PortType,
  10888. DataId = hotelId,
  10889. CreateUserId = _dto.UserId
  10890. };
  10891. var opStatus = OperationEnum.NoOperation;
  10892. if (_dto.Id<1) //添加操作
  10893. {
  10894. opInfo.OperationItem = OperationEnum.Add;
  10895. }
  10896. else if (_dto.Id > 0)
  10897. {
  10898. opInfo.OperationItem = OperationEnum.Edit;
  10899. }
  10900. string opRemark = string.Empty;
  10901. if (ccpInfo != null)
  10902. {
  10903. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10904. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10905. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10906. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10907. }
  10908. opInfo.Remark = opRemark;
  10909. await _tableorRep.AddAsync(opInfo);
  10910. #endregion
  10911. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10912. //2024-10-21 新增LZ UID
  10913. var userIds = new List<int>() { 21 };
  10914. string title = $"费用审核";
  10915. string content = "";
  10916. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10917. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10918. try
  10919. {
  10920. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10921. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  10922. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  10923. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  10924. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  10925. }
  10926. catch (Exception ex )
  10927. {
  10928. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  10929. }
  10930. }
  10931. catch (Exception ex)
  10932. {
  10933. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  10934. }
  10935. try
  10936. {
  10937. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10938. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10939. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10940. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10941. //自动审核
  10942. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  10943. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  10944. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  10945. //2024-10-21 新增LZ UID
  10946. var userIds = new List<int>() { 21 };
  10947. string title = $"系统通知";
  10948. var diId = _dto.DiId;
  10949. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10950. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10951. string content = "";
  10952. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10953. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10954. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10955. }
  10956. catch (Exception ex)
  10957. {
  10958. }
  10959. #endregion
  10960. return Ok(_view);
  10961. }
  10962. /// <summary>
  10963. /// 酒店自动审核测试
  10964. /// Add Or Edit
  10965. /// </summary>
  10966. /// <param name="_dto"></param>
  10967. /// <returns></returns>
  10968. [HttpPost]
  10969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10970. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  10971. {
  10972. #region 应用推送
  10973. try
  10974. {
  10975. //自动审核
  10976. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  10977. }
  10978. catch (Exception ex)
  10979. {
  10980. return Ok(JsonView(false, "操作失败"));
  10981. }
  10982. #endregion
  10983. return Ok(JsonView(false, "操作成功"));
  10984. }
  10985. /// <summary>
  10986. /// 酒店预订
  10987. /// Del
  10988. /// </summary>
  10989. /// <param name="_dto"></param>
  10990. /// <returns></returns>
  10991. [HttpPost]
  10992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10993. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  10994. {
  10995. #region 参数验证
  10996. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10997. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10998. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10999. #region 团组操作权限验证 76 酒店预定模块
  11000. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11001. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11002. #endregion
  11003. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11004. #region 页面操作权限验证
  11005. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11006. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11007. #endregion
  11008. #endregion
  11009. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  11010. #region 操作记录
  11011. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11012. {
  11013. TableName = "Grp_HotelReservations",
  11014. PortType = _dto.PortType,
  11015. OperationItem = OperationEnum.Del,
  11016. DataId = _dto.Id,
  11017. CreateUserId = _dto.UserId
  11018. });
  11019. #endregion
  11020. return Ok(data);
  11021. }
  11022. /// <summary>
  11023. /// 酒店预订
  11024. /// 生成VOUCHER
  11025. /// 2024.05.06 之前版本
  11026. /// </summary>
  11027. /// <param name="_dto"></param>
  11028. /// <returns></returns>
  11029. [HttpPost]
  11030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11031. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11032. {
  11033. try
  11034. {
  11035. #region 参数验证
  11036. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11037. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11038. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11039. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11040. #region 团组操作权限验证 76 酒店预定模块
  11041. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11042. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11043. #endregion
  11044. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11045. #region 页面操作权限验证
  11046. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11047. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11048. #endregion
  11049. #endregion
  11050. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11051. //判断数据是否完整
  11052. if (hr != null)
  11053. {
  11054. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11055. {
  11056. string strFileName = "HotelStatement/";
  11057. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11058. if (dele != null)
  11059. strFileName += dele.TourCode;
  11060. //载入模板
  11061. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11062. Document doc = new Document(sss);
  11063. DocumentBuilder builder = new DocumentBuilder(doc);
  11064. #region 替换Word模板书签内容
  11065. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11066. //入住卷预定号码
  11067. if (doc.Range.Bookmarks["VNO"] != null)
  11068. {
  11069. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11070. mark.Text = hr.CheckNumber;
  11071. }
  11072. //酒店时间
  11073. if (doc.Range.Bookmarks["Date"] != null)
  11074. {
  11075. Bookmark mark = doc.Range.Bookmarks["Date"];
  11076. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11077. }
  11078. //团号
  11079. if (doc.Range.Bookmarks["TNo"] != null)
  11080. {
  11081. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11082. mark.Text = dele.TourCode;
  11083. }
  11084. //预定号码
  11085. if (doc.Range.Bookmarks["BookingId"] != null)
  11086. {
  11087. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11088. mark.Text = hr.ReservationsNo;
  11089. }
  11090. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11091. {
  11092. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11093. mark.Text = hr.DetermineNo;
  11094. }
  11095. //酒店城市
  11096. if (doc.Range.Bookmarks["City"] != null)
  11097. {
  11098. Bookmark mark = doc.Range.Bookmarks["City"];
  11099. mark.Text = hr.City;
  11100. }
  11101. //酒店名称
  11102. if (doc.Range.Bookmarks["HName"] != null)
  11103. {
  11104. Bookmark mark = doc.Range.Bookmarks["HName"];
  11105. mark.Text = hr.HotelName;
  11106. }
  11107. //酒店地址
  11108. if (doc.Range.Bookmarks["Address"] != null)
  11109. {
  11110. Bookmark mark = doc.Range.Bookmarks["Address"];
  11111. mark.Text = hr.HotelAddress;
  11112. }
  11113. //酒店电话
  11114. if (doc.Range.Bookmarks["Tel"] != null)
  11115. {
  11116. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11117. mark.Text = hr.HotelTel;
  11118. }
  11119. //酒店传真
  11120. if (doc.Range.Bookmarks["Fax"] != null)
  11121. {
  11122. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11123. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11124. {
  11125. mark.Text = hr.HotelFax;
  11126. }
  11127. }
  11128. //入住时间
  11129. if (doc.Range.Bookmarks["CIn"] != null)
  11130. {
  11131. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11132. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11133. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11134. }
  11135. //退房时间
  11136. if (doc.Range.Bookmarks["COut"] != null)
  11137. {
  11138. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11139. Bookmark mark = doc.Range.Bookmarks["COut"];
  11140. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11141. }
  11142. //客户名称
  11143. if (doc.Range.Bookmarks["GName"] != null)
  11144. {
  11145. string guestName = "";
  11146. string[] clients = new string[] { };
  11147. if (hr.GuestName.Contains(","))
  11148. {
  11149. clients = hr.GuestName.Split(",");
  11150. }
  11151. else
  11152. {
  11153. clients = new string[] { hr.GuestName };
  11154. }
  11155. List<int> clientIds_int = new List<int>();
  11156. if (clients.Length > 0)
  11157. {
  11158. foreach (var item in clients)
  11159. {
  11160. if (item.IsNumeric())
  11161. {
  11162. clientIds_int.Add(int.Parse(item));
  11163. }
  11164. }
  11165. }
  11166. if (clientIds_int.Count > 0)
  11167. {
  11168. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11169. foreach (var client in _clientDatas)
  11170. {
  11171. //男
  11172. if (client.Sex == 0) guestName += $"Mr.";
  11173. //女
  11174. else if (client.Sex == 1) guestName += $"Ms.";
  11175. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11176. {
  11177. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11178. }
  11179. //guestName += $"{client.Pinyin},";
  11180. }
  11181. if (guestName.Length > 0)
  11182. {
  11183. guestName = guestName.Substring(0, guestName.Length - 1);
  11184. }
  11185. }
  11186. else
  11187. {
  11188. guestName = hr.GuestName;
  11189. }
  11190. Bookmark mark = doc.Range.Bookmarks["GName"];
  11191. mark.Text = guestName;
  11192. }
  11193. //房间介绍
  11194. if (doc.Range.Bookmarks["ROOM"] != null)
  11195. {
  11196. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11197. mark.Text = hr.RoomExplanation;
  11198. }
  11199. //报价描述
  11200. if (doc.Range.Bookmarks["NOTE"] != null)
  11201. {
  11202. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11203. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11204. if (ss != null)
  11205. mark.Text = ss.Name;
  11206. }
  11207. //入住时间
  11208. if (doc.Range.Bookmarks["CheckIn"] != null)
  11209. {
  11210. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11211. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11212. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11213. }
  11214. //退房时间
  11215. if (doc.Range.Bookmarks["CheckOut"] != null)
  11216. {
  11217. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11218. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11219. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11220. }
  11221. //日期
  11222. if (doc.Range.Bookmarks["DT"] != null)
  11223. {
  11224. Bookmark mark = doc.Range.Bookmarks["DT"];
  11225. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11226. }
  11227. //名称
  11228. if (doc.Range.Bookmarks["VName"] != null)
  11229. {
  11230. Bookmark mark = doc.Range.Bookmarks["VName"];
  11231. mark.Text = hr.HotelName;
  11232. }
  11233. //号码
  11234. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11235. {
  11236. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11237. mark.Text = hr.CheckNumber;
  11238. }
  11239. #endregion
  11240. strFileName += "VOUCHER.doc";
  11241. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11242. doc.Save(fileDir);
  11243. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11244. return Ok(JsonView(true, "操作成功!", Url));
  11245. }
  11246. else
  11247. {
  11248. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11249. }
  11250. }
  11251. else
  11252. {
  11253. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11254. }
  11255. }
  11256. catch (Exception ex)
  11257. {
  11258. return Ok(JsonView(false, ex.Message));
  11259. }
  11260. }
  11261. /// <summary>
  11262. /// 酒店预订
  11263. /// 生成VOUCHER
  11264. /// 2024.05.06 之后版本
  11265. /// </summary>
  11266. /// <param name="_dto"></param>
  11267. /// <returns></returns>
  11268. [HttpPost]
  11269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11270. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11271. {
  11272. #region 参数验证
  11273. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11274. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11275. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11276. #region 团组操作权限验证 76 酒店预定模块
  11277. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11278. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11279. #endregion
  11280. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11281. #region 页面操作权限验证
  11282. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11283. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11284. #endregion
  11285. #endregion
  11286. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11287. //判断数据是否完整
  11288. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11289. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11290. string strFileName = "HotelStatement/";
  11291. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11292. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11293. #region 数据处理
  11294. List<int> guestIds = new List<int>();
  11295. int index = 0;
  11296. foreach (var item in hrDtas)
  11297. {
  11298. if (item.GuestName.Contains(","))
  11299. {
  11300. string[] guestIdArr = item.GuestName.Split(',');
  11301. foreach (var guestIdStr in guestIdArr)
  11302. {
  11303. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11304. if (guestBool)
  11305. {
  11306. guestIds.Add(guestId);
  11307. }
  11308. }
  11309. }
  11310. else guestNames += item.GuestName;
  11311. var voucherInfo = new HotelVoucherInfoView()
  11312. {
  11313. HotelName = item.HotelName,
  11314. CheckInDate = item.CheckInDate,
  11315. CheckOutDate = item.CheckOutDate,
  11316. ConfirmationNumber = item.DetermineNo.Trim(),
  11317. RoomType = item.RoomExplanation
  11318. };
  11319. vouchers.Add(voucherInfo);
  11320. }
  11321. if (guestIds.Count > 0)
  11322. {
  11323. guestIds = guestIds.Distinct().ToList();
  11324. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11325. if (guestDatas.Count > 0)
  11326. {
  11327. guestNames = "";
  11328. foreach (var guest in guestDatas)
  11329. {
  11330. string guestName = "";
  11331. if (guest.Sex == 0) guestName += @"MR.";
  11332. else if (guest.Sex == 1) guestName += @"MS.";
  11333. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11334. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11335. guestNames += @$"{guestName.Trim()}、";
  11336. }
  11337. if (guestNames.Length > 0)
  11338. {
  11339. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11340. }
  11341. }
  11342. }
  11343. #endregion
  11344. //载入模板
  11345. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11346. Document doc = new Document(sss);
  11347. DocumentBuilder builder = new DocumentBuilder(doc);
  11348. if (doc.Range.Bookmarks["GuestName"] != null)
  11349. {
  11350. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11351. mark.Text = guestNames;
  11352. }
  11353. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11354. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11355. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11356. for (int i = 1; i <= vouchers.Count; i++)
  11357. {
  11358. HotelVoucherInfoView hviv = vouchers[i - 1];
  11359. builder.MoveToCell(0, i, 0, 0);
  11360. builder.Write(hviv.HotelName);
  11361. builder.MoveToCell(0, i, 1, 0);
  11362. builder.Write(hviv.CheckInDate);
  11363. builder.MoveToCell(0, i, 2, 0);
  11364. builder.Write(hviv.CheckOutDate);
  11365. builder.MoveToCell(0, i, 3, 0);
  11366. builder.Write(hviv.RoomType);
  11367. builder.MoveToCell(0, i, 4, 0);
  11368. builder.Write(hviv.ConfirmationNumber);
  11369. }
  11370. //删除多余行
  11371. int currRowIndex = vouchers.Count + 1;
  11372. int delRows = 21 - currRowIndex;
  11373. if (delRows > 0)
  11374. {
  11375. for (int i = 0; i < delRows; i++)
  11376. {
  11377. table.Rows.RemoveAt(currRowIndex);
  11378. //cultivateRowIndex++;
  11379. }
  11380. }
  11381. strFileName += "VOUCHER.docx";
  11382. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11383. doc.Save(fileDir);
  11384. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11385. return Ok(JsonView(true, "操作成功!", Url));
  11386. }
  11387. /// <summary>
  11388. /// 酒店预订
  11389. /// 生成VOUCHER 批量生成
  11390. /// New
  11391. /// </summary>
  11392. /// <param name="_dto"></param>
  11393. /// <returns></returns>
  11394. [HttpPost]
  11395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11396. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11397. {
  11398. #region 参数验证
  11399. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11400. if (_dto.PageId < 1) _dto.PageId = 28;
  11401. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11402. #region 团组操作权限验证 76 酒店预定模块
  11403. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11404. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11405. #endregion
  11406. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11407. #region 页面操作权限验证
  11408. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11409. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11410. #endregion
  11411. #endregion
  11412. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11413. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11414. .OrderBy(x => x.CheckInDate)
  11415. .ToListAsync();
  11416. //判断数据是否完整
  11417. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11418. string strFileName = "HotelStatement/";
  11419. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11420. if (dele != null)
  11421. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11422. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  11423. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  11424. .Where(it => it.IsDel == 0)
  11425. .ToListAsync();
  11426. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  11427. for (int i = 0; i < hrDtas.Count; i++)
  11428. {
  11429. string guestNames = string.Empty;
  11430. List<int> guestIds = new List<int>();
  11431. var item = hrDtas[i];
  11432. //处理客户姓名
  11433. if (item.GuestName.Contains(","))
  11434. {
  11435. string[] guestIdArr = item.GuestName.Split(',');
  11436. foreach (var guestIdStr in guestIdArr)
  11437. if (int.TryParse(guestIdStr, out int guestId))
  11438. guestIds.Add(guestId);
  11439. }
  11440. else
  11441. {
  11442. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11443. if (guestIdBool)
  11444. {
  11445. guestIds.Add(guestId);
  11446. }
  11447. //NaN
  11448. if (item.GuestName.Contains("NaN"))
  11449. {
  11450. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11451. }
  11452. }
  11453. if (guestIds.Count > 0)
  11454. {
  11455. guestIds = guestIds.Distinct().ToList();
  11456. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11457. if (guestDatas1.Count > 0)
  11458. {
  11459. guestNames = "";
  11460. foreach (var guest in guestDatas1)
  11461. {
  11462. string guestName = "";
  11463. if (guest.Sex == 0) guestName += @"MR.";
  11464. else if (guest.Sex == 1) guestName += @"MS.";
  11465. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11466. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11467. guestNames += @$"{guestName.Trim()}、";
  11468. }
  11469. if (guestNames.Length > 0)
  11470. {
  11471. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11472. }
  11473. }
  11474. }
  11475. //if (!string.IsNullOrEmpty(guestNames))
  11476. //{
  11477. hrDtas[i].GuestName = guestNames;
  11478. //}
  11479. }
  11480. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11481. Document doc = new Document();
  11482. DocumentBuilder builder = new DocumentBuilder(doc);
  11483. try
  11484. {
  11485. builder.MoveToDocumentStart();
  11486. foreach (var item in hrDtas)
  11487. {
  11488. //标题
  11489. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11490. builder.ParagraphFormat.LineSpacing = 1;
  11491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11492. builder.ParagraphFormat.Style.Font.Size = 9;
  11493. builder.ParagraphFormat.Style.Font.Bold = true;
  11494. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11495. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11496. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11497. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11498. builder.ParagraphFormat.LineSpacing = 1;
  11499. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11500. builder.ParagraphFormat.Style.Font.Size = 9;
  11501. builder.ParagraphFormat.Style.Font.Bold = true;
  11502. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11503. builder.StartTable();
  11504. // 设置边框颜色
  11505. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11506. //设置边框样式
  11507. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11508. //表格
  11509. #region 第一行
  11510. builder.InsertCell();
  11511. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11512. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11513. //builder.CellFormat.AllowAutoFit = false;
  11514. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11515. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11516. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11517. builder.CellFormat.WrapText = true; //自动换行
  11518. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11519. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11520. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11521. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11522. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11523. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11524. builder.Write("TOUR NO:");
  11525. builder.InsertCell();
  11526. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11527. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11528. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11529. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11530. builder.ParagraphFormat.Style.Font.Bold = false;
  11531. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11532. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11533. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11534. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11535. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11536. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11537. builder.Write($"{dele?.TourCode ?? "-"}");
  11538. builder.InsertCell();
  11539. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11540. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11541. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11542. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11543. builder.ParagraphFormat.Style.Font.Bold = false;
  11544. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11545. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11546. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11547. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11548. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11549. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11550. builder.Write($"CITY:");
  11551. builder.InsertCell();
  11552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11553. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11554. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11555. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11556. builder.ParagraphFormat.Style.Font.Bold = false;
  11557. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11558. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11559. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11560. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11561. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11562. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11563. builder.Write($"{item.City}");
  11564. builder.EndRow();
  11565. #endregion
  11566. #region 第二行
  11567. builder.InsertCell();
  11568. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11569. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11570. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11571. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11572. builder.ParagraphFormat.Style.Font.Bold = false;
  11573. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11574. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11575. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11576. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11577. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11578. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11579. builder.Write("CONFIRMATION NO:");
  11580. builder.InsertCell();
  11581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11582. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11583. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11584. builder.ParagraphFormat.Style.Font.Bold = false;
  11585. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11586. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11587. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11588. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11589. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11590. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11591. builder.CellFormat.VerticalMerge = CellMerge.None;
  11592. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11593. builder.Write($"{item.DetermineNo}");
  11594. builder.InsertCell();
  11595. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11596. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11597. builder.InsertCell();
  11598. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11599. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11600. builder.EndRow();
  11601. #endregion
  11602. #region 第三行
  11603. builder.InsertCell();
  11604. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11605. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11606. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11607. builder.ParagraphFormat.Style.Font.Bold = false;
  11608. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11609. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11611. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11612. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11613. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11614. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11615. builder.Write($"HOTEL NAME:");
  11616. builder.InsertCell();
  11617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11618. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11619. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11620. builder.ParagraphFormat.Style.Font.Bold = false;
  11621. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11622. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11623. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11624. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11625. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11626. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11627. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11628. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11629. builder.Write($"{item.HotelName}");
  11630. builder.InsertCell();
  11631. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11632. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11633. builder.InsertCell();
  11634. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11635. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11636. builder.EndRow();
  11637. #endregion
  11638. #region 第四行
  11639. builder.InsertCell();
  11640. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11641. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11642. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11643. builder.ParagraphFormat.Style.Font.Bold = false;
  11644. builder.CellFormat.HorizontalMerge = CellMerge.None;
  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($"HOTEL ADDRESS:");
  11652. builder.InsertCell();
  11653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11654. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11655. builder.ParagraphFormat.Style.Font.Size = 8;
  11656. builder.ParagraphFormat.Style.Font.Bold = false;
  11657. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11658. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11659. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11660. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11661. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11662. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11663. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11664. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11665. builder.Write($"{item.HotelAddress}");
  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("TEL:");
  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.Write($"{item.HotelTel}");
  11701. builder.InsertCell();
  11702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11703. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11704. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11705. builder.ParagraphFormat.Style.Font.Bold = false;
  11706. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11707. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11708. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11709. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11710. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11711. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11712. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11713. builder.Write($"FAX:");
  11714. builder.InsertCell();
  11715. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11716. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11717. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11718. builder.ParagraphFormat.Style.Font.Bold = false;
  11719. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11720. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11721. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11722. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11723. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11724. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11725. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11726. builder.Write($"{item.HotelFax}");
  11727. builder.EndRow();
  11728. #endregion
  11729. #region 第六行
  11730. builder.InsertCell();
  11731. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11732. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11733. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11734. builder.ParagraphFormat.Style.Font.Bold = false;
  11735. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11736. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11737. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11738. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11739. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11740. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11741. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11742. builder.Write("CHECK IN:");
  11743. builder.InsertCell();
  11744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11746. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11747. builder.ParagraphFormat.Style.Font.Bold = false;
  11748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11751. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11752. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11753. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11754. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11755. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11756. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11757. builder.Write($"{checkInStr}");
  11758. builder.InsertCell();
  11759. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11760. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11761. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11762. builder.ParagraphFormat.Style.Font.Bold = false;
  11763. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11764. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11765. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11766. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11767. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11768. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11769. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11770. builder.Write($"CHECK OUT:");
  11771. builder.InsertCell();
  11772. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11773. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11774. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11775. builder.ParagraphFormat.Style.Font.Bold = false;
  11776. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11777. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11778. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11779. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11780. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11781. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11782. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11783. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11784. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11785. builder.Write($"{checkOutStr}");
  11786. builder.EndRow();
  11787. #endregion
  11788. #region 第七行
  11789. builder.InsertCell();
  11790. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11791. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11792. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11793. builder.ParagraphFormat.Style.Font.Bold = false;
  11794. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11795. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11796. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11797. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11798. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11799. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11800. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11801. builder.Write($"GUEST NAME:");
  11802. builder.InsertCell();
  11803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11804. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11805. builder.ParagraphFormat.Style.Font.Size = 8;
  11806. builder.ParagraphFormat.Style.Font.Bold = false;
  11807. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11808. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11809. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  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.CellFormat.HorizontalMerge = CellMerge.First;
  11815. builder.Write($"{item.GuestName}");
  11816. builder.InsertCell();
  11817. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11818. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11819. builder.InsertCell();
  11820. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11821. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11822. builder.EndRow();
  11823. #endregion
  11824. #region 第八行
  11825. builder.InsertCell();
  11826. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11827. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11828. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11829. builder.ParagraphFormat.Style.Font.Bold = false;
  11830. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11831. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11832. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11833. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11834. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11835. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11836. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11837. builder.Write($"ROOM TYPE:");
  11838. builder.InsertCell();
  11839. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11840. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11841. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11842. builder.ParagraphFormat.Style.Font.Bold = false;
  11843. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11844. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11845. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11846. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11847. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11848. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11849. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11850. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11851. builder.Write($"{item.RoomExplanation}");
  11852. builder.InsertCell();
  11853. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11854. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11855. builder.InsertCell();
  11856. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11857. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  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($"NOTE:");
  11874. builder.InsertCell();
  11875. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11876. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11877. builder.ParagraphFormat.Style.Font.Size = 7.5;
  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.CellFormat.HorizontalMerge = CellMerge.First;
  11883. 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.");
  11884. builder.InsertCell();
  11885. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11886. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11887. builder.InsertCell();
  11888. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11889. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11890. builder.EndRow();
  11891. #endregion
  11892. builder.EndTable();
  11893. //换行
  11894. builder.Writeln("");
  11895. builder.Writeln("");
  11896. }
  11897. #region 获取文档中的所有表格 设置文字自适应
  11898. // 获取文档中的所有表格。
  11899. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11900. {
  11901. // 遍历表格中的所有行。
  11902. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11903. {
  11904. foreach (Cell cell in row.Cells)
  11905. {
  11906. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11907. cellFormat.Width = 0;
  11908. }
  11909. }
  11910. }
  11911. #endregion
  11912. #region 设置页眉
  11913. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11914. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11915. if (System.IO.File.Exists(voucherHeaderPath))
  11916. {
  11917. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11918. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11919. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11920. Shape shape = builder.InsertImage(imageBytes);
  11921. // 调整图片位置
  11922. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  11923. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  11924. shape.Top = 50; // 将图片距离页眉上边缘的距离
  11925. shape.Left = 0; // 将图片距离页面左边缘的距离
  11926. shape.Width = 81; // 设置图片宽度
  11927. shape.Height = 36; // 设置图片高度
  11928. }
  11929. //靠右
  11930. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  11931. //// 设置页脚上下边距
  11932. //builder.PageSetup.HeaderDistance = 42;
  11933. // 添加页眉线
  11934. Aspose.Words.Border borderHeader = null;
  11935. try
  11936. {
  11937. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  11938. }
  11939. catch (Exception e)
  11940. {
  11941. // TODO Auto-generated catch block
  11942. //e.printStackTrace();
  11943. }
  11944. borderHeader.Shadow = true;
  11945. borderHeader.DistanceFromText = 2;
  11946. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  11947. #endregion
  11948. }
  11949. catch (Exception ex)
  11950. {
  11951. }
  11952. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11953. doc.Save(fileDir);
  11954. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11955. return Ok(JsonView(true, "操作成功!", Url));
  11956. }
  11957. /// <summary>
  11958. /// 酒店预订
  11959. /// 生成 预定成本 Excel
  11960. /// </summary>
  11961. /// <param name="_dto"></param>
  11962. /// <returns></returns>
  11963. [HttpPost]
  11964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11965. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  11966. {
  11967. #region 参数验证
  11968. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  11969. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  11970. if (!vadalitorRes.IsValid)
  11971. {
  11972. var errors = new StringBuilder();
  11973. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  11974. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  11975. }
  11976. #region 团组操作权限验证 76 酒店预定模块
  11977. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11978. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11979. #endregion
  11980. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11981. #region 页面操作权限验证
  11982. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11983. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11984. #endregion
  11985. #endregion
  11986. decimal _rate = 1.00M;
  11987. string _currency = string.Empty;
  11988. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  11989. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11990. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  11991. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11992. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  11993. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  11994. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  11995. if (_GroupCostParameter == null)
  11996. {
  11997. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  11998. bool isIntType = int.TryParse(_currency, out int currId);
  11999. if (isIntType)
  12000. {
  12001. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12002. }
  12003. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12004. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12005. if (currInfo == null)
  12006. {
  12007. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12008. }
  12009. else _rate = currInfo.Rate;
  12010. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12011. {
  12012. _rate = _GroupCostParameter.Rate;
  12013. }
  12014. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12015. string strFileName = "HotelStatement/";
  12016. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12017. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12018. var rateDatas = new List<dynamic>();
  12019. #region 数据处理
  12020. foreach (var item in hrDtas)
  12021. {
  12022. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12023. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12024. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12025. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12026. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12027. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12028. {
  12029. continue;
  12030. }
  12031. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12032. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12033. string singleRoomFeeStr = string.Empty,
  12034. doubleRoomFeeStr = string.Empty,
  12035. suiteRoomFeeStr = string.Empty,
  12036. otherRoomFeeStr = string.Empty,
  12037. payMoneyStr = string.Empty,
  12038. cardPriceStr = string.Empty;
  12039. if (roomCurr.Equals("CNY"))
  12040. {
  12041. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12042. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12043. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12044. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12045. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12046. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12047. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12048. }
  12049. else
  12050. {
  12051. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12052. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12053. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12054. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12055. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12056. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12057. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12058. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12059. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12060. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12061. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12062. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12063. if (ccpPaymentCurrency.Equals("CNY"))
  12064. {
  12065. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12066. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12067. }
  12068. else
  12069. {
  12070. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12071. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12072. }
  12073. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12074. if (hotelcardPriceCurrency.Equals("CNY"))
  12075. {
  12076. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12077. }
  12078. else
  12079. {
  12080. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12081. }
  12082. }
  12083. string breakfastPriceStr = string.Empty,
  12084. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12085. governmentRentStr = string.Empty,
  12086. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12087. cityTaxStr = string.Empty,
  12088. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12089. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12090. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12091. {
  12092. if (breakfastCurrency1.Equals("CNY"))
  12093. {
  12094. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12095. }
  12096. else
  12097. {
  12098. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12099. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12100. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12101. }
  12102. }
  12103. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12104. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12105. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12106. {
  12107. if (governmentRentCurrency.Equals("CNY"))
  12108. {
  12109. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12110. }
  12111. else
  12112. {
  12113. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12114. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12115. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12116. }
  12117. }
  12118. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12119. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12120. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12121. {
  12122. if (cityTaxStrCurrency1.Equals("CNY"))
  12123. {
  12124. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12125. }
  12126. else
  12127. {
  12128. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12129. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12130. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12131. }
  12132. }
  12133. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12134. int payDId = roomInfo?.PayDId ?? 0;
  12135. pcfds.Add(new HotelReservations_PCFD_View()
  12136. {
  12137. City = item.City,
  12138. HotelName = item.HotelName,
  12139. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12140. // SingleRoomCount = item.SingleRoomCount,
  12141. SingleRoomPrice = singleRoomFeeStr,
  12142. // DoubleRoomCount = item.DoubleRoomCount,
  12143. DoubleRoomPrice = doubleRoomFeeStr,
  12144. //SuiteRoomCount = item.SuiteRoomCount,
  12145. SuiteRoomPrice = suiteRoomFeeStr,
  12146. OtherRoomPrice = otherRoomFeeStr,
  12147. //OtherRoomCount = item.OtherRoomCount,
  12148. BreakfastPrice = breakfastPriceStr,
  12149. GovernmentRent = governmentRentStr,
  12150. CityTax = cityTaxStr,
  12151. RoomExplanation = item.RoomExplanation,
  12152. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12153. PayTime = roomInfo?.ConsumptionDate,
  12154. BankNo = roomInfo?.BankNo,
  12155. PayMoney = payMoneyStr,
  12156. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12157. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12158. CardPrice = cardPriceStr,
  12159. Remark = ccpInfo.Remark
  12160. });
  12161. }
  12162. #endregion
  12163. //载入模板
  12164. WorkbookDesigner designer = new WorkbookDesigner();
  12165. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12166. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12167. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12168. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12169. var rateDatas1 = rateDatas.Distinct();
  12170. var rateStr = string.Empty;
  12171. foreach (var item in rateDatas1)
  12172. {
  12173. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12174. }
  12175. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12176. designer.SetDataSource("Opertor", userInfo.CnName);
  12177. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12178. dt.TableName = "ViewMyHotelReservations";
  12179. designer.SetDataSource(dt);
  12180. designer.Process();
  12181. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12182. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12183. designer.Workbook.Save(serverPath);
  12184. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12185. #region 删除指定行
  12186. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12187. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12188. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12189. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12190. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12191. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12192. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12193. cssIndex = dt.Columns["CityTax"].Ordinal,
  12194. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12195. remarkIndex = dt.Columns["Remark"].Ordinal;
  12196. //删除指定列
  12197. foreach (DataRow item in dt.Rows)
  12198. {
  12199. string singleStr = item["SingleRoomPrice"].ToString();
  12200. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12201. if (containsDigitButNotZero1) singleDel = false;
  12202. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12203. string doubleStr = item["DoubleRoomPrice"].ToString();
  12204. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12205. if (containsDigitButNotZero2) doubleDel = false;
  12206. string suiteStr = item["SuiteRoomPrice"].ToString();
  12207. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12208. if (containsDigitButNotZero3) suiteDel = false;
  12209. string otherStr = item["OtherRoomPrice"].ToString();
  12210. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12211. if (containsDigitButNotZero4) otherDel = false;
  12212. string zcStr = item["BreakfastPrice"].ToString();
  12213. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12214. if (containsDigitButNotZero5) zcDel = false;
  12215. string dsStr = item["GovernmentRent"].ToString();
  12216. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12217. if (containsDigitButNotZero6) dsDel = false;
  12218. string cssStr = item["CityTax"].ToString();
  12219. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12220. if (containsDigitButNotZero7) cssDel = false;
  12221. string cpStr = item["ConsumptionPatterns"].ToString();
  12222. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12223. string remarkStr = item["Remark"].ToString();
  12224. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12225. }
  12226. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12227. DeleteColumn(serverPath, cpIndex, cpDel);
  12228. DeleteColumn(serverPath, dsIndex, dsDel);
  12229. DeleteColumn(serverPath, cssIndex, cssDel);
  12230. DeleteColumn(serverPath, zcIndex, zcDel);
  12231. DeleteColumn(serverPath, otherIndex, otherDel);
  12232. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12233. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12234. DeleteColumn(serverPath, singleIndex, singleDel);
  12235. #endregion
  12236. //只保留第一个表格
  12237. DeleteSheet(serverPath);
  12238. return Ok(JsonView(true, "操作成功", url = rst));
  12239. }
  12240. else
  12241. {
  12242. _currency = _GroupCostParameter.Currency;
  12243. bool isIntType = int.TryParse(_currency, out int currId);
  12244. if (isIntType)
  12245. {
  12246. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12247. }
  12248. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12249. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12250. if (currInfo == null)
  12251. {
  12252. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12253. }
  12254. if (!_currency.ToUpper().Equals("CNY"))
  12255. {
  12256. _rate = _GroupCostParameter.Rate;
  12257. }
  12258. _rate = currInfo.Rate;
  12259. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12260. string strFileName = "HotelStatement/";
  12261. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12262. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12263. #region 数据处理
  12264. foreach (var item in hrDtas)
  12265. {
  12266. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12267. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12268. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12269. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12270. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12271. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12272. string singleRoomFeeStr = string.Empty,
  12273. doubleRoomFeeStr = string.Empty,
  12274. suiteRoomFeeStr = string.Empty,
  12275. otherRoomFeeStr = string.Empty,
  12276. payMoneyStr = string.Empty,
  12277. cardPriceStr = string.Empty;
  12278. if (roomCurr.Equals(_currency))
  12279. {
  12280. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12281. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12282. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12283. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12284. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12285. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12286. }
  12287. else
  12288. {
  12289. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12290. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12291. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12292. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12293. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12294. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12295. }
  12296. string breakfastPriceStr = string.Empty,
  12297. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12298. governmentRentStr = string.Empty,
  12299. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12300. cityTaxStrStr = string.Empty,
  12301. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12302. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12303. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12304. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12305. int payDId = roomInfo?.PayDId ?? 0;
  12306. pcfds.Add(new HotelReservations_PCFD_View()
  12307. {
  12308. City = item.City,
  12309. HotelName = item.HotelName,
  12310. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12311. // SingleRoomCount = item.SingleRoomCount,
  12312. SingleRoomPrice = singleRoomFeeStr,
  12313. // DoubleRoomCount = item.DoubleRoomCount,
  12314. DoubleRoomPrice = doubleRoomFeeStr,
  12315. //SuiteRoomCount = item.SuiteRoomCount,
  12316. SuiteRoomPrice = suiteRoomFeeStr,
  12317. OtherRoomPrice = otherRoomFeeStr,
  12318. //OtherRoomCount = item.OtherRoomCount,
  12319. BreakfastPrice = breakfastPriceStr,
  12320. GovernmentRent = governmentRentStr,
  12321. CityTax = cityTaxStrStr,
  12322. RoomExplanation = item.RoomExplanation,
  12323. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12324. PayTime = roomInfo?.ConsumptionDate,
  12325. BankNo = roomInfo?.BankNo,
  12326. PayMoney = payMoneyStr,
  12327. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12328. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12329. CardPrice = cardPriceStr,
  12330. Remark = ccpInfo.Remark
  12331. });
  12332. }
  12333. #endregion
  12334. //载入模板
  12335. WorkbookDesigner designer = new WorkbookDesigner();
  12336. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12337. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12338. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12339. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12340. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12341. designer.SetDataSource("Opertor", userInfo.CnName);
  12342. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12343. dt.TableName = "ViewMyHotelReservations";
  12344. designer.SetDataSource(dt);
  12345. designer.Process();
  12346. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12347. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12348. designer.Workbook.Save(serverPath);
  12349. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12350. #region 删除指定行
  12351. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12352. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12353. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12354. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12355. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12356. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12357. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12358. cssIndex = dt.Columns["CityTax"].Ordinal,
  12359. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12360. remarkIndex = dt.Columns["Remark"].Ordinal;
  12361. //删除指定列
  12362. foreach (DataRow item in dt.Rows)
  12363. {
  12364. string singleStr = item["SingleRoomPrice"].ToString();
  12365. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12366. if (containsDigitButNotZero1) singleDel = false;
  12367. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12368. string doubleStr = item["DoubleRoomPrice"].ToString();
  12369. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12370. if (containsDigitButNotZero2) doubleDel = false;
  12371. string suiteStr = item["SuiteRoomPrice"].ToString();
  12372. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12373. if (containsDigitButNotZero3) suiteDel = false;
  12374. string otherStr = item["OtherRoomPrice"].ToString();
  12375. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12376. if (containsDigitButNotZero4) otherDel = false;
  12377. string zcStr = item["BreakfastPrice"].ToString();
  12378. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12379. if (containsDigitButNotZero5) zcDel = false;
  12380. string dsStr = item["GovernmentRent"].ToString();
  12381. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12382. if (containsDigitButNotZero6) dsDel = false;
  12383. string cssStr = item["CityTax"].ToString();
  12384. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12385. if (containsDigitButNotZero7) cssDel = false;
  12386. string cpStr = item["ConsumptionPatterns"].ToString();
  12387. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12388. string remarkStr = item["Remark"].ToString();
  12389. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12390. }
  12391. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12392. DeleteColumn(serverPath, cpIndex, cpDel);
  12393. DeleteColumn(serverPath, dsIndex, dsDel);
  12394. DeleteColumn(serverPath, cssIndex, cssDel);
  12395. DeleteColumn(serverPath, zcIndex, zcDel);
  12396. DeleteColumn(serverPath, otherIndex, otherDel);
  12397. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12398. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12399. DeleteColumn(serverPath, singleIndex, singleDel);
  12400. #endregion
  12401. //只保留第一个表格
  12402. DeleteSheet(serverPath);
  12403. return Ok(JsonView(true, "操作成功", url = rst));
  12404. }
  12405. return Ok(JsonView(false));
  12406. }
  12407. /// <summary>
  12408. /// 删除指定列
  12409. /// </summary>
  12410. /// <param name="file"></param>
  12411. /// <param name="columnIndex"></param>
  12412. /// <param name="isDel"></param>
  12413. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12414. {
  12415. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12416. //wb.Save(file);
  12417. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12418. if (sheet1 != null)
  12419. {
  12420. if (isDel)
  12421. {
  12422. Cells cells = sheet1.Cells;
  12423. cells.DeleteColumn(columnIndex);
  12424. }
  12425. }
  12426. wb.Save(file);
  12427. }
  12428. /// <summary>
  12429. /// 删除sheet
  12430. /// </summary>
  12431. /// <param name="file"></param>
  12432. /// <param name="sheetName"></param>
  12433. private void DeleteSheet(string file, string sheetName = "")
  12434. {
  12435. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12436. //wb.Save(file);
  12437. List<string> sheets = new List<string>();
  12438. foreach (var item in wb.Worksheets)
  12439. {
  12440. sheets.Add(item.Name);
  12441. }
  12442. if (sheets.Count > 0)
  12443. {
  12444. sheets.RemoveAt(0);//不删除第一个sheet
  12445. foreach (var item in sheets)
  12446. {
  12447. wb.Worksheets.RemoveAt(item);
  12448. }
  12449. }
  12450. wb.Save(file);
  12451. }
  12452. /// <summary>
  12453. /// 酒店预订
  12454. /// 确认单
  12455. /// </summary>
  12456. /// <param name="_dto"></param>
  12457. /// <returns></returns>
  12458. [HttpPost]
  12459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12460. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12461. {
  12462. try
  12463. {
  12464. #region 参数验证
  12465. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12466. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12467. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12468. #region 团组操作权限验证 76 酒店预定模块
  12469. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12470. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12471. #endregion
  12472. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12473. #region 页面操作权限验证
  12474. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12475. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12476. #endregion
  12477. #endregion
  12478. //团组信息
  12479. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12480. //酒店数据
  12481. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12482. if (listhoteldata.Count < 0)
  12483. {
  12484. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12485. }
  12486. //利datatable存储
  12487. DataTable dt = new DataTable();
  12488. dt.Columns.Add("CheckInDate", typeof(string));
  12489. dt.Columns.Add("City", typeof(string));
  12490. dt.Columns.Add("Hotel", typeof(string));
  12491. dt.Columns.Add("Room", typeof(string));
  12492. for (int i = 0; i < listhoteldata.Count; i++)
  12493. {
  12494. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12495. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12496. while (dayStart < dayEnd)
  12497. {
  12498. string temp = "";
  12499. DataRow row = dt.NewRow();
  12500. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12501. row["City"] = listhoteldata[i].City;
  12502. row["Hotel"] = listhoteldata[i].HotelName;
  12503. if (listhoteldata[i].SingleRoomCount > 0)
  12504. {
  12505. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12506. }
  12507. if (listhoteldata[i].DoubleRoomCount > 0)
  12508. {
  12509. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12510. }
  12511. if (listhoteldata[i].SuiteRoomCount > 0)
  12512. {
  12513. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12514. }
  12515. if (listhoteldata[i].OtherRoomCount > 0)
  12516. {
  12517. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12518. }
  12519. row["Room"] = temp;
  12520. dt.Rows.Add(row);
  12521. dayStart = dayStart.AddDays(1);
  12522. }
  12523. }
  12524. Dictionary<string, string> dic = new Dictionary<string, string>();
  12525. dic.Add("Dele", di.TeamName);
  12526. dic.Add("City", di.VisitCountry);
  12527. //模板路径
  12528. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12529. //载入模板
  12530. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12531. DocumentBuilder builder = new DocumentBuilder(doc);
  12532. foreach (var key in dic.Keys)
  12533. {
  12534. builder.MoveToBookmark(key);
  12535. builder.Write(dic[key]);
  12536. }
  12537. //获取word里所有表格
  12538. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12539. //获取所填表格的序数
  12540. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12541. var rowStart = tableOne.Rows[0]; //获取第1行
  12542. //循环赋值
  12543. for (int i = 0; i < dt.Rows.Count; i++)
  12544. {
  12545. builder.MoveToCell(0, i + 1, 0, 0);
  12546. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12547. builder.MoveToCell(0, i + 1, 1, 0);
  12548. builder.Write(dt.Rows[i]["City"].ToString());
  12549. builder.MoveToCell(0, i + 1, 2, 0);
  12550. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12551. builder.MoveToCell(0, i + 1, 3, 0);
  12552. builder.Write(dt.Rows[i]["Room"].ToString());
  12553. }
  12554. //删除多余行
  12555. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12556. {
  12557. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12558. }
  12559. string strFileName = di.TeamName + "酒店确认单.doc";
  12560. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12561. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12562. return Ok(JsonView(true, "成功", url));
  12563. }
  12564. catch (Exception ex)
  12565. {
  12566. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12567. }
  12568. }
  12569. #endregion
  12570. #region 团组状态
  12571. /// <summary>
  12572. /// 团组状态列表 Page
  12573. /// </summary>
  12574. /// <param name="dto">团组列表请求dto</param>
  12575. /// <returns></returns>
  12576. [HttpPost]
  12577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12578. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12579. {
  12580. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12581. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12582. {
  12583. string sqlWhere = string.Empty;
  12584. if (dto.IsSure == 0) //未完成
  12585. {
  12586. sqlWhere += string.Format(@" And IsSure = 0");
  12587. }
  12588. else if (dto.IsSure == 1) //已完成
  12589. {
  12590. sqlWhere += string.Format(@" And IsSure = 1");
  12591. }
  12592. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12593. {
  12594. string tj = dto.SearchCriteria;
  12595. 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}%')",
  12596. tj, tj, tj, tj, tj);
  12597. }
  12598. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12599. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12600. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12601. From (
  12602. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12603. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12604. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12605. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12606. From Grp_DelegationInfo gdi
  12607. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12608. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12609. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12610. Where gdi.IsDel = 0 {0}
  12611. ) temp ", sqlWhere);
  12612. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12613. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12614. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12615. }
  12616. else
  12617. {
  12618. return Ok(JsonView(false, "查询失败"));
  12619. }
  12620. }
  12621. /// <summary>
  12622. /// 团组状态
  12623. /// 设置操作完成
  12624. /// </summary>
  12625. /// <param name="dto">团组列表请求dto</param>
  12626. /// <returns></returns>
  12627. [HttpPost]
  12628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12629. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12630. {
  12631. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12632. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12633. {
  12634. Id = dto.Id,
  12635. IsSure = 1
  12636. };
  12637. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12638. .UpdateColumns(it => new { it.IsSure })
  12639. .WhereColumns(it => new { it.Id })
  12640. .ExecuteCommandAsync();
  12641. if (result > 0)
  12642. {
  12643. return Ok(JsonView(true, "操作完成!"));
  12644. }
  12645. return Ok(JsonView(false, "操作失败!"));
  12646. }
  12647. #endregion
  12648. #region 保险费用录入
  12649. /// <summary>
  12650. /// 根据团组Id查询保险费用列表
  12651. /// </summary>
  12652. /// <param name="dto"></param>
  12653. /// <returns></returns>
  12654. [HttpPost]
  12655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12656. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12657. {
  12658. Result groupData = await _customersRep.CustomersByDiId(dto);
  12659. if (groupData.Code != 0)
  12660. {
  12661. return Ok(JsonView(false, groupData.Msg));
  12662. }
  12663. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12664. }
  12665. /// <summary>
  12666. /// 根据保险费用Id查询保险费用详细
  12667. /// </summary>
  12668. /// <param name="dto"></param>
  12669. /// <returns></returns>
  12670. [HttpPost]
  12671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12672. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12673. {
  12674. try
  12675. {
  12676. Result groupData = await _customersRep.CustomersById(dto);
  12677. if (groupData.Code != 0)
  12678. {
  12679. return Ok(JsonView(false, groupData.Msg));
  12680. }
  12681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12682. }
  12683. catch (Exception ex)
  12684. {
  12685. return Ok(JsonView(false, ex.Message));
  12686. }
  12687. }
  12688. /// <summary>
  12689. /// 保险费用录入页面初始化绑定
  12690. /// </summary>
  12691. /// <param name="dto"></param>
  12692. /// <returns></returns>
  12693. [HttpPost]
  12694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12695. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12696. {
  12697. try
  12698. {
  12699. Result groupData = await _customersRep.CustomersInitialize(dto);
  12700. if (groupData.Code != 0)
  12701. {
  12702. return Ok(JsonView(false, groupData.Msg));
  12703. }
  12704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12705. }
  12706. catch (Exception ex)
  12707. {
  12708. return Ok(JsonView(false, ex.Message));
  12709. }
  12710. }
  12711. /// <summary>
  12712. /// 保险费用操作(Status:1.新增,2.修改)
  12713. /// </summary>
  12714. /// <param name="dto"></param>
  12715. /// <returns></returns>
  12716. [HttpPost]
  12717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12718. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12719. {
  12720. Result groupData = await _customersRep.OpCustomers(dto);
  12721. if (groupData.Code != 0)
  12722. {
  12723. return Ok(JsonView(false, groupData.Msg));
  12724. }
  12725. #region 应用推送
  12726. try
  12727. {
  12728. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12729. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12730. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12731. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12732. //自动审核
  12733. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12734. //2024-10-21 新增LZ UID
  12735. var userIds = new List<int>() { 21 };
  12736. string title = $"系统通知";
  12737. var diId = dto.DiId;
  12738. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12739. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12740. string content = "";
  12741. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12742. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12743. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12744. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12745. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12746. }
  12747. catch (Exception ex)
  12748. {
  12749. }
  12750. #endregion
  12751. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12752. }
  12753. /// <summary>
  12754. /// 保险文件上传
  12755. /// </summary>
  12756. /// <param name="file"></param>
  12757. /// <returns></returns>
  12758. [HttpPost]
  12759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12760. public async Task<IActionResult> UploadCus(IFormFile file)
  12761. {
  12762. try
  12763. {
  12764. if (file != null)
  12765. {
  12766. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12767. //文件名称
  12768. string projectFileName = file.FileName;
  12769. //上传的文件的路径
  12770. string filePath = "";
  12771. if (!Directory.Exists(fileDir))
  12772. {
  12773. Directory.CreateDirectory(fileDir);
  12774. }
  12775. //上传的文件的路径
  12776. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12777. using (FileStream fs = System.IO.File.Create(filePath))
  12778. {
  12779. file.CopyTo(fs);
  12780. fs.Flush();
  12781. }
  12782. return Ok(JsonView(true, "上传成功!", projectFileName));
  12783. }
  12784. else
  12785. {
  12786. return Ok(JsonView(false, "上传失败!"));
  12787. }
  12788. }
  12789. catch (Exception ex)
  12790. {
  12791. return Ok(JsonView(false, "程序错误!"));
  12792. throw;
  12793. }
  12794. }
  12795. /// <summary>
  12796. /// 保险删除指定文件
  12797. /// </summary>
  12798. /// <param name="dto"></param>
  12799. /// <returns></returns>
  12800. [HttpPost]
  12801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12802. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12803. {
  12804. try
  12805. {
  12806. string filePath = "";
  12807. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12808. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12809. //int id = 0;
  12810. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12811. // 删除该文件
  12812. try
  12813. {
  12814. System.IO.File.Delete(filePath);
  12815. 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()
  12816. {
  12817. Attachment = "",
  12818. }).ExecuteCommandAsync();
  12819. if (result != 0)
  12820. {
  12821. return Ok(JsonView(true, "成功!"));
  12822. }
  12823. else
  12824. {
  12825. return Ok(JsonView(false, "失败!"));
  12826. }
  12827. }
  12828. catch (Exception)
  12829. {
  12830. 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()
  12831. {
  12832. Attachment = "",
  12833. }).ExecuteCommandAsync();
  12834. if (result != 0)
  12835. {
  12836. return Ok(JsonView(true, "成功!"));
  12837. }
  12838. else
  12839. {
  12840. return Ok(JsonView(false, "失败!"));
  12841. }
  12842. }
  12843. }
  12844. catch (Exception ex)
  12845. {
  12846. return Ok(JsonView(false, "程序错误!"));
  12847. throw;
  12848. }
  12849. }
  12850. /// <summary>
  12851. /// 保险费用操作(删除)
  12852. /// </summary>
  12853. /// <param name="dto"></param>
  12854. /// <returns></returns>
  12855. [HttpPost]
  12856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12857. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12858. {
  12859. try
  12860. {
  12861. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12862. if (!res)
  12863. {
  12864. return Ok(JsonView(false, "删除失败"));
  12865. }
  12866. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12867. {
  12868. IsDel = 1,
  12869. DeleteUserId = dto.DeleteUserId,
  12870. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12871. }).ExecuteCommandAsync();
  12872. return Ok(JsonView(true, "删除成功!"));
  12873. }
  12874. catch (Exception ex)
  12875. {
  12876. return Ok(JsonView(false, "程序错误!"));
  12877. throw;
  12878. }
  12879. }
  12880. #endregion
  12881. #region 接团客户名单 PageId 104
  12882. /// <summary>
  12883. /// 接团客户名单
  12884. /// 迁移数据(慎用!)
  12885. /// </summary>
  12886. /// <param name="dto"></param>
  12887. /// <returns></returns>
  12888. [HttpPost]
  12889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12890. public async Task<IActionResult> PostTourClientListChange()
  12891. {
  12892. try
  12893. {
  12894. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12895. //var groupClinetData1
  12896. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12897. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12898. int updateCount = 0;
  12899. if (oldOAClientList.Count > 0)
  12900. {
  12901. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12902. _sqlSugar.BeginTran();
  12903. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12904. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12905. foreach (var item in oldOAClientList)
  12906. {
  12907. int comId = 0;
  12908. string format = "yyyy-MM-dd HH:mm:ss";
  12909. string data11 = "1990-01-01 00:00";
  12910. var data1 = IsValidDate(item.OPdate, format);
  12911. if (data1) data11 = item.OPdate;
  12912. //客户公司验证
  12913. if (!string.IsNullOrEmpty(item.Company))
  12914. {
  12915. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12916. if (clientComInfo == null) // add
  12917. {
  12918. var addInfo = new Crm_CustomerCompany()
  12919. {
  12920. CompanyAbbreviation = "",
  12921. CompanyFullName = item.Company,
  12922. Address = "",
  12923. PostCodes = "",
  12924. LastedOpUserId = item.OPer,
  12925. LastedOpDt = Convert.ToDateTime(data11),
  12926. CreateUserId = item.OPer,
  12927. CreateTime = Convert.ToDateTime(data11),
  12928. IsDel = 0
  12929. };
  12930. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  12931. if (comId1 > 0) comId = comId1;
  12932. }
  12933. else comId = clientComInfo.Id;
  12934. }
  12935. //客户人员验证
  12936. int clientId = 0;
  12937. string name = item.LastName + item.Name;
  12938. if (!string.IsNullOrEmpty(name))
  12939. {
  12940. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  12941. if (clientInfo == null)
  12942. {
  12943. DateTime? dateTime = null;
  12944. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  12945. if (isDt) dateTime = birthDayDt;
  12946. var addInfo1 = new Crm_DeleClient()
  12947. {
  12948. CrmCompanyId = comId,
  12949. DiId = -1,
  12950. LastName = item.LastName,
  12951. FirstName = item.Name,
  12952. OldName = "",
  12953. Pinyin = item.Pinyin,
  12954. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  12955. Marriage = 0,
  12956. Phone = item.Phone,
  12957. Job = item.Job,
  12958. BirthDay = dateTime
  12959. };
  12960. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  12961. if (clientId1 > 0) clientId = clientId1;
  12962. }
  12963. else clientId = clientInfo.Id;
  12964. }
  12965. if (clientId < 1)
  12966. {
  12967. continue;
  12968. }
  12969. int airType = 0;
  12970. if (item.AirType == "超经舱") airType = 459;
  12971. else if (item.AirType == "公务舱") airType = 458;
  12972. else if (item.AirType == "经济舱") airType = 460;
  12973. else if (item.AirType == "其他") airType = 565;
  12974. else if (item.AirType == "头等舱") airType = 457;
  12975. var _TourClientListEntity = new Grp_TourClientList()
  12976. {
  12977. DiId = item.Diid,
  12978. ClientId = clientId,
  12979. CreateUserId = item.OPer,
  12980. CreateTime = Convert.ToDateTime(data11),
  12981. Remark = item.Remark,
  12982. IsDel = item.Isdel,
  12983. ShippingSpaceTypeId = airType,
  12984. ShippingSpaceSpecialNeeds = item.AirRemark,
  12985. HotelSpecialNeeds = item.RoomType
  12986. };
  12987. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  12988. if (_TourClientList > 0)
  12989. {
  12990. updateCount++;
  12991. }
  12992. }
  12993. _sqlSugar.CommitTran();
  12994. }
  12995. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  12996. }
  12997. catch (Exception ex)
  12998. {
  12999. _sqlSugar.RollbackTran();
  13000. return Ok(JsonView(false, ex.Message));
  13001. }
  13002. return Ok(JsonView(true));
  13003. }
  13004. private bool IsValidDate(string dateString, string format)
  13005. {
  13006. DateTime dateValue;
  13007. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  13008. return valid;
  13009. }
  13010. /// <summary>
  13011. /// 接团客户名单
  13012. /// 根据团组Id查询List
  13013. /// </summary>
  13014. /// <param name="dto"></param>
  13015. /// <returns></returns>
  13016. [HttpPost]
  13017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13018. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13019. {
  13020. #region 参数验证
  13021. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13022. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13023. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13024. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13025. #region 页面操作权限验证
  13026. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13027. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13028. #endregion
  13029. #endregion
  13030. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13031. if (viewData.Code != 0)
  13032. {
  13033. return Ok(JsonView(false, viewData.Msg));
  13034. }
  13035. return Ok(JsonView(viewData.Data));
  13036. }
  13037. /// <summary>
  13038. /// 接团客户名单
  13039. /// 基础数据 Init
  13040. /// </summary>
  13041. /// <param name="_dto"></param>
  13042. /// <returns></returns>
  13043. [HttpPost]
  13044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13045. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13046. {
  13047. #region 参数验证
  13048. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13049. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13050. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13051. #region 页面操作权限验证
  13052. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13053. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13054. #endregion
  13055. #endregion
  13056. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13057. }
  13058. /// <summary>
  13059. /// 接团客户名单
  13060. /// 根据 Id查询 Details
  13061. /// </summary>
  13062. /// <param name="_dto"></param>
  13063. /// <returns></returns>
  13064. [HttpPost]
  13065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13066. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13067. {
  13068. #region 参数验证
  13069. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13070. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13071. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13072. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13073. #region 页面操作权限验证
  13074. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13075. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13076. #endregion
  13077. #endregion
  13078. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13079. if (viewData.Code != 0)
  13080. {
  13081. return Ok(JsonView(false, viewData.Msg));
  13082. }
  13083. return Ok(JsonView(viewData.Data));
  13084. }
  13085. /// <summary>
  13086. /// 接团客户名单
  13087. /// Add Or Edit
  13088. /// </summary>
  13089. /// <param name="_dto"></param>
  13090. /// <returns></returns>
  13091. [HttpPost]
  13092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13093. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13094. {
  13095. #region 参数验证
  13096. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13097. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13098. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13099. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13100. #region 页面操作权限验证
  13101. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13102. if (_dto.Id == 0) //添加
  13103. {
  13104. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13105. }
  13106. else if (_dto.Id >= 0) //修改
  13107. {
  13108. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13109. }
  13110. #endregion
  13111. #endregion
  13112. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13113. if (viewData.Code != 0)
  13114. {
  13115. return Ok(JsonView(false, viewData.Msg));
  13116. }
  13117. return Ok(JsonView(true));
  13118. }
  13119. /// <summary>
  13120. /// 接团客户名单
  13121. /// AddMultiple(添加多个)
  13122. /// </summary>
  13123. /// <param name="_dto"></param>
  13124. /// <returns></returns>
  13125. [HttpPost]
  13126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13127. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13128. {
  13129. #region 参数验证
  13130. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13131. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13132. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13133. #region 页面操作权限验证
  13134. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13135. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13136. #endregion
  13137. #endregion
  13138. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13139. if (viewData.Code != 0)
  13140. {
  13141. return Ok(JsonView(false, viewData.Msg));
  13142. }
  13143. return Ok(JsonView(true));
  13144. }
  13145. /// <summary>
  13146. /// 接团客户名单
  13147. /// Del
  13148. /// </summary>
  13149. /// <param name="_dto"></param>
  13150. /// <returns></returns>
  13151. [HttpPost]
  13152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13153. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13154. {
  13155. #region 参数验证
  13156. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13157. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13158. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13159. #region 页面操作权限验证
  13160. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13161. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13162. #endregion
  13163. #endregion
  13164. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13165. if (viewData.Code != 0)
  13166. {
  13167. return Ok(JsonView(false, viewData.Msg));
  13168. }
  13169. return Ok(JsonView(true));
  13170. }
  13171. /// <summary>
  13172. /// 接团客户名单
  13173. /// 文件下载 客户名单
  13174. /// </summary>
  13175. /// <param name="_dto"></param>
  13176. /// <returns></returns>
  13177. [HttpPost]
  13178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13179. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13180. {
  13181. #region 参数验证
  13182. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13183. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13184. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13185. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13186. #region 页面操作权限验证
  13187. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13188. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13189. #endregion
  13190. #endregion
  13191. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13192. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13193. From Grp_TourClientList tcl
  13194. Left Join
  13195. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13196. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13197. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13198. From Crm_DeleClient dc
  13199. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13200. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13201. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13202. Where dc.IsDel = 0) temp
  13203. On temp.DcId =tcl.ClientId
  13204. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13205. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13206. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13207. //载入模板
  13208. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13209. if (_dto.Language == 1)
  13210. {
  13211. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13212. }
  13213. //载入模板
  13214. var doc = new Document(tempPath);
  13215. DocumentBuilder builder = new DocumentBuilder(doc);
  13216. //获取word里所有表格
  13217. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13218. //获取所填表格的序数
  13219. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13220. var rowStart = tableOne.Rows[0]; //获取第1行
  13221. if (_dto.Language == 0)
  13222. {
  13223. //循环赋值
  13224. for (int i = 0; i < DcList.Count; i++)
  13225. {
  13226. EncryptionProcessor.DecryptProperties(DcList[i]);
  13227. builder.MoveToCell(0, i + 1, 0, 0);
  13228. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13229. builder.MoveToCell(0, i + 1, 1, 0);
  13230. int sex = DcList[i].Sex;
  13231. string sexStr = string.Empty;
  13232. if (sex == 0) sexStr = "男";
  13233. else if (sex == 1) sexStr = "女";
  13234. else sexStr = "未设置";
  13235. builder.Write(sexStr);
  13236. builder.MoveToCell(0, i + 1, 2, 0);
  13237. string birthDay = DcList[i].BirthDay;
  13238. string birthDayStr = string.Empty;
  13239. if (!string.IsNullOrEmpty(birthDay))
  13240. {
  13241. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13242. }
  13243. builder.Write(birthDayStr);
  13244. builder.MoveToCell(0, i + 1, 3, 0);
  13245. string company = "";
  13246. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13247. {
  13248. company = DcList[i].CompanyFullName.ToString();
  13249. }
  13250. builder.Write(company);
  13251. builder.MoveToCell(0, i + 1, 4, 0);
  13252. builder.Write(DcList[i].Job);
  13253. }
  13254. }
  13255. else if (_dto.Language == 1)
  13256. {
  13257. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13258. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13259. List<string> transArrayStr = new List<string>();
  13260. string transStrRes1 = "";
  13261. for (int i = 0; i < DcList.Count; i++)
  13262. {
  13263. var dc = DcList[i];
  13264. EncryptionProcessor.DecryptProperties(dc);
  13265. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13266. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13267. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13268. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13269. else transStrRes1 += $"{str1}|";
  13270. }
  13271. //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";
  13272. string transStrRes = "";
  13273. if (transStrRes1.Length > 0)
  13274. {
  13275. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13276. }
  13277. //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
  13278. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13279. //List<string> transArray = new List<string> { };
  13280. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13281. if (transStrRes.Contains("|"))
  13282. {
  13283. string[] transArray1 = transStrRes.Split('|');
  13284. if (transArray1.Length > 0)
  13285. {
  13286. foreach (var item in transArray1)
  13287. {
  13288. if (item.Contains("&"))
  13289. {
  13290. string[] transArray2 = item.Split('&');
  13291. int index = 0;
  13292. string companyName = "", job = "";
  13293. if (transArray2.Length > 0)
  13294. {
  13295. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13296. if (1 < transArray2.Length) companyName = transArray2[1];
  13297. if (2 < transArray2.Length) job = transArray2[2];
  13298. }
  13299. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13300. }
  13301. }
  13302. }
  13303. }
  13304. //循环赋值
  13305. for (int i = 0; i < DcList.Count; i++)
  13306. {
  13307. string PYName = "";
  13308. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13309. {
  13310. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13311. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13312. PYName = PY_First + " " + PY_Last;
  13313. }
  13314. else
  13315. {
  13316. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13317. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13318. PYName = PY_First + " " + PY_Last;
  13319. }
  13320. builder.MoveToCell(0, i + 1, 0, 0);
  13321. builder.Write(PYName);
  13322. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13323. builder.MoveToCell(0, i + 1, 1, 0);
  13324. builder.Write(sex);
  13325. DateTime birthDt;
  13326. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13327. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13328. builder.MoveToCell(0, i + 1, 2, 0);
  13329. builder.Write(birthday);
  13330. string company = string.Empty, job = string.Empty;
  13331. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13332. if (dcTransInfo != null)
  13333. {
  13334. company = dcTransInfo.CompanyName;
  13335. job = dcTransInfo.Job;
  13336. }
  13337. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13338. {
  13339. //查询对照表
  13340. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13341. if (tempCec != null)
  13342. {
  13343. company = tempCec.enName;
  13344. }
  13345. //翻译
  13346. else
  13347. {
  13348. }
  13349. }
  13350. builder.MoveToCell(0, i + 1, 3, 0);
  13351. builder.Write(company);
  13352. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13353. {
  13354. //查询对照表
  13355. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13356. if (tempPec != null)
  13357. {
  13358. job = tempPec.enName;
  13359. }
  13360. //翻译
  13361. else
  13362. {
  13363. }
  13364. }
  13365. builder.MoveToCell(0, i + 1, 4, 0);
  13366. builder.Write(job);
  13367. }
  13368. }
  13369. //删除多余行
  13370. while (tableOne.Rows.Count > DcList.Count + 1)
  13371. {
  13372. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13373. }
  13374. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13375. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13376. doc.Save(fileDir);
  13377. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13378. return Ok(JsonView(true, "操作成功!", Url));
  13379. }
  13380. private class TranslateInfo
  13381. {
  13382. public int Index { get; set; }
  13383. public string CompanyName { get; set; }
  13384. public string Job { get; set; }
  13385. }
  13386. #endregion
  13387. #region 团组倒推表
  13388. /// <summary>
  13389. /// 倒推表基础数据
  13390. /// Init
  13391. /// </summary>
  13392. /// <param name="dto"></param>
  13393. /// <returns></returns>
  13394. [HttpPost]
  13395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13396. public async Task<IActionResult> PostInvertedListInit()
  13397. {
  13398. var viewData = await _invertedListRep._Init();
  13399. if (viewData.Code != 0)
  13400. {
  13401. return Ok(JsonView(false, viewData.Msg));
  13402. }
  13403. return Ok(JsonView(viewData.Data));
  13404. }
  13405. /// <summary>
  13406. /// 倒推表
  13407. /// Info
  13408. /// </summary>
  13409. /// <param name="dto"></param>
  13410. /// <returns></returns>
  13411. [HttpPost]
  13412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13413. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13414. {
  13415. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13416. if (viewData.Code != 0)
  13417. {
  13418. return Ok(JsonView(false, viewData.Msg));
  13419. }
  13420. return Ok(JsonView(viewData.Data));
  13421. }
  13422. /// <summary>
  13423. /// 倒推表
  13424. /// Create
  13425. /// </summary>
  13426. /// <param name="dto"></param>
  13427. /// <returns></returns>
  13428. [HttpPost]
  13429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13430. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13431. {
  13432. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13433. if (viewData.Code != 0)
  13434. {
  13435. return Ok(JsonView(false, viewData.Msg));
  13436. }
  13437. return Ok(JsonView(viewData.Data));
  13438. }
  13439. /// <summary>
  13440. /// 倒推表
  13441. /// Update
  13442. /// </summary>
  13443. /// <param name="dto"></param>
  13444. /// <returns></returns>
  13445. [HttpPost]
  13446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13447. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13448. {
  13449. var viewData = await _invertedListRep._Update(dto);
  13450. if (viewData.Code != 0)
  13451. {
  13452. return Ok(JsonView(false, viewData.Msg));
  13453. }
  13454. return Ok(JsonView(viewData.Data));
  13455. }
  13456. /// <summary>
  13457. /// 倒推表
  13458. /// File Download
  13459. /// </summary>
  13460. /// <param name="dto"></param>
  13461. /// <returns></returns>
  13462. [HttpPost]
  13463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13464. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13465. {
  13466. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13467. if (info2.Code != 0)
  13468. {
  13469. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13470. }
  13471. var info1 = info2.Data as InvertedListInfoView;
  13472. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13473. string teamName = "";
  13474. if (info != null) teamName = info.TeamName;
  13475. //载入模板
  13476. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13477. DocumentBuilder builder = new DocumentBuilder(doc);
  13478. //利用键值对存放数据
  13479. Dictionary<string, string> dic = new Dictionary<string, string>();
  13480. dic.Add("TeamName", teamName);
  13481. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13482. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13483. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13484. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13485. dic.Add("SQRemark", info1.ApprovalRemark);
  13486. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13487. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13488. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13489. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13490. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13491. dic.Add("QZRemark", info1.VisaInformationRemark);
  13492. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13493. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13494. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13495. dic.Add("CQRemark", info1.IssueVisaRemark);
  13496. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13497. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13498. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13499. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13500. #region 填充word模板书签内容
  13501. foreach (var key in dic.Keys)
  13502. {
  13503. builder.MoveToBookmark(key);
  13504. builder.Write(dic[key]);
  13505. }
  13506. #endregion
  13507. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13508. string fileName = $"{teamName}团出行准备流程表.doc";
  13509. string filePath = fileDir + $@"InvertedList/{fileName}";
  13510. doc.Save(filePath);
  13511. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13512. return Ok(JsonView(true, "操作成功!", Url));
  13513. }
  13514. #endregion
  13515. #region 三公签证费用(签证费、代办费)
  13516. /// <summary>
  13517. /// 三公签证费用(签证费、代办费)
  13518. /// List
  13519. /// </summary>
  13520. /// <returns></returns>
  13521. [HttpPost]
  13522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13523. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13524. {
  13525. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13526. if (_view.Code != 0)
  13527. {
  13528. return Ok(JsonView(false, _view.Msg));
  13529. }
  13530. return Ok(JsonView(true, "操作成功!", _view.Data));
  13531. }
  13532. /// <summary>
  13533. /// 三公签证费用(签证费、代办费)
  13534. /// Add Or Update
  13535. /// </summary>
  13536. /// <returns></returns>
  13537. [HttpPost]
  13538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13539. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13540. {
  13541. var _view = await _visaFeeInfoRep._Update(_dto);
  13542. if (_view.Code != 0)
  13543. {
  13544. return Ok(JsonView(false, _view.Msg));
  13545. }
  13546. return Ok(JsonView(true, _view.Msg));
  13547. }
  13548. #endregion
  13549. #region 酒店询价
  13550. /// <summary>
  13551. /// 酒店询价
  13552. /// Init
  13553. /// </summary>
  13554. /// <param name="dto"></param>
  13555. /// <returns></returns>
  13556. [HttpPost]
  13557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13558. public async Task<IActionResult> PostHotelInquiryInit()
  13559. {
  13560. var res = await _hotelInquiryRep._Init();
  13561. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13562. return Ok(JsonView(true, res.Msg, res.Data));
  13563. }
  13564. /// <summary>
  13565. /// 酒店询价
  13566. /// page Item
  13567. /// </summary>
  13568. /// <param name="_dto"></param>
  13569. /// <returns></returns>
  13570. [HttpPost]
  13571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13572. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13573. {
  13574. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13575. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13576. var view = res.Data as PageDataViewBase;
  13577. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13578. }
  13579. /// <summary>
  13580. /// 酒店询价
  13581. /// info
  13582. /// </summary>
  13583. /// <param name="_dto"></param>
  13584. /// <returns></returns>
  13585. [HttpPost]
  13586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13587. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13588. {
  13589. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13590. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13591. return Ok(JsonView(true, res.Msg, res.Data));
  13592. }
  13593. /// <summary>
  13594. /// 酒店询价
  13595. /// Add Or Edit
  13596. /// </summary>
  13597. /// <param name="_dto"></param>
  13598. /// <returns></returns>
  13599. [HttpPost]
  13600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13601. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13602. {
  13603. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13604. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13605. return Ok(JsonView(true, res.Msg, res.Data));
  13606. }
  13607. /// <summary>
  13608. /// 酒店询价
  13609. /// Del
  13610. /// </summary>
  13611. /// <param name="_dto"></param>
  13612. /// <returns></returns>
  13613. [HttpPost]
  13614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13615. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13616. {
  13617. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13618. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13619. return Ok(JsonView(true, res.Msg, res.Data));
  13620. }
  13621. #endregion
  13622. #region 下载匹配op行程单
  13623. /// <summary>
  13624. /// 匹配op行程单
  13625. /// Init
  13626. /// </summary>
  13627. /// <param name="dto">团组列表请求dto</param>
  13628. /// <returns></returns>
  13629. [HttpPost]
  13630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13631. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13632. {
  13633. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13634. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13635. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13636. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13637. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13638. .Where(it => it.IsDel == 0)
  13639. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13640. .OrderByDescending(it => it.CreateUserId)
  13641. .ToList();
  13642. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13643. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13644. var diids = groupInfos.Select(it => it.Id).ToList();
  13645. List<string> countrys = new List<string>();
  13646. foreach (var item in country)
  13647. {
  13648. var data = _groupRepository.FormartTeamName(item);
  13649. var dataArray = _groupRepository.GroupSplitCountry(data);
  13650. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13651. }
  13652. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13653. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13654. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13655. foreach (var item in areaItem)
  13656. {
  13657. string areaStr = item.Value;
  13658. if (!string.IsNullOrEmpty(areaStr))
  13659. {
  13660. string[] str1 = areaStr.Split("-");
  13661. if (str1.Length > 0)
  13662. {
  13663. areaArray.AddRange(str1);
  13664. }
  13665. }
  13666. }
  13667. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13668. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13669. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13670. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13671. .ToList();
  13672. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13673. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13674. .Where(it => countriesIds.Contains(it.Id))
  13675. .Select(it => new { it.Id, Name = it.Name_CN })
  13676. .ToList();
  13677. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13678. .Select(it => it.TeamName).ToList();
  13679. stopwatch.Stop();
  13680. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13681. }
  13682. ///// <summary>
  13683. ///// 匹配op行程单
  13684. ///// Init 查询区域数据
  13685. ///// </summary>
  13686. ///// <param name="dto">团组列表请求dto</param>
  13687. ///// <returns></returns>
  13688. //[HttpPost]
  13689. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13690. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13691. //{
  13692. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13693. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13694. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13695. // if (string.IsNullOrEmpty(countriesDataStr))
  13696. // {
  13697. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13698. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13699. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13700. // }
  13701. // else
  13702. // {
  13703. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13704. // }
  13705. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13706. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13707. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13708. // List<dynamic> childList = new List<dynamic>();
  13709. // int parentId = dto.CountriesId;
  13710. // if (provinceData.Count > 1)
  13711. // {
  13712. // foreach (var item1 in provinceData)
  13713. // {
  13714. // List<dynamic> childList1 = new List<dynamic>();
  13715. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13716. // foreach (var item2 in citiesData1)
  13717. // {
  13718. // List<dynamic> childList2 = new List<dynamic>();
  13719. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13720. // foreach (var item3 in countiesData1)
  13721. // {
  13722. // childList2.Add(new
  13723. // {
  13724. // id = item3.Id,
  13725. // parentId = item2.Id,
  13726. // level = "district",
  13727. // name = item3.Name_CN,
  13728. // });
  13729. // }
  13730. // childList1.Add(new
  13731. // {
  13732. // id = item2.Id,
  13733. // parentId = item1.Id,
  13734. // level = "city",
  13735. // name = item2.Name_CN,
  13736. // childList = childList2
  13737. // });
  13738. // }
  13739. // childList.Add(new
  13740. // {
  13741. // id = item1.Id,
  13742. // parentId = parentId,
  13743. // level = "province",
  13744. // name = item1.Name_CN,
  13745. // childList = childList1
  13746. // });
  13747. // }
  13748. // //城市
  13749. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13750. // foreach (var item2 in citiesData2)
  13751. // {
  13752. // List<dynamic> childList22 = new List<dynamic>();
  13753. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13754. // foreach (var item3 in countiesData1)
  13755. // {
  13756. // childList22.Add(new
  13757. // {
  13758. // id = item3.Id,
  13759. // parentId = item2.Id,
  13760. // level = "district",
  13761. // name = item3.Name_CN,
  13762. // });
  13763. // }
  13764. // childList.Add(new
  13765. // {
  13766. // id = item2.Id,
  13767. // parentId = parentId,
  13768. // level = "city",
  13769. // name = item2.Name_CN,
  13770. // childList = childList22
  13771. // });
  13772. // }
  13773. // }
  13774. // else
  13775. // {
  13776. // foreach (var item2 in citiesData)
  13777. // {
  13778. // string cname = item2.Name_CN;
  13779. // List<dynamic> childList1 = new List<dynamic>();
  13780. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13781. // foreach (var item3 in countiesData1)
  13782. // {
  13783. // childList1.Add(new
  13784. // {
  13785. // Id = item3.Id,
  13786. // parentId = item2.Id,
  13787. // level = "district",
  13788. // name = item3.Name_CN
  13789. // });
  13790. // }
  13791. // childList.Add(new
  13792. // {
  13793. // id = item2.Id,
  13794. // parentId = parentId,
  13795. // level = "city",
  13796. // name = item2.Name_CN,
  13797. // childList = childList1
  13798. // });
  13799. // }
  13800. // }
  13801. // stopwatch.Stop();
  13802. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13803. //}
  13804. /// <summary>
  13805. /// 匹配op行程单
  13806. /// 接团信息列表 Page
  13807. /// </summary>
  13808. /// <param name="dto">团组列表请求dto</param>
  13809. /// <returns></returns>
  13810. [HttpPost]
  13811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13812. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13813. {
  13814. var swatch = new Stopwatch();
  13815. swatch.Start();
  13816. #region 参数验证
  13817. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13818. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13819. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13820. #region 页面操作权限验证
  13821. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13822. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13823. #endregion
  13824. #endregion
  13825. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13826. {
  13827. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13828. string sqlWhere = "";
  13829. if (!string.IsNullOrEmpty(dto.Country))
  13830. {
  13831. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13832. }
  13833. if (!string.IsNullOrEmpty(dto.Area))
  13834. {
  13835. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13836. }
  13837. if (!string.IsNullOrEmpty(dto.TeamName))
  13838. {
  13839. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13840. }
  13841. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13842. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13843. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13844. swatch.Stop();
  13845. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13846. }
  13847. else
  13848. {
  13849. return Ok(JsonView(false, "查询失败"));
  13850. }
  13851. }
  13852. /// <summary>
  13853. /// 匹配op行程单
  13854. /// 行程单下载
  13855. /// </summary>
  13856. /// <param name="dto">团组列表请求dto</param>
  13857. /// <returns></returns>
  13858. [HttpPost]
  13859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13860. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13861. {
  13862. #region 参数验证
  13863. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13864. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13865. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13866. #region 页面操作权限验证
  13867. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13868. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13869. #endregion
  13870. #endregion
  13871. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13872. {
  13873. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13874. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13875. }
  13876. else
  13877. {
  13878. return Ok(JsonView(false, "下载失败!"));
  13879. }
  13880. }
  13881. #endregion
  13882. #region 国家信息 数据 注释
  13883. //[HttpPost]
  13884. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13885. //{
  13886. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13887. // foreach (var item in dto)
  13888. // {
  13889. // infos.Add(new Grp_GroupsTaskAssignment()
  13890. // {
  13891. // DIId = item,
  13892. // CTId = 82,
  13893. // UId = 248,
  13894. // IsEnable = 1,
  13895. // CreateUserId = 233,
  13896. // CreateTime = DateTime.Now,
  13897. // IsDel = 0
  13898. // });
  13899. // infos.Add(new Grp_GroupsTaskAssignment()
  13900. // {
  13901. // DIId = item,
  13902. // CTId = 82,
  13903. // UId = 286,
  13904. // IsEnable = 1,
  13905. // CreateUserId = 233,
  13906. // CreateTime = DateTime.Now,
  13907. // IsDel = 0
  13908. // });
  13909. // }
  13910. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13911. // return Ok("操作成功");
  13912. //}
  13913. //public class paramJsonDto
  13914. //{
  13915. // public List<CountriesInfo> str { get; set; }
  13916. //}
  13917. //[HttpPost]
  13918. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13919. //{
  13920. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13921. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  13922. // List<Sys_Cities> cities = new List<Sys_Cities>();
  13923. // List<Sys_Cities> districts = new List<Sys_Cities>();
  13924. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13925. // _sqlSugar.BeginTran();
  13926. // int countitiesIndex = 0;
  13927. // foreach (var item in dto.str)
  13928. // {
  13929. // dynamic data = item.c;
  13930. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  13931. // if (data != null)
  13932. // {
  13933. // countitiesIndex++;
  13934. // foreach (var item1 in data)
  13935. // {
  13936. // string cnname = item1.cn;
  13937. // string enname = item1.en;
  13938. // Sys_Cities provinceInfo = new Sys_Cities()
  13939. // {
  13940. // CountriesId = countriesId,
  13941. // Name_CN = cnname,
  13942. // Name_EN = enname,
  13943. // ParentId = 0,
  13944. // IsCapital = 1,
  13945. // CreateUserId = 208,
  13946. // CreateTime = DateTime.Now,
  13947. // IsDel = 0
  13948. // };
  13949. // if (item1.lv == "province") //省份
  13950. // {
  13951. // provinceInfo.Level = 1;
  13952. // int provinceId = 0;
  13953. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  13954. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  13955. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13956. // var data1 = item1.c;
  13957. // foreach (var item2 in data1)
  13958. // {
  13959. // if (item2.lv == "city")
  13960. // {
  13961. // string citycnname = item2.cn;
  13962. // string cityenname = item2.en;
  13963. // Sys_Cities cityInfo = new Sys_Cities()
  13964. // {
  13965. // CountriesId = countriesId,
  13966. // ParentId = provinceId,
  13967. // Level = 2,
  13968. // Name_CN = citycnname,
  13969. // Name_EN = cityenname,
  13970. // IsCapital = 1,
  13971. // CreateUserId = 208,
  13972. // CreateTime = DateTime.Now,
  13973. // IsDel = 0
  13974. // };
  13975. // if (item2.c != null)
  13976. // {
  13977. // int cityId = 0;
  13978. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  13979. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13980. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  13981. // foreach (var item3 in item2.c)
  13982. // {
  13983. // if (item3.lv == "district")
  13984. // {
  13985. // var districtInfo = new Sys_Cities()
  13986. // {
  13987. // CountriesId = countriesId,
  13988. // Name_CN = item3.cn,
  13989. // Name_EN = item3.en,
  13990. // Level = 3,
  13991. // ParentId = cityId,
  13992. // IsCapital = 1,
  13993. // CreateUserId = 208,
  13994. // CreateTime = DateTime.Now,
  13995. // IsDel = 0
  13996. // };
  13997. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13998. // //{
  13999. // districts.Add(districtInfo);
  14000. // //}
  14001. // }
  14002. // }
  14003. // }
  14004. // else
  14005. // {
  14006. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  14007. // //{
  14008. // cities.Add(cityInfo);
  14009. // //}
  14010. // }
  14011. // }
  14012. // }
  14013. // }
  14014. // else if (item1.lv == "city")//城市
  14015. // {
  14016. // provinceInfo.Level = 2;
  14017. // if (item1.c != null)
  14018. // {
  14019. // int cityId = 0;
  14020. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14021. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14022. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14023. // foreach (var item3 in item1.c)
  14024. // {
  14025. // if (item3.lv == "district")
  14026. // {
  14027. // var districtInfo = new Sys_Cities()
  14028. // {
  14029. // CountriesId = countriesId,
  14030. // Name_CN = item3.cn,
  14031. // Name_EN = item3.en,
  14032. // Level = 3,
  14033. // ParentId = cityId,
  14034. // IsCapital = 1,
  14035. // CreateUserId = 208,
  14036. // CreateTime = DateTime.Now,
  14037. // IsDel = 0
  14038. // };
  14039. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14040. // //{
  14041. // districts.Add(districtInfo);
  14042. // //}
  14043. // }
  14044. // }
  14045. // }
  14046. // else
  14047. // {
  14048. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14049. // //{
  14050. // cities.Add(provinceInfo);
  14051. // //}
  14052. // }
  14053. // }
  14054. // }
  14055. // }
  14056. // }
  14057. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14058. // cities = cities.Distinct().ToList();
  14059. // districts = districts.Distinct().ToList();
  14060. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14061. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14062. // cities.AddRange(districts);
  14063. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14064. // //_sqlSugar.RollbackTran();
  14065. // _sqlSugar.CommitTran();
  14066. // return Ok(JsonView(false, "操作成功!"));
  14067. //}
  14068. //[HttpPost]
  14069. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14070. //{
  14071. // List<CountitiesInfo> infos = dto.MyProperty;
  14072. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14073. // _sqlSugar.BeginTran();
  14074. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14075. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14076. // foreach (var item in infos)
  14077. // {
  14078. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14079. // if (countryInfo != null)
  14080. // {
  14081. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14082. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14083. // if (cityInfo1 != null)
  14084. // {
  14085. // cityInfo1.IsCapital = 0;
  14086. // cityInfos.Add(cityInfo1);
  14087. // }
  14088. // }
  14089. // }
  14090. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14091. // .UpdateColumns(it => it.IsCapital)
  14092. // .WhereColumns(it => it.Id)
  14093. // .ExecuteCommand();
  14094. // //_sqlSugar.RollbackTran();
  14095. // _sqlSugar.CommitTran();
  14096. // return Ok(JsonView(false, "操作成功!"));
  14097. //}
  14098. //public class CounrtiesDto
  14099. //{
  14100. // public List<CountitiesInfo> MyProperty { get; set; }
  14101. //}
  14102. //public class CountitiesInfo
  14103. //{
  14104. // /// <summary>
  14105. // /// 圣约翰
  14106. // /// </summary>
  14107. // public string capital_name_chinese { get; set; }
  14108. // /// <summary>
  14109. // ///
  14110. // /// </summary>
  14111. // public string capital_name { get; set; }
  14112. // /// <summary>
  14113. // ///
  14114. // /// </summary>
  14115. // public string country_type { get; set; }
  14116. // /// <summary>
  14117. // /// 安提瓜和巴布达
  14118. // /// </summary>
  14119. // public string country_name_chinese { get; set; }
  14120. // /// <summary>
  14121. // /// 安提瓜和巴布达
  14122. // /// </summary>
  14123. // public string country_name_chinese_short { get; set; }
  14124. // /// <summary>
  14125. // /// 安提瓜和巴布达
  14126. // /// </summary>
  14127. // public string country_name_chinese_UN { get; set; }
  14128. // /// <summary>
  14129. // ///
  14130. // /// </summary>
  14131. // public string country_name_english_abbreviation { get; set; }
  14132. // /// <summary>
  14133. // ///
  14134. // /// </summary>
  14135. // public string country_name_english_formal { get; set; }
  14136. // /// <summary>
  14137. // ///
  14138. // /// </summary>
  14139. // public string country_name_english_UN { get; set; }
  14140. // /// <summary>
  14141. // ///
  14142. // /// </summary>
  14143. // public string continent_name { get; set; }
  14144. // /// <summary>
  14145. // ///
  14146. // /// </summary>
  14147. // public string subregion_name { get; set; }
  14148. // /// <summary>
  14149. // ///
  14150. // /// </summary>
  14151. // public string country_code2 { get; set; }
  14152. // /// <summary>
  14153. // ///
  14154. // /// </summary>
  14155. // public string country_code3 { get; set; }
  14156. // /// <summary>
  14157. // ///
  14158. // /// </summary>
  14159. // public string phone_code { get; set; }
  14160. //}
  14161. //public class CountriesInfo : BasicInfo
  14162. //{
  14163. // public List<CitiesInfo> c { get; set; }
  14164. //}
  14165. //public class CitiesInfo : BasicInfo
  14166. //{
  14167. // public List<AreaInfo> c { get; set; }
  14168. //}
  14169. //public class AreaInfo : BasicInfo
  14170. //{
  14171. // public List<AreaInfo> c { get; set; }
  14172. //}
  14173. //public class BasicInfo
  14174. //{
  14175. // public string code { get; set; }
  14176. // public string cn { get; set; }
  14177. // public string lv { get; set; }
  14178. // public string en { get; set; }
  14179. //}
  14180. #endregion
  14181. #region 查看邀请方
  14182. /// <summary>
  14183. /// 查看邀请方
  14184. /// 邀请方信息 Init
  14185. /// </summary>
  14186. /// <param name="dto"></param>
  14187. /// <returns></returns>
  14188. [HttpPost]
  14189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14190. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14191. {
  14192. string sqlWhere = string.Empty;
  14193. if (!string.IsNullOrEmpty(dto.Search))
  14194. {
  14195. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14196. }
  14197. string sql = string.Format($@"Select
  14198. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14199. Id,
  14200. UnitName
  14201. From Res_InvitationOfficialActivityData
  14202. Where IsDel = 0
  14203. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14204. RefAsync<int> total = 0;
  14205. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14206. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14207. }
  14208. /// <summary>
  14209. /// 查看邀请方
  14210. /// 国家信息 Init
  14211. /// </summary>
  14212. /// <param name="dto"></param>
  14213. /// <returns></returns>
  14214. [HttpPost]
  14215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14216. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14217. {
  14218. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14219. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14220. var diids = groupInfos.Select(it => it.Id).ToList();
  14221. List<string> countrys = new List<string>();
  14222. foreach (var item in country)
  14223. {
  14224. var data = _groupRepository.FormartTeamName(item);
  14225. var dataArray = _groupRepository.GroupSplitCountry(data);
  14226. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14227. }
  14228. countrys = countrys.Distinct().ToList();
  14229. for (int i = 0; i < countrys.Count; i++)
  14230. {
  14231. string item = countrys[i];
  14232. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14233. {
  14234. countrys.Remove(item);
  14235. i--;
  14236. }
  14237. }
  14238. RefAsync<int> total = 0;
  14239. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14240. .Where(it => countrys.Contains(it.Name_CN))
  14241. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14242. .Select(it => new { id = it.Id, name = it.Name_CN })
  14243. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14244. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14245. }
  14246. /// <summary>
  14247. /// 查看邀请方
  14248. /// 城市信息 Init
  14249. /// </summary>
  14250. /// <param name="dto"></param>
  14251. /// <returns></returns>
  14252. [HttpPost]
  14253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14254. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14255. {
  14256. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14257. RefAsync<int> total = 0;
  14258. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14259. .Where(it => it.CountriesId == dto.CountiesId)
  14260. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14261. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14262. .Select(it => new { id = it.Id, name = it.Name_CN })
  14263. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14264. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14265. }
  14266. /// <summary>
  14267. /// 查看邀请方
  14268. /// 团组名称 Init
  14269. /// </summary>
  14270. /// <param name="dto"></param>
  14271. /// <returns></returns>
  14272. [HttpPost]
  14273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14274. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14275. {
  14276. var watch = new Stopwatch();
  14277. watch.Start();
  14278. RefAsync<int> total = 0;
  14279. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14280. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14281. .Where((oa, di) => oa.IsDel == 0)
  14282. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14283. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14284. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14285. .Distinct()
  14286. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14287. watch.Stop();
  14288. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14289. }
  14290. /// <summary>
  14291. /// 查看邀请方
  14292. /// 团组 & 邀请方信息
  14293. /// </summary>
  14294. /// <param name="dto"></param>
  14295. /// <returns></returns>
  14296. [HttpPost]
  14297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14298. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14299. {
  14300. var watch = new Stopwatch();
  14301. watch.Start();
  14302. RefAsync<int> total = 0;
  14303. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14304. .AS("Grp_DelegationInfo")
  14305. .Includes(x => x.InvitingInfos)
  14306. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14307. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14308. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14309. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14310. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14311. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14312. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14313. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14314. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14315. infos.ForEach(x =>
  14316. {
  14317. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14318. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14319. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14320. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14321. });
  14322. watch.Stop();
  14323. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14324. }
  14325. #endregion
  14326. #region 报批行程
  14327. /// <summary>
  14328. /// 报批行程初始化
  14329. /// </summary>
  14330. /// <param name="dto"></param>
  14331. /// <returns></returns>
  14332. [HttpPost]
  14333. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14334. {
  14335. const int chiNumber = 5;
  14336. var jw = JsonView(false);
  14337. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14338. var group = groupList.First();
  14339. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14340. group = groupList.First(x => x.Id == diid);
  14341. if (group == null)
  14342. {
  14343. jw.Msg = "暂无团组!";
  14344. return Ok(jw);
  14345. }
  14346. var data = new
  14347. {
  14348. groupList = groupList.Select(x => new
  14349. {
  14350. x.TeamName,
  14351. x.Id
  14352. }),
  14353. content = new ArrayList(),
  14354. groupInfo = new
  14355. {
  14356. group.VisitDays,
  14357. group.TourCode,
  14358. group.VisitPNumber,
  14359. group.TeamName,
  14360. group.Id,
  14361. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14362. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14363. },
  14364. };
  14365. var resultArr = new ArrayList();
  14366. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14367. if (content.Count == 0)
  14368. {
  14369. var stay = "-";
  14370. var cityPath = "-";
  14371. //添加城市路径以及住宿地
  14372. //黑屏代码数据
  14373. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14374. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14375. {
  14376. jw = JsonView(true, "黑屏代码有误!", data);
  14377. return Ok(jw);
  14378. }
  14379. foreach (DataRow row in dtBlack.Rows)
  14380. {
  14381. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14382. {
  14383. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14384. return Ok(jw);
  14385. }
  14386. }
  14387. //黑屏代码获取时间区间
  14388. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14389. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14390. _sqlSugar.BeginTran();
  14391. for (int i = 0; i < timeArr.Count; i++)
  14392. {
  14393. stay = "-";
  14394. cityPath = "-";
  14395. DateTime NewData = DateTime.Parse(timeArr[i]);
  14396. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14397. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14398. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14399. if (tbSelect.Length > 0)
  14400. {
  14401. List<string> threeCodeStr = new List<string>();
  14402. foreach (var item in tbSelect)
  14403. {
  14404. var threeCode = item["Three"].ToString() ?? "";
  14405. if (threeCode.Length == 6)
  14406. {
  14407. var start = threeCode.Substring(0, 3);
  14408. var end = threeCode.Substring(3, 3);
  14409. if (threeCodeStr.Count == 0)
  14410. {
  14411. threeCodeStr.Add(start);
  14412. threeCodeStr.Add(end);
  14413. }
  14414. else
  14415. {
  14416. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14417. {
  14418. threeCodeStr.Add(end);
  14419. }
  14420. else
  14421. {
  14422. threeCodeStr.Add(start);
  14423. threeCodeStr.Add(end);
  14424. }
  14425. }
  14426. }
  14427. }
  14428. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14429. var last = threeCodeStr.Last();
  14430. foreach (var item in threeCodeStr)
  14431. {
  14432. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14433. if (item.Equals(last))
  14434. {
  14435. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14436. }
  14437. }
  14438. cityPath = cityPath.Trim('-');
  14439. }
  14440. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14441. appro.Diid = diid ?? -1;
  14442. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14443. appro.Id = thisId;
  14444. appro.CreateUserId = dto.UserId;
  14445. appro.CreateTime = DateTime.Now;
  14446. content.Add(appro);
  14447. }
  14448. _sqlSugar.CommitTran();
  14449. }
  14450. foreach (var x in content)
  14451. {
  14452. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14453. if (chiList.Count < chiNumber)
  14454. {
  14455. for (int i = chiList.Count; i < chiNumber; i++)
  14456. {
  14457. chiList.Add(new Grp_ApprovalTravelDetails());
  14458. }
  14459. }
  14460. resultArr.Add(new
  14461. {
  14462. x.Id,
  14463. x.Date,
  14464. x.Diid,
  14465. chiList = chiList.Select(x1 => new
  14466. {
  14467. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14468. x1.Details,
  14469. x1.ParentId,
  14470. x1.Id
  14471. })
  14472. });
  14473. }
  14474. data = data with
  14475. {
  14476. content = resultArr,
  14477. };
  14478. jw = JsonView(true, "获取成功!", data);
  14479. return Ok(jw);
  14480. }
  14481. /// <summary>
  14482. /// 报批行程删除
  14483. /// </summary>
  14484. /// <param name="dto"></param>
  14485. /// <returns></returns>
  14486. [HttpPost]
  14487. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14488. {
  14489. var jw = JsonView(false);
  14490. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14491. if (group == null)
  14492. {
  14493. jw.Msg = "团组参数有误!";
  14494. return Ok(jw);
  14495. }
  14496. try
  14497. {
  14498. _sqlSugar.BeginTran();
  14499. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14500. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14501. {
  14502. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14503. DeleteUserId = dto.uesrId,
  14504. IsDel = 1
  14505. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14506. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14507. {
  14508. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14509. DeleteUserId = dto.uesrId,
  14510. IsDel = 1
  14511. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14512. _sqlSugar.CommitTran();
  14513. jw = JsonView(true, "删除成功");
  14514. }
  14515. catch (Exception ex)
  14516. {
  14517. jw = JsonView(false, ex.Message);
  14518. }
  14519. return Ok(jw);
  14520. }
  14521. /// <summary>
  14522. /// 报批行程保存
  14523. /// </summary>
  14524. /// <param name="dto"></param>
  14525. /// <returns></returns>
  14526. [HttpPost]
  14527. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14528. {
  14529. var jw = JsonView(false);
  14530. var Find = dto.Arr.Find(x => x.id == 0);
  14531. if (Find != null)
  14532. {
  14533. jw.Msg = "生成的ID为0!";
  14534. return Ok(jw);
  14535. }
  14536. foreach (var item in dto.Arr)
  14537. {
  14538. foreach (var chi in item.chiList)
  14539. {
  14540. if (chi.parentId == 0)
  14541. {
  14542. chi.parentId = item.id;
  14543. }
  14544. }
  14545. }
  14546. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14547. _sqlSugar.BeginTran();
  14548. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14549. {
  14550. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14551. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14552. {
  14553. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14554. DeleteUserId = dto.UserId,
  14555. IsDel = 1
  14556. }).ExecuteCommand();
  14557. }
  14558. try
  14559. {
  14560. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14561. {
  14562. CreateTime = DateTime.Now,
  14563. CreateUserId = dto.UserId,
  14564. Details = x.details,
  14565. ParentId = x.parentId,
  14566. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14567. Remark = "",
  14568. IsDel = 0
  14569. }).ToList()).ExecuteCommand();
  14570. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14571. {
  14572. Id = x.id,
  14573. Details = x.details,
  14574. ParentId = x.parentId,
  14575. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14576. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14577. {
  14578. Details = x.Details,
  14579. ParentId = x.ParentId,
  14580. Time = x.Time
  14581. }).ExecuteCommand();
  14582. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14583. {
  14584. Id = x.id,
  14585. Date = x.date,
  14586. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14587. {
  14588. Date = x.Date
  14589. }).ExecuteCommand();
  14590. _sqlSugar.CommitTran();
  14591. jw = JsonView(true, "保存成功!");
  14592. }
  14593. catch (Exception ex)
  14594. {
  14595. _sqlSugar.RollbackTran();
  14596. jw = JsonView(false, "保存失败!" + ex.Message);
  14597. }
  14598. return Ok(jw);
  14599. }
  14600. /// <summary>
  14601. /// 报批行程生成
  14602. /// </summary>
  14603. /// <param name="dto"></param>
  14604. /// <returns></returns>
  14605. [HttpPost]
  14606. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14607. {
  14608. var jw = JsonView(false);
  14609. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14610. if (group == null)
  14611. {
  14612. jw.Msg = "暂无该团组!";
  14613. return Ok(jw);
  14614. }
  14615. //黑屏代码数据
  14616. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14617. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14618. {
  14619. jw.Msg = "黑屏代码有误!";
  14620. return Ok(jw);
  14621. }
  14622. foreach (DataRow row in dtBlack.Rows)
  14623. {
  14624. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14625. {
  14626. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14627. return Ok(jw);
  14628. }
  14629. }
  14630. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14631. var resultArr = new ArrayList();
  14632. if (officialActivitiesArr.Count == 0)
  14633. {
  14634. jw.Msg = "暂无公务出访信息!";
  14635. return Ok(jw);
  14636. }
  14637. try
  14638. {
  14639. _sqlSugar.BeginTran();
  14640. DeleteApprovalJourney(new
  14641. Domain.Dtos.Groups.DeleteApprovalJourney
  14642. {
  14643. Diid = dto.Diid,
  14644. uesrId = dto.Userid
  14645. });
  14646. var stay = "-";
  14647. var cityPath = "-";
  14648. //添加城市路径以及住宿地
  14649. //黑屏代码获取时间区间
  14650. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14651. var empty = "【未收入该三字码!请机票同事录入】";
  14652. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14653. for (int i = 0; i < timeArr.Count; i++)
  14654. {
  14655. stay = "-";
  14656. cityPath = "-";
  14657. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14658. DateTime NewData = DateTime.Parse(timeArr[i]);
  14659. 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();
  14660. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14661. if (tbSelect.Length > 0)
  14662. {
  14663. List<string> threeCodeStr = new List<string>();
  14664. bool isTrade = false;
  14665. string trip = string.Empty;
  14666. var rowLast = tbSelect.Last();
  14667. var rowFirst = tbSelect.First();
  14668. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14669. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14670. var takeOffTime = DateTime.Parse(timeArr[i]);
  14671. var fallToTime = DateTime.Parse(timeArr[i]);
  14672. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14673. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14674. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14675. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14676. foreach (var item in tbSelect)
  14677. {
  14678. var start = string.Empty;
  14679. var end = string.Empty;
  14680. var threeCode = item["Three"].ToString() ?? "";
  14681. if (threeCode.Length == 6)
  14682. {
  14683. start = threeCode.Substring(0, 3);
  14684. end = threeCode.Substring(3, 3);
  14685. if (threeCodeStr.Count == 0)
  14686. {
  14687. threeCodeStr.Add(start);
  14688. threeCodeStr.Add(end);
  14689. }
  14690. else
  14691. {
  14692. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14693. {
  14694. threeCodeStr.Add(end);
  14695. }
  14696. else
  14697. {
  14698. threeCodeStr.Add(start);
  14699. threeCodeStr.Add(end);
  14700. }
  14701. }
  14702. }
  14703. //处理机票信息
  14704. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14705. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14706. if (start_Object == null)
  14707. {
  14708. start_Object = new Res_ThreeCode()
  14709. {
  14710. AirPort = empty,
  14711. AirPort_En = empty,
  14712. City = empty,
  14713. Country = empty,
  14714. Four = empty,
  14715. Three = empty,
  14716. };
  14717. }
  14718. if (end_Object == null)
  14719. {
  14720. end_Object = new Res_ThreeCode()
  14721. {
  14722. AirPort = empty,
  14723. AirPort_En = empty,
  14724. City = empty,
  14725. Country = empty,
  14726. Four = empty,
  14727. Three = empty,
  14728. };
  14729. }
  14730. //机型判断
  14731. string airModel = item["AirModel"].ToString();
  14732. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14733. string flightTime = item["FlightTime"].ToString();
  14734. if (flightTime!.Contains(":"))
  14735. {
  14736. flightTime = flightTime.Replace(":", "小时");
  14737. flightTime += "分钟";
  14738. }
  14739. if (flightTime.Contains("H"))
  14740. {
  14741. flightTime = flightTime.Replace("H", "小时");
  14742. }
  14743. if (flightTime.Contains("M"))
  14744. {
  14745. flightTime = flightTime.Replace("M", "分钟");
  14746. }
  14747. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14748. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14749. {
  14750. flightTime = flightDataTime.Hour > 0
  14751. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14752. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14753. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14754. }
  14755. //航班号
  14756. string flightcode = item["Fliagtcode"].ToString();
  14757. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14758. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14759. if (aircompany == null)
  14760. {
  14761. aircompany = new Res_AirCompany
  14762. {
  14763. CnName = hsEmpty,
  14764. EnName = hsEmpty,
  14765. ShortCode = hsEmpty,
  14766. };
  14767. }
  14768. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14769. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14770. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14771. if (isTrade)
  14772. {
  14773. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14774. }
  14775. else
  14776. {
  14777. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14778. }
  14779. }
  14780. chiarr.Add(new Grp_ApprovalTravelDetails
  14781. {
  14782. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14783. CreateTime = DateTime.Now,
  14784. CreateUserId = dto.Userid,
  14785. ParentId = 0,
  14786. Details = trip
  14787. });
  14788. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14789. var last = threeCodeStr.Last();
  14790. foreach (var item in threeCodeStr)
  14791. {
  14792. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14793. if (item.Equals(last))
  14794. {
  14795. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14796. }
  14797. }
  14798. cityPath = cityPath.Trim('-');
  14799. }
  14800. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14801. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14802. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14803. appro.Diid = dto.Diid;
  14804. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14805. appro.Id = thisId;
  14806. appro.CreateUserId = dto.Userid;
  14807. appro.CreateTime = DateTime.Now;
  14808. foreach (var item in gwinfo)
  14809. {
  14810. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14811. chi.Details = "拜访" + item.Client;
  14812. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14813. {
  14814. chi.Details += "," + item.ReqSample;
  14815. }
  14816. chi.ParentId = thisId;
  14817. chi.Time = item.Time;
  14818. chiarr.Add(chi);
  14819. }
  14820. if (chiarr.Count < 5)
  14821. {
  14822. for (int j = chiarr.Count; j < 5; j++)
  14823. {
  14824. chiarr.Add(new
  14825. Grp_ApprovalTravelDetails());
  14826. }
  14827. }
  14828. resultArr.Add(new
  14829. {
  14830. appro.Id,
  14831. appro.Date,
  14832. appro.Diid,
  14833. chiList = chiarr.Select(x1 => new
  14834. {
  14835. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14836. x1.Details,
  14837. x1.ParentId,
  14838. x1.Id
  14839. })
  14840. });
  14841. }
  14842. _sqlSugar.CommitTran();
  14843. jw = JsonView(true, "生成成功!", resultArr);
  14844. }
  14845. catch (Exception ex)
  14846. {
  14847. jw.Code = 400;
  14848. jw.Msg = "生成失败!" + ex.Message;
  14849. }
  14850. return Ok(jw);
  14851. }
  14852. /// <summary>
  14853. /// 报批行程word导出
  14854. /// </summary>
  14855. /// <param name="dto"></param>
  14856. /// <returns></returns>
  14857. [HttpPost]
  14858. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14859. {
  14860. var jw = JsonView(false);
  14861. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14862. if (group == null)
  14863. {
  14864. jw.Msg = "暂无该团组!";
  14865. return Ok(jw);
  14866. }
  14867. //模板路径
  14868. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14869. //载入模板
  14870. Document doc = new Document(tempPath);
  14871. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14872. //获取所填表格的序数
  14873. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14874. Aspose.Words.Tables.Row titleRowClone = null;
  14875. Aspose.Words.Tables.Row CenterRowClone = null;
  14876. int index = 0;
  14877. int indexChi = 0;
  14878. int SetIndex = 0;
  14879. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14880. //获取数据,放到datatable
  14881. foreach (var item in ApprovalTravelArr)
  14882. {
  14883. if (index > 0)
  14884. {
  14885. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14886. tableOne.AppendChild(titleRowClone);
  14887. }
  14888. var textTime = item.Date;
  14889. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14890. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14891. SetIndex++;
  14892. if (ChiRep.Count > 0)
  14893. {
  14894. foreach (var itemChi in ChiRep)
  14895. {
  14896. var txtTime = itemChi.Time;
  14897. var txtDetail = itemChi.Details;
  14898. if (indexChi > 0)
  14899. {
  14900. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14901. tableOne.AppendChild(CenterRowClone);
  14902. }
  14903. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14904. {
  14905. SetCells(tableOne, doc, SetIndex, 0, "");
  14906. SetCells(tableOne, doc, SetIndex, 1, "");
  14907. indexChi++;
  14908. SetIndex++;
  14909. break;
  14910. }
  14911. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14912. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14913. indexChi++;
  14914. SetIndex++;
  14915. }
  14916. }
  14917. else
  14918. {
  14919. if (indexChi > 0)
  14920. {
  14921. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14922. tableOne.AppendChild(CenterRowClone);
  14923. }
  14924. SetCells(tableOne, doc, SetIndex, 0, "");
  14925. SetCells(tableOne, doc, SetIndex, 1, "");
  14926. indexChi++;
  14927. SetIndex++;
  14928. }
  14929. index++;
  14930. }
  14931. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  14932. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14933. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14934. jw.Code = 200;
  14935. jw.Msg = "";
  14936. return Ok(jw);
  14937. }
  14938. private string intToString(int numberVal)
  14939. {
  14940. string numberval = numberVal.ToString();
  14941. Dictionary<char, string> Number = new Dictionary<char, string>();
  14942. Number.Add('1', "一");
  14943. Number.Add('2', "二");
  14944. Number.Add('3', "三");
  14945. Number.Add('4', "四");
  14946. Number.Add('5', "五");
  14947. Number.Add('6', "六");
  14948. Number.Add('7', "七");
  14949. Number.Add('8', "八");
  14950. Number.Add('9', "九");
  14951. string stringNumberVal = string.Empty;
  14952. for (int i = 0; i < numberval.Length; i++)
  14953. {
  14954. if (i == 0)
  14955. {
  14956. stringNumberVal += Number[numberval[i]];
  14957. }
  14958. else if (i >= 1)
  14959. {
  14960. if (numberval[i] == '0')
  14961. {
  14962. stringNumberVal = "十";
  14963. }
  14964. else
  14965. {
  14966. stringNumberVal += "十" + Number[numberval[i]];
  14967. }
  14968. }
  14969. }
  14970. return stringNumberVal;
  14971. }
  14972. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  14973. {
  14974. //获取table中的某个单元格,从0开始
  14975. Cell lshCell = table.Rows[rows].Cells[cells];
  14976. //将单元格中段落移除
  14977. foreach (Node item in lshCell.Paragraphs)
  14978. {
  14979. lshCell.Paragraphs.Remove(item);
  14980. }
  14981. if (val.Contains("\r\n"))
  14982. {
  14983. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  14984. foreach (var item in spArr)
  14985. {
  14986. //新建一个段落
  14987. Paragraph p = new Paragraph(doc);
  14988. var r = new Run(doc, item);
  14989. //把设置的值赋给之前新建的段落
  14990. p.AppendChild(r);
  14991. //将此段落加到单元格内
  14992. lshCell.AppendChild(p);
  14993. }
  14994. }
  14995. else
  14996. {
  14997. //新建一个段落
  14998. Paragraph p = new Paragraph(doc);
  14999. var r = new Run(doc, val);
  15000. //把设置的值赋给之前新建的段落
  15001. p.AppendChild(r);
  15002. //将此段落加到单元格内
  15003. lshCell.AppendChild(p);
  15004. }
  15005. }
  15006. [HttpPost]
  15007. public async Task<IActionResult> ServerHttp(string paramStr)
  15008. {
  15009. paramStr = paramStr.TrimEnd('\'');
  15010. paramStr = paramStr.TrimStart('\'');
  15011. JsonView jw = JsonView(false);
  15012. JObject param = JObject.Parse(paramStr);
  15013. if (!param.ContainsKey("url"))
  15014. {
  15015. jw.Msg = "url null";
  15016. return Ok(jw);
  15017. }
  15018. string url = param["url"]!.ToString();
  15019. var methon = "get";
  15020. Dictionary<string, string> headValues = null;
  15021. string bodyStr = string.Empty;
  15022. if (param.ContainsKey("methon"))
  15023. {
  15024. methon = param["methon"]!.ToString().ToLower();
  15025. }
  15026. if (param.ContainsKey("header"))
  15027. {
  15028. var header = param["header"]!.ToString();
  15029. JObject headerJobject = JObject.Parse(header);
  15030. headValues = new Dictionary<string, string>();
  15031. foreach (JProperty item in headerJobject.Properties())
  15032. {
  15033. var value = item.Value.ToString();
  15034. var head = item.Path;
  15035. headValues.Add(head, value);
  15036. }
  15037. }
  15038. HttpClient client = new HttpClient();
  15039. string responseString = string.Empty;
  15040. StringContent content = null;
  15041. if (headValues != null)
  15042. {
  15043. foreach (var item in headValues.Keys)
  15044. {
  15045. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15046. {
  15047. if (param.ContainsKey("body"))
  15048. {
  15049. bodyStr = param["body"]!.ToString();
  15050. }
  15051. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15052. }
  15053. else
  15054. {
  15055. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15056. }
  15057. }
  15058. }
  15059. try
  15060. {
  15061. if (methon == "get")
  15062. {
  15063. responseString = await client.GetStringAsync(url);
  15064. }
  15065. else if (methon == "post")
  15066. {
  15067. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15068. {
  15069. Content = content
  15070. };
  15071. var response = await client.SendAsync(request);
  15072. try
  15073. {
  15074. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15075. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15076. {
  15077. using (StreamReader reader = new StreamReader(gzipStream))
  15078. {
  15079. responseString = await reader.ReadToEndAsync();
  15080. }
  15081. }
  15082. }
  15083. catch (Exception)
  15084. {
  15085. responseString = await response.Content.ReadAsStringAsync();
  15086. }
  15087. }
  15088. else
  15089. {
  15090. responseString = "methon error";
  15091. }
  15092. jw = JsonView(true, "success", responseString);
  15093. }
  15094. catch (Exception ex)
  15095. {
  15096. jw.Msg = "error " + ex.Message;
  15097. jw.Data = ex.StackTrace;
  15098. }
  15099. finally
  15100. {
  15101. client.Dispose();
  15102. }
  15103. return Ok(jw);
  15104. }
  15105. #endregion
  15106. #region 团组接待意见调查
  15107. /// <summary>
  15108. /// 团组接待意见调查 - 信息管理
  15109. /// 基础数据(团组)
  15110. /// </summary>
  15111. /// <param name="dto"></param>
  15112. /// <returns></returns>
  15113. [HttpGet]
  15114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15115. public async Task<IActionResult> OpinionaireInit()
  15116. {
  15117. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15118. .Select(x => new
  15119. {
  15120. x.Id,
  15121. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15122. })
  15123. .OrderByDescending(x => x.Id)
  15124. .ToListAsync();
  15125. return Ok(JsonView(groupData, groupData.Count));
  15126. }
  15127. /// <summary>
  15128. /// 团组接待意见调查 - 信息管理
  15129. /// 列表
  15130. /// </summary>
  15131. /// <param name="groupId"></param>
  15132. /// <returns></returns>
  15133. [HttpGet("{groupId}")]
  15134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15135. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15136. {
  15137. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15138. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15139. .Select(x => new
  15140. {
  15141. x.Id,
  15142. x.TourGuideName,
  15143. x.CityName,
  15144. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15145. x.CreateTime
  15146. })
  15147. .OrderBy(x => x.Id)
  15148. .ToListAsync();
  15149. return Ok(JsonView(data));
  15150. }
  15151. /// <summary>
  15152. /// 团组接待意见调查 - 信息管理
  15153. /// 保存
  15154. /// </summary>
  15155. /// <param name="dto"></param>
  15156. /// <returns></returns>
  15157. [HttpPost]
  15158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15159. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15160. {
  15161. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15162. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15163. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15164. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15165. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15166. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15167. _opinionaireRep.BeginTran();
  15168. if (addData != null && addData.Count > 0)
  15169. {
  15170. foreach (var item in addData)
  15171. {
  15172. item.CreateUserId = currUserInfo.UserId;
  15173. item.DiId = dto.DiId;
  15174. }
  15175. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15176. }
  15177. if (updData != null && updData.Count > 0)
  15178. {
  15179. var upd = await _opinionaireRep._sqlSugar
  15180. .Updateable(updData)
  15181. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15182. .WhereColumns(x => new { x.Id })
  15183. .ExecuteCommandAsync();
  15184. }
  15185. _opinionaireRep.CommitTran();
  15186. return Ok(JsonView("操作成功!"));
  15187. }
  15188. /// <summary>
  15189. /// 团组接待意见调查 - 信息管理
  15190. /// 删除
  15191. /// </summary>
  15192. /// <param name="id"></param>
  15193. /// <returns></returns>
  15194. [HttpDelete("{id}")]
  15195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15196. public async Task<IActionResult> OpinionaireManageDel(int id)
  15197. {
  15198. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15199. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15200. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15201. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15202. if (!del) return Ok(JsonView("操作失败!"));
  15203. return Ok(JsonView("操作成功!"));
  15204. }
  15205. /// <summary>
  15206. /// 团组接待意见调查 - 用户
  15207. /// 列表
  15208. /// </summary>
  15209. /// <param name="id"></param>
  15210. /// <returns></returns>
  15211. [HttpGet("{diId}")]
  15212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15213. public async Task<IActionResult> OpinionaireUserList(int diId)
  15214. {
  15215. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15216. var sql = string.Format(@"
  15217. SELECT
  15218. o.Id,
  15219. o.DiId,
  15220. di.TeamName AS 'GroupName',
  15221. di.VisitPNumber AS 'PeopleNumber',
  15222. di.ClientName AS 'LeadGroup',
  15223. di.VisitCountry AS 'Travel',
  15224. di.VisitDays AS 'Days',
  15225. o.CityName,
  15226. o.TourGuideName,
  15227. o.Catering,
  15228. o.CateringReason,
  15229. o.Stay,
  15230. o.StayReason,
  15231. o.[Route],
  15232. o.RouteReason,
  15233. o.OfficialActivity,
  15234. o.OfficialActivityReason,
  15235. o.TourGuide,
  15236. o.TourGuideReason,
  15237. o.[Translate],
  15238. o.TranslateReason,
  15239. o.Trip,
  15240. o.TripReason,
  15241. o.ESFileName,
  15242. o.SignatureDate,
  15243. o.Remark
  15244. FROM
  15245. Grp_Opinionaire o
  15246. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15247. WHERE
  15248. o.IsDel = 0
  15249. AND o.DiId = {0}
  15250. ORDER BY
  15251. o.Id ASC", diId);
  15252. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15253. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15254. return Ok(JsonView(data));
  15255. }
  15256. /// <summary>
  15257. /// 团组接待意见调查 - 用户
  15258. /// 保存
  15259. /// </summary>
  15260. /// <param name="id"></param>
  15261. /// <returns></returns>
  15262. [HttpPost]
  15263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15264. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15265. {
  15266. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15267. foreach (var item in dto)
  15268. {
  15269. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15270. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15271. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15272. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15273. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15274. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15275. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15276. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15277. }
  15278. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15279. if (!Directory.Exists(filePathBase))
  15280. {
  15281. Directory.CreateDirectory(filePathBase);
  15282. }
  15283. #region 上传文件
  15284. var filePaths = new List<string>();
  15285. foreach (var item in dto)
  15286. {
  15287. var file = item.File;
  15288. // 将文件保存到指定位置
  15289. var filePath = Path.Combine(filePathBase, file.FileName);
  15290. using (var stream = new FileStream(filePath, FileMode.Create))
  15291. {
  15292. await file.CopyToAsync(stream);
  15293. }
  15294. //验证文件是否上传成功
  15295. if (!System.IO.File.Exists(filePath))
  15296. {
  15297. foreach (var filePathStr in filePaths)
  15298. {
  15299. System.IO.File.Delete(filePathStr);
  15300. }
  15301. return Ok(JsonView(false, "文件上传失败!"));
  15302. }
  15303. item.ESFileName = file.FileName;
  15304. }
  15305. #endregion
  15306. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15307. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15308. .UpdateColumns(x => new
  15309. {
  15310. x.Catering,
  15311. x.CateringReason,
  15312. x.Stay,
  15313. x.StayReason,
  15314. x.Route,
  15315. x.RouteReason,
  15316. x.OfficialActivity,
  15317. x.OfficialActivityReason,
  15318. x.TourGuide,
  15319. x.TourGuideReason,
  15320. x.Translate,
  15321. x.TranslateReason,
  15322. x.Trip,
  15323. x.TripReason,
  15324. x.ESFileName,
  15325. x.SignatureDate,
  15326. x.Remark
  15327. })
  15328. .WhereColumns(x => new { x.Id })
  15329. .ExecuteCommandAsync();
  15330. if (upd < 1)
  15331. {
  15332. foreach (var filePathStr in filePaths)
  15333. {
  15334. System.IO.File.Delete(filePathStr);
  15335. }
  15336. return Ok(JsonView(false));
  15337. }
  15338. return Ok(JsonView(true));
  15339. }
  15340. #endregion
  15341. // /// <summary>
  15342. // ///
  15343. // /// </summary>
  15344. // /// <param name="_dto"></param>
  15345. // /// <returns></returns>
  15346. // [HttpPost]
  15347. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15348. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15349. // {
  15350. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15351. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15352. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15353. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15354. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15355. // dic_psg.Add("客人", 974);
  15356. // dic_psg.Add("司机", 975);
  15357. // dic_psg.Add("导游", 976);
  15358. // dic_psg.Add("公司内部人员", 977);
  15359. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15360. // foreach (var item in list_visa)
  15361. // {
  15362. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15363. // temp.Id = item.Id;
  15364. // temp.DIId = item.DIId;
  15365. // temp.VisaClient = item.VisaClient;
  15366. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15367. // temp.VisaCurrency = item.VisaCurrency;
  15368. // temp.IsThird = item.IsThird;
  15369. // if (dic_psg.ContainsKey(item.PassengerType))
  15370. // {
  15371. // temp.PassengerType = dic_psg[item.PassengerType];
  15372. // }
  15373. // else {
  15374. // temp.PassengerType = -1;
  15375. // }
  15376. // temp.VisaNumber = item.VisaNumber;
  15377. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15378. // temp.CreateUserId = item.Operators;
  15379. // DateTime dt_ct;
  15380. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15381. // if (b_ct)
  15382. // {
  15383. // temp.CreateTime = dt_ct;
  15384. // }
  15385. // else
  15386. // {
  15387. // temp.CreateTime = DateTime.Now;
  15388. // }
  15389. // temp.DeleteTime = "";
  15390. // temp.DeleteUserId = 0;
  15391. // temp.Remark = item.Remark;
  15392. // if (string.IsNullOrEmpty(temp.Remark)) {
  15393. // temp.Remark = "";
  15394. // }
  15395. // temp.IsDel = item.IsDel;
  15396. // temp.VisaDescription = item.VisaAttachment;
  15397. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15398. //([Id]
  15399. // ,[DIId]
  15400. // ,[VisaClient]
  15401. // ,[VisaPrice]
  15402. // ,[VisaCurrency]
  15403. // ,[IsThird]
  15404. // ,[PassengerType]
  15405. // ,[VisaNumber]
  15406. // ,[VisaFreeNumber]
  15407. // ,[CreateUserId]
  15408. // ,[CreateTime]
  15409. // ,[DeleteTime]
  15410. // ,[DeleteUserId]
  15411. // ,[Remark]
  15412. // ,[IsDel]
  15413. // ,[visaDescription])
  15414. // VALUES
  15415. // ({0},{1},'{2}',{3},{4}
  15416. //,{5},{6},{7},{8},{9}
  15417. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15418. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15419. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15420. //);
  15421. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15422. // }
  15423. // return Ok(JsonView(true, "操作成功!"));
  15424. // }
  15425. /// <summary>
  15426. /// 123132123
  15427. /// </summary>
  15428. /// <param name="_dto"></param>
  15429. /// <returns></returns>
  15430. [HttpPost]
  15431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15432. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15433. {
  15434. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15435. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15436. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15437. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15438. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15439. dicDetail.Add(789, 1034);
  15440. dicDetail.Add(790, 1035);
  15441. dicDetail.Add(791, 1036);
  15442. dicDetail.Add(792, 1037);
  15443. dicDetail.Add(793, 1038);
  15444. dicDetail.Add(794, 1039);
  15445. dicDetail.Add(795, 1040);
  15446. dicDetail.Add(796, 1041);
  15447. dicDetail.Add(797, 1042);
  15448. dicDetail.Add(798, 1043);
  15449. dicDetail.Add(801, 1044);
  15450. dicDetail.Add(802, 1045);
  15451. dicDetail.Add(803, 1046);
  15452. Dictionary<int, int> dic = new Dictionary<int, int>();
  15453. dic.Add(806, 1027);
  15454. dic.Add(807, 1028);
  15455. dic.Add(808, 1029);
  15456. dic.Add(809, 1030);
  15457. dic.Add(810, 1031);
  15458. dic.Add(811, 1032);
  15459. dic.Add(812, 1033);
  15460. foreach (var item in list_visa)
  15461. {
  15462. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15463. temp.Coefficient = item.coefficient;
  15464. DateTime dtCrt;
  15465. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15466. if (b1)
  15467. {
  15468. temp.CreateTime = dtCrt;
  15469. }
  15470. else
  15471. {
  15472. temp.CreateTime = DateTime.Now;
  15473. }
  15474. temp.CreateUserId = item.Operators;
  15475. temp.DeleteTime = "";
  15476. temp.DeleteUserId = 0;
  15477. temp.DiId = int.Parse(item.DIID);
  15478. temp.FilePath = item.FilePath;
  15479. temp.IsDel = item.IsDel;
  15480. temp.Price = item.Price;
  15481. temp.PriceCount = 1;
  15482. temp.PriceCurrency = item.Currency;
  15483. int detailId = 0;
  15484. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15485. {
  15486. detailId = dicDetail[item.PriceTypeDetail];
  15487. }
  15488. temp.PriceDetailType = detailId;
  15489. temp.PriceDt = DateTime.Now;
  15490. temp.PriceName = item.PriceName;
  15491. temp.PriceSum = item.Price;
  15492. int tid = 0;
  15493. if (dic.ContainsKey(item.PriceType))
  15494. {
  15495. tid = dic[item.PriceType];
  15496. }
  15497. temp.PriceType = tid;
  15498. temp.Remark = item.Remark;
  15499. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15500. }
  15501. return Ok(JsonView(true, "操作成功!"));
  15502. }
  15503. [HttpPost]
  15504. public IActionResult TimeTest()
  15505. {
  15506. var jw = JsonView(false, "error");
  15507. _sqlSugar.BeginTran();
  15508. try
  15509. {
  15510. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  15511. .Select(x => new Crm_NewClientData
  15512. {
  15513. Id = x.Id,
  15514. Client = x.Client,
  15515. Contact = x.Contact,
  15516. Location = x.Location,
  15517. })
  15518. .ToList();
  15519. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  15520. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  15521. Stopwatch stopwatch = new Stopwatch();
  15522. // 开始计时
  15523. stopwatch.Start();
  15524. foreach (var item in clientList)
  15525. {
  15526. EncryptionProcessor.DecryptProperties(item);
  15527. }
  15528. stopwatch.Stop();
  15529. jw.Code = 200;
  15530. jw.Data = stopwatch.ElapsedMilliseconds;
  15531. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  15532. }
  15533. catch (Exception ex)
  15534. {
  15535. jw.Code = 400;
  15536. jw.Msg = ex.Message;
  15537. }
  15538. return Ok(jw);
  15539. }
  15540. }
  15541. }