GroupsController.cs 832 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905
  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. #region 页面操作权限验证
  1502. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1503. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1504. #endregion
  1505. #endregion
  1506. var _view = new Grp_CreditCardPaymentView();
  1507. var clientNameList = getSimplClientList(_dto.DiId);
  1508. #region 费用清单
  1509. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1510. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1511. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1512. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1513. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1514. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1515. /*
  1516. * 76://酒店预订
  1517. */
  1518. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1519. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1520. /*
  1521. * 79://车/导游地接
  1522. */
  1523. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1524. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1525. /*
  1526. * 80: //签证
  1527. */
  1528. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1529. /*
  1530. *81: //邀请/公务活动
  1531. */
  1532. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1533. /*
  1534. * 82: //团组客户保险
  1535. */
  1536. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1537. /*
  1538. * Lable = 85 机票预订
  1539. */
  1540. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1541. /*
  1542. * 85 机票预定
  1543. */
  1544. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1545. /*
  1546. * 98 其他款项
  1547. */
  1548. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1549. /*
  1550. * 285:收款退还
  1551. */
  1552. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1553. /*
  1554. * 1015: //超支费用
  1555. */
  1556. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1557. /*
  1558. * 币种信息
  1559. */
  1560. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1561. /*
  1562. * 车/导游地接 费用类型
  1563. */
  1564. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1565. /*
  1566. * 车/导游地接 费用类型
  1567. */
  1568. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1569. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1570. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1571. /*
  1572. * 用户信息
  1573. */
  1574. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1575. /*
  1576. * 费用模块
  1577. */
  1578. var sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1579. string priceModule = string.Empty;
  1580. if (sdPriceName != null)
  1581. {
  1582. priceModule = sdPriceName.Name;
  1583. }
  1584. /*
  1585. * 成本信息
  1586. */
  1587. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1588. decimal _groupRate = 0.0000M;
  1589. string _groupCurrencyCode = "-";
  1590. if (groupCost != null)
  1591. {
  1592. _groupRate = groupCost.Rate;
  1593. if (int.TryParse(groupCost.Currency, out int _currency))
  1594. {
  1595. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1596. }
  1597. else _groupCurrencyCode = groupCost.Currency;
  1598. }
  1599. string costContentSql = $"Select * From Grp_GroupCost";
  1600. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1601. //处理日期为空的天数
  1602. for (int i = 0; i < groupCostDetails.Count; i++)
  1603. if (i != 0)
  1604. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1605. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1606. /*
  1607. * 处理详情数据
  1608. */
  1609. foreach (var entity in entityList)
  1610. {
  1611. var _detail = new Grp_CreditCardPaymentDetailView();
  1612. _detail.Id = entity.Id;
  1613. _detail.PriceName = priceModule;
  1614. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1615. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1616. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1617. //处理金额
  1618. if (entity.CTable == 1015)
  1619. {
  1620. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1621. if (czInfo != null)
  1622. {
  1623. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1624. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1625. }
  1626. }
  1627. /*
  1628. * 应付款金额
  1629. */
  1630. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1631. string PaymentCurrency_WaitPay = "Unknown";
  1632. string hotelCurrncyCode = "Unknown";
  1633. string hotelCurrncyName = "Unknown";
  1634. if (sdPaymentCurrency_WaitPay != null)
  1635. {
  1636. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1637. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1638. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1639. if (hotelCurrncyCode.Equals("CNY"))
  1640. {
  1641. entity.DayRate = 1.0000M;
  1642. }
  1643. }
  1644. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1645. /*
  1646. * 此次付款金额
  1647. */
  1648. decimal CurrPayStr = 0.00M,
  1649. OriginalCurrPay = 0.00M;
  1650. if (entity.PayPercentage == 0)
  1651. {
  1652. if (entity.PayThenMoney != 0)
  1653. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1654. }
  1655. else
  1656. {
  1657. if (entity.PayMoney != 0)
  1658. {
  1659. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1660. }
  1661. }
  1662. //if (_dto.Label == 79)
  1663. //{
  1664. // string original = string.Empty;
  1665. // if (hotelCurrncyCode.Equals("CNY"))
  1666. // {
  1667. // OriginalCurrPay = CurrPayStr;
  1668. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1669. // }
  1670. // else
  1671. // {
  1672. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1673. // //760 EUR(7600.00 CNY)
  1674. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1675. // }
  1676. //}
  1677. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1678. string original = string.Empty;
  1679. if (hotelCurrncyCode.Equals("CNY"))
  1680. {
  1681. OriginalCurrPay = CurrPayStr;
  1682. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1683. }
  1684. else
  1685. {
  1686. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1687. //760 EUR(7600.00 CNY)
  1688. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1689. }
  1690. /*
  1691. * 剩余尾款
  1692. */
  1693. decimal BalanceStr = 0;
  1694. if (CurrPayStr != 0)
  1695. {
  1696. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1697. BalanceStr = 0;
  1698. else
  1699. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1700. }
  1701. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1702. /*
  1703. * Bus名称
  1704. */
  1705. _detail.BusName = "待增加";
  1706. /*
  1707. *费用所属
  1708. */
  1709. switch (entity.CTable)
  1710. {
  1711. case 76://酒店预订
  1712. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1713. if (hotelReservations != null)
  1714. {
  1715. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1716. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1717. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1718. string roomFeeStr = "", roomFeestr1 = "";
  1719. //是否比较房型价格
  1720. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1721. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1722. roomFeeStr += $"<br/>";
  1723. var roomTotal = 0.00M;
  1724. if (hotelReservations.SingleRoomPrice > 0)
  1725. {
  1726. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1727. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1728. __isSingle = true;
  1729. roomTotal += fee;
  1730. }
  1731. if (hotelReservations.DoubleRoomPrice > 0)
  1732. {
  1733. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1734. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1735. __isDouble = true;
  1736. roomTotal += fee;
  1737. }
  1738. if (hotelReservations.SuiteRoomPrice > 0)
  1739. {
  1740. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1741. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1742. __isSuite = true;
  1743. roomTotal += fee;
  1744. }
  1745. if (hotelReservations.OtherRoomPrice > 0)
  1746. {
  1747. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1748. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1749. __isOther = true;
  1750. roomTotal += fee;
  1751. }
  1752. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1753. else roomFeeStr += " 0.00 * 0";
  1754. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1755. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1756. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1757. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1758. /*
  1759. * 费用类型
  1760. * 1:房费
  1761. * 2:早餐
  1762. * 3:地税
  1763. * 4:城市税
  1764. * </summary>
  1765. */
  1766. //地税
  1767. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1768. if (governmentRentData != null)
  1769. {
  1770. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1771. governmentRentFee = governmentRentData.Price;
  1772. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1773. if (governmentRentCurrData != null)
  1774. {
  1775. governmentRentCode = governmentRentCurrData.Name;
  1776. governmentRentName = $"({governmentRentCurrData.Remark})";
  1777. }
  1778. }
  1779. //城市税
  1780. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1781. if (cityTaxData != null)
  1782. {
  1783. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1784. cityTaxFee = cityTaxData.Price;
  1785. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1786. if (cityTaxCurrData != null)
  1787. {
  1788. cityTaxCode = cityTaxCurrData.Name;
  1789. cityTaxName = $"({cityTaxCurrData.Remark})";
  1790. }
  1791. }
  1792. //酒店早餐
  1793. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1794. if (breakfastData != null)
  1795. {
  1796. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1797. breakfastFee = breakfastData.Price;
  1798. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1799. if (breakfastCurrData != null)
  1800. {
  1801. breakfastCode = breakfastCurrData.Name;
  1802. breakfastName = $"({breakfastCurrData.Remark})";
  1803. }
  1804. }
  1805. //房间费用
  1806. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1807. if (roomData != null)
  1808. {
  1809. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1810. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1811. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1812. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1813. roomFee = roomData.Price;
  1814. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1815. if (roomCurrData != null)
  1816. {
  1817. roomCode = roomCurrData.Name;
  1818. roomName = $"({roomCurrData.Remark})";
  1819. }
  1820. }
  1821. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1822. string hotelCostStr = "";
  1823. decimal hotelCsotTotal = 0.00M;
  1824. if (groupCost != null)
  1825. {
  1826. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1827. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1828. }
  1829. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1830. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1831. string hotelCost_day = "";
  1832. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1833. foreach (var item in hotelCostDetails1)
  1834. {
  1835. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1836. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1837. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1838. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1839. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1840. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1841. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1842. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1843. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1844. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1845. hotelCost_day += @$"<br/>";
  1846. }
  1847. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1848. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  1849. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  1850. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  1851. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1852. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1853. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1854. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1855. $"房间说明: {hotelReservations.Remark} <br/>" +
  1856. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  1857. $"{hotelBreakfastStr}" +
  1858. $"{hotelGovernmentRentStr}" +
  1859. $"{hotelCityTaxStr}";
  1860. _detail.PriceNameContent = hotelReservations.HotelName;
  1861. }
  1862. break;
  1863. case 79://车/导游地接
  1864. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1865. if (touristGuideGroundReservations != null)
  1866. {
  1867. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1868. {
  1869. _detail.BusName = touristGuideGroundReservations.BusName;
  1870. }
  1871. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1872. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1873. //if (isInt)
  1874. //{
  1875. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1876. // if (cityInfo != null)
  1877. // {
  1878. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1879. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1880. // if (carFeeItem != null)
  1881. // {
  1882. // nameContent += $@"({carFeeItem.Name})";
  1883. // }
  1884. // _detail.PriceNameContent = nameContent;
  1885. // }
  1886. //}
  1887. //else
  1888. //{
  1889. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1890. //}
  1891. var touristGuideGroundReservationsContents =
  1892. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1893. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1894. foreach (var item in touristGuideGroundReservationsContents)
  1895. {
  1896. string typeName = "Unknown";
  1897. string carCurrencyCode = "Unknown";
  1898. string carCurrencyName = "Unknown";
  1899. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1900. if (carTypeData != null) typeName = carTypeData.Name;
  1901. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1902. if (currencyData != null)
  1903. {
  1904. carCurrencyCode = currencyData.Name;
  1905. carCurrencyName = currencyData.Remark;
  1906. }
  1907. //op、成本 币种是否一致
  1908. bool IsCurrencyAgreement = false;
  1909. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1910. string opCostStr = string.Empty;
  1911. decimal opCostTypePrice = 0.00M;
  1912. #region 处理成本各项费用
  1913. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1914. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1915. if (opCost.Count > 0)
  1916. {
  1917. switch (item.SId)
  1918. {
  1919. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1920. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1921. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1922. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1923. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1924. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1925. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1926. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1927. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1928. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1929. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1930. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1931. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1932. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1933. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1934. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1935. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1936. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1937. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1938. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1939. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1940. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1941. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1942. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1943. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1944. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1945. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1946. }
  1947. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1948. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1949. }
  1950. #endregion
  1951. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1952. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1953. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1954. $"{opTypeStr} {opCostStr}<br/>" +
  1955. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1956. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1957. }
  1958. _detail.PriceMsgContent = priceMsg;
  1959. }
  1960. break;
  1961. case 80: //签证
  1962. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1963. if (visaInfo != null)
  1964. {
  1965. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1966. _detail.PriceNameContent = visaInfo.VisaDescription;
  1967. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1968. }
  1969. break;
  1970. case 81: //邀请/公务活动
  1971. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1972. if (_ioa != null)
  1973. {
  1974. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1975. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1976. sendCurrName = "Unknown", //快递费用币种 Name
  1977. sendCurrCode = "Unknown", //快递费用币种 Code
  1978. eventsCurrName = "Unknown", //公务活动费币种 Name
  1979. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1980. translateCurrName = "Unknown", //公务翻译费 Name
  1981. translateCurrCode = "Unknown"; //公务翻译费 Code
  1982. #region 处理费用币种
  1983. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1984. if (inviteCurrData != null)
  1985. {
  1986. inviteCurrName = inviteCurrData.Remark;
  1987. inviteCurrCode = inviteCurrData.Name;
  1988. }
  1989. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1990. if (sendCurrData != null)
  1991. {
  1992. sendCurrName = sendCurrData.Remark;
  1993. sendCurrCode = sendCurrData.Name;
  1994. }
  1995. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1996. if (eventsCurrData != null)
  1997. {
  1998. eventsCurrName = eventsCurrData.Remark;
  1999. eventsCurrCode = eventsCurrData.Name;
  2000. }
  2001. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2002. if (translateCurrData != null)
  2003. {
  2004. translateCurrName = translateCurrData.Remark;
  2005. translateCurrCode = translateCurrData.Name;
  2006. }
  2007. #endregion
  2008. _detail.PriceNameContent = _ioa.InviterArea;
  2009. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2010. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2011. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2012. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2013. $@"备注:" + _ioa.Remark + "<br/>";
  2014. }
  2015. break;
  2016. case 82: //团组客户保险
  2017. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2018. if (customers != null)
  2019. {
  2020. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2021. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2022. }
  2023. break;
  2024. case 85: //机票预订
  2025. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2026. if (jpRes != null)
  2027. {
  2028. string FlightsDescription = jpRes.FlightsDescription;
  2029. string PriceDescription = jpRes.PriceDescription;
  2030. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2031. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2032. }
  2033. break;
  2034. case 98://其他款项
  2035. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2036. if (gdpRes != null)
  2037. {
  2038. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2039. _detail.PriceNameContent = gdpRes.PriceName;
  2040. }
  2041. break;
  2042. case 285://收款退还
  2043. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2044. if (refundAndOtherMoney != null)
  2045. {
  2046. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2047. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2048. }
  2049. break;
  2050. case 751://酒店早餐
  2051. break;
  2052. case 1015://超支费用
  2053. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2054. if (groupExtraCost != null)
  2055. {
  2056. _detail.PriceNameContent = groupExtraCost.PriceName;
  2057. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2058. }
  2059. break;
  2060. default:
  2061. break;
  2062. }
  2063. /*
  2064. * 申请人
  2065. */
  2066. string operatorName = " - ";
  2067. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2068. if (_opUser != null)
  2069. {
  2070. operatorName = _opUser.CnName;
  2071. }
  2072. _detail.OperatorName = operatorName;
  2073. /*
  2074. * 审核人
  2075. */
  2076. string auditOperatorName = "Unknown";
  2077. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2078. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2079. else
  2080. {
  2081. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2082. if (_adUser != null)
  2083. {
  2084. auditOperatorName = _adUser.CnName;
  2085. }
  2086. }
  2087. _detail.AuditOperatorName = auditOperatorName;
  2088. /*
  2089. * 超预算比例
  2090. */
  2091. string overBudgetStr = "";
  2092. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2093. else if (entity.ExceedBudget == 0)
  2094. {
  2095. if (entity.CTable == 76 || entity.CTable == 79)
  2096. {
  2097. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2098. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2099. }
  2100. else
  2101. {
  2102. overBudgetStr = "未超预算";
  2103. }
  2104. }
  2105. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2106. _detail.OverBudget = overBudgetStr;
  2107. decimal auditFee = 0.00M; //已审核金额 人名币
  2108. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始币种
  2109. decimal unAuditFee = 0.00M; //未审核款项
  2110. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2111. {
  2112. auditedFeeOriginal = entity.PayMoney;
  2113. auditFee = CurrPayStr;
  2114. }
  2115. else if (entity.IsAuditGM == 0)
  2116. {
  2117. unAuditFee = OriginalCurrPay;
  2118. OriginalCurrPay = 0.00M;
  2119. }
  2120. /*
  2121. * 费用总计
  2122. */
  2123. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2124. {
  2125. CurrencyId = entity.PaymentCurrency,
  2126. CurrencyName = PaymentCurrency_WaitPay,
  2127. AmountPayable = entity.PayMoney,
  2128. ThisPayment = OriginalCurrPay,
  2129. BalancePayment = BalanceStr,
  2130. AuditedFunds = auditFee,
  2131. AuditedFundsOriginal = auditedFeeOriginal,
  2132. UnAuditFunds = unAuditFee
  2133. });
  2134. _detail.IsAuditGM = entity.IsAuditGM;
  2135. detailList.Add(_detail);
  2136. }
  2137. #endregion
  2138. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2139. /*
  2140. * 下方描述处理
  2141. */
  2142. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2143. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2144. if (ccpCurrencyPrice != null)
  2145. {
  2146. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2147. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2148. }
  2149. else
  2150. {
  2151. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2152. }
  2153. string amountPayableStr = string.Format(@"应付款总金额: ");
  2154. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2155. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2156. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2157. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2158. foreach (var item in nonDuplicat)
  2159. {
  2160. var currencyName = item.CurrencyName;
  2161. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2162. if (strs.Count > 0)
  2163. {
  2164. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2165. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2166. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2167. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2168. //单独处理此次付款金额
  2169. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2170. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2171. //单独处理已审核费用
  2172. //if (item.CurrencyId == 836) //人民币
  2173. //{
  2174. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2175. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2176. //}
  2177. //else
  2178. //{
  2179. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2180. //}
  2181. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment), currencyName);
  2182. //未审核费用
  2183. var unAudit = strs.Sum(x => x.UnAuditFunds);
  2184. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", unAudit.ToString("#0.00"), currencyName);
  2185. }
  2186. }
  2187. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2188. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2189. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2190. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2191. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2192. var _view1 = new
  2193. {
  2194. PageFuncAuth = pageFunAuthView,
  2195. Data = _view
  2196. };
  2197. return Ok(JsonView(_view1));
  2198. }
  2199. catch (Exception ex)
  2200. {
  2201. return Ok(JsonView(false, ex.Message));
  2202. }
  2203. }
  2204. /// <summary>
  2205. /// 费用审核
  2206. /// 修改团组费用审核状态
  2207. /// </summary>
  2208. /// <param name="_dto">参数Json字符串</param>
  2209. /// <returns></returns>
  2210. [HttpPost]
  2211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2212. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2213. {
  2214. #region 参数验证
  2215. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2216. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2217. #endregion
  2218. #region 页面操作权限验证
  2219. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2220. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2221. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2222. #endregion
  2223. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2224. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2225. DateTime dtNow = DateTime.Now;
  2226. _groupRepository.BeginTran();
  2227. int rst = 0;
  2228. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2229. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2230. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2231. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2232. List<dynamic> msgDatas = new List<dynamic>();
  2233. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2234. foreach (var item in idList)
  2235. {
  2236. int CreditId = int.Parse(item);
  2237. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2238. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2239. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2240. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2241. .Where(s => s.Id == CreditId)
  2242. .ExecuteCommandAsync();
  2243. if (result < 1)
  2244. {
  2245. rst = -1;
  2246. _groupRepository.RollbackTran();
  2247. return Ok(JsonView(false, "操作失败并回滚!"));
  2248. }
  2249. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2250. if (creditData != null)
  2251. {
  2252. #region 应用通知配置
  2253. try
  2254. {
  2255. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2256. }
  2257. catch (Exception ex)
  2258. {
  2259. }
  2260. #endregion
  2261. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2262. string groupNameStr = string.Empty;
  2263. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2264. if (groupData != null) groupNameStr = groupData.TeamName;
  2265. string creditTypeStr = string.Empty;
  2266. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2267. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2268. string creditCurrency = string.Empty;
  2269. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2270. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2271. if (creditCurrency.Equals("CNY"))
  2272. {
  2273. creditData.DayRate = 1.0000M;
  2274. }
  2275. if (creditData.PayPercentage == 0.00M)
  2276. {
  2277. creditData.PayPercentage = 100M;
  2278. }
  2279. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2280. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2281. string msgContent = "";
  2282. if (creditCurrency.Equals("CNY"))
  2283. {
  2284. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2285. }
  2286. else
  2287. {
  2288. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2289. }
  2290. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2291. }
  2292. }
  2293. if (rst == 0)
  2294. {
  2295. _groupRepository.CommitTran();
  2296. foreach (var item in msgDatas)
  2297. {
  2298. //发送消息
  2299. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2300. }
  2301. #region 应用推送
  2302. try
  2303. {
  2304. foreach (var ccpId in dic_ccp_user.Keys)
  2305. {
  2306. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2307. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2308. }
  2309. }
  2310. catch (Exception)
  2311. {
  2312. }
  2313. #endregion
  2314. return Ok(JsonView(true, "操作成功!"));
  2315. }
  2316. return Ok(JsonView(false, "操作失败!"));
  2317. }
  2318. #endregion
  2319. #region 机票费用录入
  2320. /// <summary>
  2321. /// 机票录入当前登录人可操作团组
  2322. /// </summary>
  2323. /// <param name="dto"></param>
  2324. /// <returns></returns>
  2325. [HttpPost]
  2326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2327. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2328. {
  2329. try
  2330. {
  2331. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2332. if (groupData.Code != 0)
  2333. {
  2334. return Ok(JsonView(false, groupData.Msg));
  2335. }
  2336. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2337. }
  2338. catch (Exception ex)
  2339. {
  2340. return Ok(JsonView(false, "程序错误!"));
  2341. throw;
  2342. }
  2343. }
  2344. /// <summary>
  2345. /// 机票费用录入列表
  2346. /// </summary>
  2347. /// <param name="dto"></param>
  2348. /// <returns></returns>
  2349. [HttpPost]
  2350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2351. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2352. {
  2353. try
  2354. {
  2355. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2356. if (groupData.Code != 0)
  2357. {
  2358. return Ok(JsonView(false, groupData.Msg));
  2359. }
  2360. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2361. }
  2362. catch (Exception ex)
  2363. {
  2364. return Ok(JsonView(false, ex.Message));
  2365. throw;
  2366. }
  2367. }
  2368. /// <summary>
  2369. /// 根据id查询费用录入信息
  2370. /// </summary>
  2371. /// <param name="dto"></param>
  2372. /// <returns></returns>
  2373. [HttpPost]
  2374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2375. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2376. {
  2377. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2378. if (groupData.Code != 0)
  2379. {
  2380. return Ok(JsonView(false, groupData.Msg));
  2381. }
  2382. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2383. }
  2384. /// <summary>
  2385. /// 机票费用录入操作(Status:1.新增,2.修改)
  2386. /// </summary>
  2387. /// <param name="dto"></param>
  2388. /// <returns></returns>
  2389. [HttpPost]
  2390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2391. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2392. {
  2393. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2394. if (groupData.Code != 0)
  2395. {
  2396. return Ok(JsonView(false, groupData.Msg));
  2397. }
  2398. #region 应用推送
  2399. try
  2400. {
  2401. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2402. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2403. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2404. //2024-10-21 新增LZ UID
  2405. var userIds = new List<int>() { 21 };
  2406. string title = $"系统通知";
  2407. string content = "";
  2408. var diId = dto.AirTicketResOpData.DiId;
  2409. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2410. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2411. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2412. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2413. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2414. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2415. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2416. }
  2417. catch (Exception ex)
  2418. {
  2419. }
  2420. #endregion
  2421. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2422. }
  2423. /// <summary>
  2424. /// 根据舱位类型查询接团客户名单信息
  2425. /// </summary>
  2426. /// <param name="dto"></param>
  2427. /// <returns></returns>
  2428. [HttpPost]
  2429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2430. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2431. {
  2432. try
  2433. {
  2434. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2435. if (crm_Groups.Count != 0)
  2436. {
  2437. List<dynamic> Customer = new List<dynamic>();
  2438. foreach (var item in crm_Groups)
  2439. {
  2440. var data = new
  2441. {
  2442. Id = item.Id,
  2443. Pinyin = item.Pinyin,
  2444. Name = item.LastName + item.FirstName
  2445. };
  2446. Customer.Add(data);
  2447. }
  2448. return Ok(JsonView(true, "查询成功!", Customer));
  2449. }
  2450. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2451. }
  2452. catch (Exception ex)
  2453. {
  2454. return Ok(JsonView(false, "程序错误!"));
  2455. throw;
  2456. }
  2457. }
  2458. /// <summary>
  2459. /// 根据团号获取客户信息
  2460. /// </summary>
  2461. /// <param name="dto"></param>
  2462. /// <returns></returns>
  2463. [HttpPost]
  2464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2465. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2466. {
  2467. var jw = JsonView(false);
  2468. if (dto.DIID < 1)
  2469. {
  2470. jw.Msg += "请输入正确的diid";
  2471. return Ok(jw);
  2472. }
  2473. var arr = getSimplClientList(dto.DIID);
  2474. jw = JsonView(true, "获取成功!", arr);
  2475. return Ok(jw);
  2476. }
  2477. private List<SimplClientInfo> getSimplClientList(int diId)
  2478. {
  2479. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  2480. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2481. foreach (var item in arr)
  2482. {
  2483. EncryptionProcessor.DecryptProperties(item);
  2484. }
  2485. return arr;
  2486. }
  2487. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2488. {
  2489. string result = origin;
  2490. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2491. {
  2492. string[] temparr = origin.Split(',');
  2493. string fistrStr = temparr[0];
  2494. int count = temparr.Count();
  2495. int tempId;
  2496. bool success = int.TryParse(fistrStr, out tempId);
  2497. if (success)
  2498. {
  2499. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2500. if (tempInfo != null)
  2501. {
  2502. if (count > 1)
  2503. {
  2504. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2505. }
  2506. else
  2507. {
  2508. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2509. }
  2510. }
  2511. }
  2512. }
  2513. return result;
  2514. }
  2515. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2516. {
  2517. string result = origin;
  2518. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2519. {
  2520. string[] temparr = origin.Split(',');
  2521. result = "";
  2522. foreach (var item in temparr)
  2523. {
  2524. int tempId;
  2525. bool success = int.TryParse(item, out tempId);
  2526. if (success)
  2527. {
  2528. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2529. if (tempInfo != null)
  2530. {
  2531. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2532. }
  2533. }
  2534. }
  2535. }
  2536. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2537. return result;
  2538. }
  2539. /// <summary>
  2540. /// 机票费用录入,删除
  2541. /// </summary>
  2542. /// <param name="dto"></param>
  2543. /// <returns></returns>
  2544. [HttpPost]
  2545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2546. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2547. {
  2548. try
  2549. {
  2550. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2551. if (res)
  2552. {
  2553. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2554. {
  2555. IsDel = 1,
  2556. DeleteUserId = dto.DeleteUserId,
  2557. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2558. }).ExecuteCommandAsync();
  2559. return Ok(JsonView(true, "删除成功!"));
  2560. }
  2561. return Ok(JsonView(false, "删除失败!"));
  2562. }
  2563. catch (Exception ex)
  2564. {
  2565. return Ok(JsonView(false, "程序错误!"));
  2566. throw;
  2567. }
  2568. }
  2569. /// <summary>
  2570. /// 导出机票录入报表
  2571. /// </summary>
  2572. /// <param name="dto"></param>
  2573. /// <returns></returns>
  2574. [HttpPost]
  2575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2576. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2577. {
  2578. try
  2579. {
  2580. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2581. if (groupData.Code != 0)
  2582. {
  2583. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2584. }
  2585. else
  2586. {
  2587. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2588. if (AirTicketReservations.Count != 0)
  2589. {
  2590. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2591. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2592. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2593. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2594. WorkbookDesigner designer = new WorkbookDesigner();
  2595. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2596. decimal countCost = 0;
  2597. foreach (var item in AirTicketReservations)
  2598. {
  2599. #region 处理客人姓名
  2600. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2601. item.ClientName = clientNames;
  2602. #endregion
  2603. if (item.BankType == "其他")
  2604. {
  2605. item.BankNo = "--";
  2606. }
  2607. else
  2608. {
  2609. if (!string.IsNullOrEmpty(item.BankType))
  2610. {
  2611. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2612. }
  2613. }
  2614. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2615. item.Price = System.Decimal.Round(item.Price, 2);
  2616. countCost += Convert.ToDecimal(item.Price);
  2617. }
  2618. designer.SetDataSource("Export", AirTicketReservations);
  2619. designer.SetDataSource("ExportDiCode", diCode);
  2620. designer.SetDataSource("ExportDiName", diName);
  2621. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2622. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2623. designer.Process();
  2624. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2625. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2626. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2627. return Ok(JsonView(true, "成功", url = rst));
  2628. }
  2629. else
  2630. {
  2631. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2632. }
  2633. }
  2634. }
  2635. catch (Exception ex)
  2636. {
  2637. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2638. throw;
  2639. }
  2640. }
  2641. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2642. /// <summary>
  2643. /// 行程单导出
  2644. /// </summary>
  2645. /// <param name="dto"></param>
  2646. /// <returns></returns>
  2647. [HttpPost]
  2648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2649. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2650. {
  2651. try
  2652. {
  2653. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2654. if (groupData.Code != 0)
  2655. {
  2656. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2657. }
  2658. else
  2659. {
  2660. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2661. if (dto.Language == "CN")
  2662. {
  2663. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2664. DocumentBuilder builder = new DocumentBuilder(doc);
  2665. int tableIndex = 0;//表格索引
  2666. //得到文档中的第一个表格
  2667. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2668. foreach (var item in _AirTicketReservations)
  2669. {
  2670. #region 处理固定数据
  2671. string[] FlightsCode = item.FlightsCode.Split('/');
  2672. if (FlightsCode.Length != 0)
  2673. {
  2674. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2675. if (_AirCompany != null)
  2676. {
  2677. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2678. }
  2679. else
  2680. {
  2681. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2682. }
  2683. }
  2684. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2685. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2686. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2687. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2688. string name = "";
  2689. foreach (string clientName in nameArray)
  2690. {
  2691. if (!name.Contains(clientName))
  2692. {
  2693. name += clientName + ",";
  2694. }
  2695. }
  2696. if (!string.IsNullOrWhiteSpace(name))
  2697. {
  2698. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2699. }
  2700. else
  2701. {
  2702. table.Range.Bookmarks["ClientName"].Text = "--";
  2703. }
  2704. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2705. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2706. table.Range.Bookmarks["JointTicket"].Text = "--";
  2707. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2708. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2709. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2710. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2711. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2712. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2713. #endregion
  2714. #region 循环数据处理
  2715. List<AirInfo> airs = new List<AirInfo>();
  2716. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2717. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2718. for (int i = 0; i < FlightsCode.Length; i++)
  2719. {
  2720. AirInfo air = new AirInfo();
  2721. string[] tempstr = DayArray[i]
  2722. .Replace("\r\n", string.Empty)
  2723. .Replace("\\r\\n", string.Empty)
  2724. .TrimStart().TrimEnd()
  2725. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2726. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2727. string starCity = "";
  2728. if (star_Three != null)
  2729. {
  2730. starCity = star_Three.AirPort;
  2731. }
  2732. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2733. string EndCity = "";
  2734. if (End_Three != null)
  2735. {
  2736. EndCity = End_Three.AirPort;
  2737. }
  2738. air.Destination = starCity + "/" + EndCity;
  2739. air.Flight = FlightsCode[i];
  2740. air.SeatingClass = item.CTypeName;
  2741. string dateTime = tempstr[2];
  2742. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2743. air.FlightDate = DateTemp;
  2744. air.DepartureTime = tempstr[5];
  2745. air.LandingTime = tempstr[6];
  2746. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2747. air.TicketStatus = "--";
  2748. air.Luggage = "--";
  2749. air.DepartureTerminal = "--";
  2750. air.LandingTerminal = "--";
  2751. airs.Add(air);
  2752. }
  2753. int row = 13;
  2754. for (int i = 0; i < airs.Count; i++)
  2755. {
  2756. if (airs.Count > 2)
  2757. {
  2758. for (int j = 0; j < airs.Count - 2; j++)
  2759. {
  2760. var CopyRow = table.Rows[12].Clone(true);
  2761. table.Rows.Add(CopyRow);
  2762. }
  2763. }
  2764. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2765. int index = 0;
  2766. foreach (PropertyInfo property in properties)
  2767. {
  2768. string value = property.GetValue(airs[i]).ToString();
  2769. Cell ishcel0 = table.Rows[row].Cells[index];
  2770. Paragraph p = new Paragraph(doc);
  2771. string s = value;
  2772. p.AppendChild(new Run(doc, s));
  2773. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2774. ishcel0.AppendChild(p);
  2775. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2776. index++;
  2777. }
  2778. row++;
  2779. }
  2780. #endregion
  2781. Paragraph lastParagraph = new Paragraph(doc);
  2782. //第一个表格末尾加段落
  2783. table.ParentNode.InsertAfter(lastParagraph, table);
  2784. //复制第一个表格
  2785. Table cloneTable = (Table)table.Clone(true);
  2786. //在文档末尾段落后面加入复制的表格
  2787. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2788. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2789. {
  2790. int rownewsIndex = 13;
  2791. for (int i = 0; i < 2; i++)
  2792. {
  2793. var CopyRow = table.Rows[12].Clone(true);
  2794. table.Rows.RemoveAt(13);
  2795. table.Rows.Add(CopyRow);
  2796. rownewsIndex++;
  2797. }
  2798. }
  2799. else
  2800. {
  2801. table.Rows.RemoveAt(12);
  2802. }
  2803. cloneTable.Rows.RemoveAt(12);
  2804. }
  2805. if (_AirTicketReservations.Count != 0)
  2806. {
  2807. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2808. if (FlightsCode.Length != 0)
  2809. {
  2810. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2811. if (_AirCompany != null)
  2812. {
  2813. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2814. }
  2815. else
  2816. {
  2817. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2818. }
  2819. }
  2820. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2821. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2822. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2823. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2824. string name = "";
  2825. foreach (string clientName in nameArray)
  2826. {
  2827. if (!name.Contains(clientName))
  2828. {
  2829. name += clientName + ",";
  2830. }
  2831. }
  2832. if (!string.IsNullOrWhiteSpace(name))
  2833. {
  2834. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2835. }
  2836. else
  2837. {
  2838. table.Range.Bookmarks["ClientName"].Text = "--";
  2839. }
  2840. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2841. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2842. table.Range.Bookmarks["JointTicket"].Text = "--";
  2843. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2844. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2845. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2846. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2847. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2848. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2849. }
  2850. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2851. //保存合并后的文档
  2852. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2853. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2854. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2855. return Ok(JsonView(true, "成功!", rst));
  2856. }
  2857. else
  2858. {
  2859. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2860. DocumentBuilder builder = new DocumentBuilder(doc);
  2861. int tableIndex = 0;//表格索引
  2862. //得到文档中的第一个表格
  2863. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2864. List<string> texts = new List<string>();
  2865. foreach (var item in _AirTicketReservations)
  2866. {
  2867. string[] FlightsCode = item.FlightsCode.Split('/');
  2868. if (FlightsCode.Length != 0)
  2869. {
  2870. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2871. if (_AirCompany != null)
  2872. {
  2873. if (!transDic.ContainsKey(_AirCompany.CnName))
  2874. {
  2875. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2876. }
  2877. }
  2878. else
  2879. {
  2880. if (!transDic.ContainsKey("--"))
  2881. {
  2882. transDic.Add("--", "--");
  2883. }
  2884. }
  2885. }
  2886. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2887. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2888. string name = "";
  2889. foreach (string clientName in nameArray)
  2890. {
  2891. name += clientName + ",";
  2892. }
  2893. if (!texts.Contains(name))
  2894. {
  2895. texts.Add(name);
  2896. }
  2897. List<AirInfo> airs = new List<AirInfo>();
  2898. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2899. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2900. for (int i = 0; i < FlightsCode.Length; i++)
  2901. {
  2902. AirInfo air = new AirInfo();
  2903. string[] tempstr = DayArray[i]
  2904. .Replace("\r\n", string.Empty)
  2905. .Replace("\\r\\n", string.Empty)
  2906. .TrimStart().TrimEnd()
  2907. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2908. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2909. if (star_Three != null)
  2910. {
  2911. if (!transDic.ContainsKey(star_Three.AirPort))
  2912. {
  2913. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2914. }
  2915. }
  2916. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2917. if (End_Three != null)
  2918. {
  2919. if (!transDic.ContainsKey(End_Three.AirPort))
  2920. {
  2921. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2922. }
  2923. }
  2924. if (!texts.Contains(item.CTypeName))
  2925. {
  2926. texts.Add(item.CTypeName);
  2927. }
  2928. }
  2929. }
  2930. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2931. if (transData.Count > 0)
  2932. {
  2933. foreach (TranslateResult item in transData)
  2934. {
  2935. if (!transDic.ContainsKey(item.Query))
  2936. {
  2937. transDic.Add(item.Query, item.Translation);
  2938. }
  2939. }
  2940. }
  2941. foreach (var item in _AirTicketReservations)
  2942. {
  2943. #region 处理固定数据
  2944. string[] FlightsCode = item.FlightsCode.Split('/');
  2945. if (FlightsCode.Length != 0)
  2946. {
  2947. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2948. if (_AirCompany != null)
  2949. {
  2950. string str = "--";
  2951. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2952. if (!string.IsNullOrEmpty(translateResult))
  2953. {
  2954. str = translateResult;
  2955. str = _airTicketResRep.Processing(str);
  2956. }
  2957. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2958. }
  2959. else
  2960. {
  2961. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2962. }
  2963. }
  2964. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2965. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2966. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2967. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2968. string names = "";
  2969. foreach (string clientName in nameArray)
  2970. {
  2971. names += clientName + ",";
  2972. }
  2973. if (!string.IsNullOrWhiteSpace(names))
  2974. {
  2975. string str = "--";
  2976. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2977. if (!string.IsNullOrEmpty(translateResult))
  2978. {
  2979. str = translateResult;
  2980. str = _airTicketResRep.Processing(str);
  2981. }
  2982. table.Range.Bookmarks["ClientName"].Text = str;
  2983. }
  2984. else
  2985. {
  2986. table.Range.Bookmarks["ClientName"].Text = "--";
  2987. }
  2988. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2989. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2990. table.Range.Bookmarks["JointTicket"].Text = "--";
  2991. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2992. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2993. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2994. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2995. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2996. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2997. #endregion
  2998. #region 循环数据处理
  2999. List<AirInfo> airs = new List<AirInfo>();
  3000. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3001. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3002. for (int i = 0; i < FlightsCode.Length; i++)
  3003. {
  3004. AirInfo air = new AirInfo();
  3005. string[] tempstr = DayArray[i]
  3006. .Replace("\r\n", string.Empty)
  3007. .Replace("\\r\\n", string.Empty)
  3008. .TrimStart().TrimEnd()
  3009. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3010. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3011. string starCity = "";
  3012. if (star_Three != null)
  3013. {
  3014. string str2 = "--";
  3015. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3016. if (!string.IsNullOrEmpty(translateResult2))
  3017. {
  3018. str2 = translateResult2;
  3019. str2 = _airTicketResRep.Processing(str2);
  3020. }
  3021. starCity = str2;
  3022. }
  3023. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3024. string EndCity = "";
  3025. if (End_Three != null)
  3026. {
  3027. string str1 = "--";
  3028. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3029. if (!string.IsNullOrEmpty(translateResult1))
  3030. {
  3031. str1 = translateResult1;
  3032. str1 = _airTicketResRep.Processing(str1);
  3033. }
  3034. EndCity = str1;
  3035. }
  3036. air.Destination = starCity + "/" + EndCity;
  3037. air.Flight = FlightsCode[i];
  3038. string str = "--";
  3039. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3040. if (!string.IsNullOrEmpty(translateResult))
  3041. {
  3042. str = translateResult;
  3043. str = _airTicketResRep.Processing(str);
  3044. }
  3045. air.SeatingClass = str;
  3046. string dateTime = tempstr[2];
  3047. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3048. air.FlightDate = DateTemp;
  3049. air.DepartureTime = tempstr[5];
  3050. air.LandingTime = tempstr[6];
  3051. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3052. air.TicketStatus = "--";
  3053. air.Luggage = "--";
  3054. air.DepartureTerminal = "--";
  3055. air.LandingTerminal = "--";
  3056. airs.Add(air);
  3057. }
  3058. int row = 13;
  3059. for (int i = 0; i < airs.Count; i++)
  3060. {
  3061. if (airs.Count > 2)
  3062. {
  3063. for (int j = 0; j < airs.Count - 2; j++)
  3064. {
  3065. var CopyRow = table.Rows[12].Clone(true);
  3066. table.Rows.Add(CopyRow);
  3067. }
  3068. }
  3069. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3070. int index = 0;
  3071. foreach (PropertyInfo property in properties)
  3072. {
  3073. string value = property.GetValue(airs[i]).ToString();
  3074. Cell ishcel0 = table.Rows[row].Cells[index];
  3075. Paragraph p = new Paragraph(doc);
  3076. string s = value;
  3077. p.AppendChild(new Run(doc, s));
  3078. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3079. ishcel0.AppendChild(p);
  3080. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3081. //ishcel0.CellFormat.VerticalAlignment=
  3082. index++;
  3083. }
  3084. row++;
  3085. }
  3086. #endregion
  3087. Paragraph lastParagraph = new Paragraph(doc);
  3088. //第一个表格末尾加段落
  3089. table.ParentNode.InsertAfter(lastParagraph, table);
  3090. //复制第一个表格
  3091. Table cloneTable = (Table)table.Clone(true);
  3092. //在文档末尾段落后面加入复制的表格
  3093. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3094. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3095. {
  3096. int rownewsIndex = 13;
  3097. for (int i = 0; i < 2; i++)
  3098. {
  3099. var CopyRow = table.Rows[12].Clone(true);
  3100. table.Rows.RemoveAt(13);
  3101. table.Rows.Add(CopyRow);
  3102. rownewsIndex++;
  3103. }
  3104. }
  3105. else
  3106. {
  3107. table.Rows.RemoveAt(12);
  3108. }
  3109. cloneTable.Rows.RemoveAt(12);
  3110. }
  3111. if (_AirTicketReservations.Count != 0)
  3112. {
  3113. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3114. if (FlightsCode.Length != 0)
  3115. {
  3116. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3117. if (_AirCompany != null)
  3118. {
  3119. string str = "--";
  3120. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3121. if (!string.IsNullOrEmpty(translateResult))
  3122. {
  3123. str = translateResult;
  3124. str = _airTicketResRep.Processing(str);
  3125. }
  3126. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3127. }
  3128. else
  3129. {
  3130. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3131. }
  3132. }
  3133. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3134. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3135. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3136. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3137. string names = "";
  3138. foreach (string clientName in nameArray)
  3139. {
  3140. names += clientName + ",";
  3141. }
  3142. if (!string.IsNullOrWhiteSpace(names))
  3143. {
  3144. string str = "--";
  3145. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3146. if (!string.IsNullOrEmpty(translateResult))
  3147. {
  3148. str = translateResult;
  3149. str = _airTicketResRep.Processing(str);
  3150. }
  3151. table.Range.Bookmarks["ClientName"].Text = str;
  3152. }
  3153. else
  3154. {
  3155. table.Range.Bookmarks["ClientName"].Text = "--";
  3156. }
  3157. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3158. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3159. table.Range.Bookmarks["JointTicket"].Text = "--";
  3160. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3161. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3162. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3163. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3164. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3165. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3166. }
  3167. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3168. //保存合并后的文档
  3169. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3170. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3171. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3172. return Ok(JsonView(true, "成功!", rst));
  3173. }
  3174. }
  3175. }
  3176. catch (Exception ex)
  3177. {
  3178. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3179. throw;
  3180. }
  3181. }
  3182. #endregion
  3183. #region 团组增减款项 --> 其他款项
  3184. /// <summary>
  3185. /// 团组增减款项下拉框绑定
  3186. /// </summary>
  3187. /// <param name="dto"></param>
  3188. /// <returns></returns>
  3189. [HttpPost]
  3190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3191. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3192. {
  3193. #region 参数验证
  3194. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3195. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3196. #endregion
  3197. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3198. }
  3199. /// <summary>
  3200. /// 根据团组Id查询团组增减款项
  3201. /// </summary>
  3202. /// <param name="dto"></param>
  3203. /// <returns></returns>
  3204. [HttpPost]
  3205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3206. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3207. {
  3208. #region 参数验证
  3209. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3210. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3211. #endregion
  3212. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3213. }
  3214. /// <summary>
  3215. /// 团组增减款项操作(Status:1.新增,2.修改)
  3216. /// </summary>
  3217. /// <param name="dto"></param>
  3218. /// <returns></returns>
  3219. [HttpPost]
  3220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3221. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3222. {
  3223. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3224. if (groupData.Code != 200)
  3225. {
  3226. return Ok(JsonView(false, groupData.Msg));
  3227. }
  3228. #region 应用推送
  3229. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3230. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3231. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3232. //自动审核
  3233. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3234. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3235. //2024-10-21 新增LZ UID
  3236. var userIds = new List<int>() { 21 };
  3237. string title = $"系统通知";
  3238. string content = "";
  3239. var diId = dto.DiId;
  3240. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3241. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3242. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3243. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3244. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3245. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3246. #endregion
  3247. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3248. }
  3249. /// <summary>
  3250. /// 团组增减款项操作 删除
  3251. /// </summary>
  3252. /// <param name="dto"></param>
  3253. /// <returns></returns>
  3254. [HttpPost]
  3255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3256. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3257. {
  3258. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3259. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3260. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3261. if (res.Code == 0)
  3262. {
  3263. return Ok(JsonView(true, "删除成功!"));
  3264. }
  3265. return Ok(JsonView(false, "删除失败!"));
  3266. }
  3267. /// <summary>
  3268. /// 根据团组增减款项Id查询
  3269. /// </summary>
  3270. /// <param name="dto"></param>
  3271. /// <returns></returns>
  3272. [HttpPost]
  3273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3274. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3275. {
  3276. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3277. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3278. }
  3279. /// <summary>
  3280. /// 查询供应商名称
  3281. /// </summary>
  3282. /// <param name="dto"></param>
  3283. /// <returns></returns>
  3284. [HttpPost]
  3285. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3286. {
  3287. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3288. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3289. ?? new List<Grp_DecreasePayments>();
  3290. dbResult = dbResult.Distinct(new
  3291. ProductComparer()).ToList();
  3292. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3293. {
  3294. x.Id,
  3295. x.SupplierAddress,
  3296. x.SupplierArea,
  3297. x.SupplierContact,
  3298. x.SupplierContactNumber,
  3299. x.SupplierEmail,
  3300. x.SupplierName,
  3301. x.SupplierSocialAccount,
  3302. x.SupplierTypeId,
  3303. }).ToList());
  3304. return Ok(jw);
  3305. }
  3306. /// <summary>
  3307. /// 团组增减款项 OTA匹配
  3308. /// </summary>
  3309. /// <param name="file"></param>
  3310. /// <returns></returns>
  3311. [HttpPost]
  3312. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3313. {
  3314. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3315. string fileName = file.FileName;
  3316. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3317. {
  3318. return Ok(JsonView(false, "请上传Excel文件!"));
  3319. }
  3320. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3321. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3322. if (!Directory.Exists(path))
  3323. {
  3324. Directory.CreateDirectory(path);
  3325. }
  3326. var filePath = @$"{path}/{fileName}";
  3327. //保存文件
  3328. using (FileStream fs = System.IO.File.Create(filePath))
  3329. {
  3330. file.CopyTo(fs);
  3331. fs.Flush();
  3332. }
  3333. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3334. //读取ExcelFile
  3335. DataTable dt = ConvertExcelToDataTable(filePath);
  3336. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3337. dt.TableName = "TB";
  3338. //修改table列名
  3339. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3340. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3341. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3342. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3343. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3344. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3345. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3346. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3347. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3348. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3349. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3350. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3351. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3352. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3353. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3354. var otaOrderNos = new List<string>();
  3355. foreach (DataRow item in dt.Rows)
  3356. {
  3357. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3358. }
  3359. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3360. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3361. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3362. .Select((dp, di) => new
  3363. {
  3364. dp.PriceName,
  3365. dp.OTAOrderNo,
  3366. dp.FeeTotal,
  3367. di.TeamName,
  3368. })
  3369. .ToListAsync();
  3370. foreach (DataRow item in dt.Rows)
  3371. {
  3372. var otaOrderNo = item["OTAOrderNo"].ToString();
  3373. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3374. if (oaData == null) continue;
  3375. item["GroupName"] = oaData.TeamName;
  3376. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3377. }
  3378. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3379. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3380. List<DataTable> datas = new List<DataTable>();
  3381. datas.Add(dt);
  3382. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3383. return Ok(JsonView(true, "操作成功", new { url = url }));
  3384. }
  3385. #region
  3386. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3387. {
  3388. // 创建Workbook对象
  3389. Workbook workbook = new Workbook(excelFilePath);
  3390. // 获取第一个工作表
  3391. Worksheet worksheet = workbook.Worksheets[0];
  3392. // 将工作表转换为DataTable
  3393. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3394. return dataTable;
  3395. }
  3396. #endregion
  3397. #endregion
  3398. #region 文件上传、删除
  3399. /// <summary>
  3400. /// region 文件上传 可以带参数
  3401. /// </summary>
  3402. /// <param name="file"></param>
  3403. /// <returns></returns>
  3404. [HttpPost]
  3405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3406. public async Task<IActionResult> UploadProject(IFormFile file)
  3407. {
  3408. //var TypeName = Request.Headers["TypeName"].ToString();
  3409. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3410. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3411. ////文件名称
  3412. //string projectFileName = file.FileName;
  3413. ////上传的文件的路径
  3414. //string filePath = $"{fileDir}/{projectFileName}";
  3415. //if (TypeName == "A")//A代表团组增减款项
  3416. //{
  3417. // filePath = fileDir + $@"\团组增减款项相关文件";
  3418. // if (!Directory.Exists(filePath))
  3419. // {
  3420. // Directory.CreateDirectory(filePath);
  3421. // }
  3422. // //上传的文件的路径
  3423. // filePath += $@"\{projectFileName}";
  3424. //}
  3425. //else if (TypeName == "B")//B代表商邀相关文件
  3426. //{
  3427. // //上传的文件的路径
  3428. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3429. // if (!Directory.Exists(filePath))
  3430. // {
  3431. // Directory.CreateDirectory(filePath);
  3432. // }
  3433. // //上传的文件的路径
  3434. // filePath = $@"\{projectFileName}";
  3435. //}
  3436. //try
  3437. //{
  3438. // using (FileStream fs = System.IO.File.Create(filePath))
  3439. // {
  3440. // file.CopyTo(fs);
  3441. // fs.Flush();
  3442. // }
  3443. //}
  3444. //catch (Exception ex)
  3445. //{
  3446. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3447. //}
  3448. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3449. try
  3450. {
  3451. var TypeName = Request.Headers["TypeName"].ToString();
  3452. if (file != null)
  3453. {
  3454. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3455. //文件名称
  3456. string projectFileName = file.FileName;
  3457. //上传的文件的路径
  3458. string filePath = $"{fileDir}/{projectFileName}";
  3459. if (TypeName == "A")//A代表团组增减款项
  3460. {
  3461. if (!Directory.Exists(fileDir))
  3462. {
  3463. Directory.CreateDirectory(fileDir);
  3464. }
  3465. //上传的文件的路径
  3466. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3467. }
  3468. else if (TypeName == "B")//B代表商邀相关文件
  3469. {
  3470. if (!Directory.Exists(fileDir))
  3471. {
  3472. Directory.CreateDirectory(fileDir);
  3473. }
  3474. //上传的文件的路径
  3475. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3476. }
  3477. using (FileStream fs = System.IO.File.Create(filePath))
  3478. {
  3479. file.CopyTo(fs);
  3480. fs.Flush();
  3481. }
  3482. return Ok(JsonView(true, "上传成功!", projectFileName));
  3483. }
  3484. else
  3485. {
  3486. return Ok(JsonView(false, "上传失败!"));
  3487. }
  3488. }
  3489. catch (Exception ex)
  3490. {
  3491. return Ok(JsonView(false, "程序错误!"));
  3492. }
  3493. }
  3494. /// <summary>
  3495. /// 删除指定文件
  3496. /// </summary>
  3497. /// <param name="dto"></param>
  3498. /// <returns></returns>
  3499. [HttpPost]
  3500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3501. public async Task<IActionResult> DelFile(DelFileDto dto)
  3502. {
  3503. try
  3504. {
  3505. var TypeName = Request.Headers["TypeName"].ToString();
  3506. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3507. string filePath = "";
  3508. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3509. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3510. int id = 0;
  3511. if (TypeName == "A")
  3512. {
  3513. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3514. // 删除该文件
  3515. System.IO.File.Delete(filePath);
  3516. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3517. .Where(a => a.Id == dto.Id)
  3518. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3519. .ExecuteCommandAsync();
  3520. }
  3521. else if (TypeName == "B")
  3522. {
  3523. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3524. // 删除该文件
  3525. System.IO.File.Delete(filePath);
  3526. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3527. if (info != null)
  3528. {
  3529. string[] files = new string[] { };
  3530. if (!string.IsNullOrEmpty(info.Attachment))
  3531. {
  3532. try
  3533. {
  3534. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3535. }
  3536. catch (Exception)
  3537. {
  3538. files = new List<string>() { info.Attachment }.ToArray();
  3539. }
  3540. }
  3541. if (files.Length > 0)
  3542. {
  3543. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3544. string filePath2 = string.Empty;
  3545. if (files1.Length > 0)
  3546. {
  3547. filePath2 = JsonConvert.SerializeObject(files1);
  3548. }
  3549. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3550. .Where(a => a.Id == dto.Id)
  3551. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3552. .ExecuteCommandAsync();
  3553. }
  3554. }
  3555. }
  3556. if (id != 0)
  3557. {
  3558. return Ok(JsonView(true, "成功!"));
  3559. }
  3560. else
  3561. {
  3562. return Ok(JsonView(false, "失败!"));
  3563. }
  3564. }
  3565. catch (Exception ex)
  3566. {
  3567. return Ok(JsonView(false, "程序错误!"));
  3568. throw;
  3569. }
  3570. }
  3571. /// <summary>
  3572. /// 文件上传多个文件 可以带参数
  3573. /// </summary>
  3574. /// <param name="file"></param>
  3575. /// <returns></returns>
  3576. [HttpPost]
  3577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3578. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3579. {
  3580. try
  3581. {
  3582. var TypeName = Request.Headers["TypeName"].ToString();
  3583. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3584. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3585. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3586. var filePahts = new List<string>();
  3587. foreach (var file in files)
  3588. {
  3589. //文件名称
  3590. string projectFileName = file.FileName;
  3591. //上传的文件的路径
  3592. string filePath = $"{fileDir}/{projectFileName}";
  3593. if (TypeName == "A")//A代表团组增减款项
  3594. {
  3595. if (!Directory.Exists(fileDir))
  3596. {
  3597. Directory.CreateDirectory(fileDir);
  3598. }
  3599. //上传的文件的路径
  3600. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3601. }
  3602. else if (TypeName == "B")//B代表商邀相关文件
  3603. {
  3604. if (!Directory.Exists(fileDir))
  3605. {
  3606. Directory.CreateDirectory(fileDir);
  3607. }
  3608. //上传的文件的路径
  3609. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3610. }
  3611. using (FileStream fs = System.IO.File.Create(filePath))
  3612. {
  3613. file.CopyTo(fs);
  3614. fs.Flush();
  3615. }
  3616. filePahts.Add(projectFileName);
  3617. }
  3618. return Ok(JsonView(true, "上传成功!", filePahts));
  3619. }
  3620. catch (Exception ex)
  3621. {
  3622. return Ok(JsonView(false, "程序错误!"));
  3623. }
  3624. }
  3625. #endregion
  3626. #region 商邀费用录入
  3627. /// <summary>
  3628. /// 根据团组Id查询商邀费用列表
  3629. /// </summary>
  3630. /// <param name="dto"></param>
  3631. /// <returns></returns>
  3632. [HttpPost]
  3633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3634. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3635. {
  3636. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3637. if (groupData.Code != 0)
  3638. {
  3639. return Ok(JsonView(false, groupData.Msg));
  3640. }
  3641. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3642. }
  3643. /// <summary>
  3644. /// 商邀费用列表
  3645. /// 下载文件
  3646. /// </summary>
  3647. /// <param name="dto"></param>
  3648. /// <returns></returns>
  3649. [HttpGet("{id}")]
  3650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3651. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3652. {
  3653. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3654. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3655. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3656. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3657. var filePaths = new List<string>();
  3658. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3659. try
  3660. {
  3661. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3662. }
  3663. catch (Exception ex)
  3664. {
  3665. filePaths.Add(info.Attachment);
  3666. }
  3667. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3668. for (int i = 0; i < filePaths.Count; i++)
  3669. {
  3670. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3671. }
  3672. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3673. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3674. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3675. {
  3676. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3677. {
  3678. foreach (string filePath in filePaths)
  3679. {
  3680. if (System.IO.File.Exists(filePath))
  3681. {
  3682. // 获取文件名
  3683. string fileName = Path.GetFileName(filePath);
  3684. // 将文件添加到ZIP归档中
  3685. zipArchive.CreateEntryFromFile(filePath, fileName);
  3686. }
  3687. }
  3688. }
  3689. }
  3690. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3691. }
  3692. /// <summary>
  3693. /// 商邀费用 Info Page 基础数据源
  3694. /// </summary>
  3695. /// <param name="dto"></param>
  3696. /// <returns></returns>
  3697. [HttpPost]
  3698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3699. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3700. {
  3701. try
  3702. {
  3703. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3704. if (groupData.Code != 0)
  3705. {
  3706. return Ok(JsonView(false, groupData.Msg));
  3707. }
  3708. return Ok(JsonView(true, "操作成功", groupData.Data));
  3709. }
  3710. catch (Exception ex)
  3711. {
  3712. return Ok(JsonView(false, ex.Message));
  3713. throw;
  3714. }
  3715. }
  3716. /// <summary>
  3717. /// 根据商邀费用ID查询C表和商邀费用数据
  3718. /// </summary>
  3719. /// <param name="dto"></param>
  3720. /// <returns></returns>
  3721. [HttpPost]
  3722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3723. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3724. {
  3725. try
  3726. {
  3727. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3728. if (groupData.Code != 0)
  3729. {
  3730. return Ok(JsonView(false, groupData.Msg));
  3731. }
  3732. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3733. }
  3734. catch (Exception ex)
  3735. {
  3736. return Ok(JsonView(false, ex.Message));
  3737. throw;
  3738. }
  3739. }
  3740. /// <summary>
  3741. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3742. /// </summary>
  3743. /// <param name="dto"></param>
  3744. /// <returns></returns>
  3745. [HttpPost]
  3746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3747. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3748. {
  3749. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3750. if (groupData.Code != 0)
  3751. {
  3752. return Ok(JsonView(false, groupData.Msg));
  3753. }
  3754. #region 应用推送
  3755. try
  3756. {
  3757. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3758. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3759. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3760. //2024-10-21 新增LZ UID
  3761. var userIds = new List<int>() { 21 };
  3762. string title = $"系统通知";
  3763. string content = "";
  3764. var diId = dto.DiId;
  3765. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3766. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3767. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3768. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3769. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3770. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3771. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3772. }
  3773. catch (Exception ex)
  3774. {
  3775. }
  3776. #endregion
  3777. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3778. }
  3779. /// <summary>
  3780. /// 商邀删除
  3781. /// </summary>
  3782. /// <param name="dto"></param>
  3783. /// <returns></returns>
  3784. [HttpPost]
  3785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3786. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3787. {
  3788. try
  3789. {
  3790. _sqlSugar.BeginTran();
  3791. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3792. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3793. {
  3794. IsDel = 1,
  3795. DeleteUserId = dto.DeleteUserId,
  3796. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3797. })
  3798. .Where(it => it.Id == dto.Id)
  3799. .ExecuteCommand();
  3800. if (res1 > 0)
  3801. {
  3802. int _diId = 0;
  3803. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3804. if (_ioaInfo != null)
  3805. {
  3806. _diId = _ioaInfo.DiId;
  3807. }
  3808. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3809. .SetColumns(a => new Grp_CreditCardPayment()
  3810. {
  3811. IsDel = 1,
  3812. DeleteUserId = dto.DeleteUserId,
  3813. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3814. })
  3815. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3816. .ExecuteCommand();
  3817. if (res2 > 0)
  3818. {
  3819. _sqlSugar.CommitTran();
  3820. return Ok(JsonView(true, "删除成功!"));
  3821. }
  3822. }
  3823. _sqlSugar.RollbackTran();
  3824. return Ok(JsonView(false, "删除失败"));
  3825. }
  3826. catch (Exception ex)
  3827. {
  3828. _sqlSugar.RollbackTran();
  3829. return Ok(JsonView(false, ex.Message));
  3830. }
  3831. }
  3832. /// <summary>
  3833. /// 团组模块文件上传
  3834. /// </summary>
  3835. /// <param name="dto"></param>
  3836. /// <returns></returns>
  3837. [HttpPost]
  3838. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3839. {
  3840. var jw = JsonView(false);
  3841. long M = 1024 * 1024;
  3842. if (dto.Files == null || dto.Files.Count == 0)
  3843. {
  3844. jw.Msg = "无文件信息!";
  3845. return Ok(jw);
  3846. }
  3847. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3848. {
  3849. jw.Msg = "文件大小超过20M!";
  3850. return Ok(jw);
  3851. }
  3852. //var nameSp = dto.File.FileName.Split(".");
  3853. //if (nameSp.Length < 2)
  3854. //{
  3855. // jw.Msg = "拓展名称有误!";
  3856. // return Ok(jw);
  3857. //}
  3858. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3859. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3860. //{
  3861. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3862. // return Ok(jw);
  3863. //}
  3864. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3865. if (Ctable == null)
  3866. {
  3867. jw.Msg = "Ctable指向有误!";
  3868. return Ok(jw);
  3869. }
  3870. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3871. if (groupInfo == null)
  3872. {
  3873. jw.Msg = "团组信息不存在!";
  3874. return Ok(jw);
  3875. }
  3876. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3877. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3878. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3879. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3880. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3881. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3882. try
  3883. {
  3884. if (!Directory.Exists(fileBase))
  3885. {
  3886. Directory.CreateDirectory(fileBase);
  3887. }
  3888. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3889. foreach (var fileStream in dto.Files)
  3890. {
  3891. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3892. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3893. {
  3894. Cid = dto.Cid,
  3895. CreateTime = DateTime.Now,
  3896. CreateUserId = dto.Userid,
  3897. Ctable = dto.Ctable,
  3898. Diid = dto.Diid,
  3899. IsDel = 0,
  3900. FilePath = saveFilePath,
  3901. FileName = fileStream.FileName
  3902. };
  3903. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3904. {
  3905. fileStream.CopyTo(fs);
  3906. fs.Flush();
  3907. }
  3908. saveArr.Add(file);
  3909. }
  3910. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3911. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3912. jw = JsonView(true, "保存成功!", new
  3913. {
  3914. count = addResult,
  3915. filesName = saveArr.Select(x => x.FileName)
  3916. });
  3917. }
  3918. catch (Exception ex)
  3919. {
  3920. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3921. {
  3922. count = 0,
  3923. filesName = new string[0],
  3924. });
  3925. }
  3926. return Ok(jw);
  3927. }
  3928. /// <summary>
  3929. /// 查询各模块已保存文件
  3930. /// </summary>
  3931. /// <param name="dto"></param>
  3932. /// <returns></returns>
  3933. [HttpPost]
  3934. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3935. {
  3936. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3937. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3938. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3939. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3940. {
  3941. expression = Expressionable.Create<Grp_GroupModelFile>()
  3942. .And(x => visaIds.Contains(x.CreateUserId));
  3943. }
  3944. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3945. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3946. .Where(expression.ToExpression())
  3947. .ToList();
  3948. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3949. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3950. {
  3951. x.FileName,
  3952. x.Id,
  3953. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3954. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3955. })));
  3956. }
  3957. /// <summary>
  3958. /// 下载该团组下的所有文件
  3959. /// </summary>
  3960. /// <param name="dto"></param>
  3961. /// <returns></returns>
  3962. [HttpPost]
  3963. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3964. {
  3965. var jw = JsonView(false);
  3966. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3967. if (groupInfo == null)
  3968. {
  3969. jw.Msg = "团组信息不存在!";
  3970. return Ok(jw);
  3971. }
  3972. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3973. var isModule = Convert.ToBoolean(dto.isModule);
  3974. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3975. IOOperatorHelper io = new IOOperatorHelper();
  3976. if (isModule)
  3977. {
  3978. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3979. foreach (var moduleArr in moduleGroup)
  3980. {
  3981. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3982. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3983. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3984. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3985. foreach (var item in moduleArr)
  3986. {
  3987. if (System.IO.File.Exists(item.FilePath))
  3988. {
  3989. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3990. {
  3991. byte[] bytes = new byte[fileStream.Length];
  3992. fileStream.Read(bytes, 0, bytes.Length);
  3993. fileStream.Close();
  3994. Stream stream = new MemoryStream(bytes);
  3995. chiZips.Add(item.FileName, stream);
  3996. }
  3997. }
  3998. }
  3999. if (chiZips.Count > 0)
  4000. {
  4001. var byts = io.ConvertZipStream(chiZips);
  4002. Stream stream = new MemoryStream(byts);
  4003. Zips.Add(key.Name + "_.zip", stream);
  4004. }
  4005. }
  4006. }
  4007. else
  4008. {
  4009. foreach (var item in dbQuery)
  4010. {
  4011. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4012. {
  4013. byte[] bytes = new byte[fileStream.Length];
  4014. fileStream.Read(bytes, 0, bytes.Length);
  4015. fileStream.Close();
  4016. Stream stream = new MemoryStream(bytes);
  4017. while (Zips.Keys.Contains(item.FileName))
  4018. {
  4019. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4020. }
  4021. Zips.Add(item.FileName, stream);
  4022. }
  4023. }
  4024. }
  4025. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4026. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4027. if (Zips.Count > 0)
  4028. {
  4029. var byts = io.ConvertZipStream(Zips);
  4030. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4031. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4032. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4033. }
  4034. else
  4035. {
  4036. jw.Msg = "暂无生成文件!";
  4037. }
  4038. return Ok(jw);
  4039. }
  4040. /// <summary>
  4041. /// 下载该团组下此模块的所有文件
  4042. /// </summary>
  4043. /// <param name="dto"></param>
  4044. /// <returns></returns>
  4045. [HttpPost]
  4046. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4047. {
  4048. var jw = JsonView(false);
  4049. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4050. if (groupInfo == null)
  4051. {
  4052. jw.Msg = "团组信息不存在!";
  4053. return Ok(jw);
  4054. }
  4055. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4056. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4057. && x.IsDel == 0);
  4058. if (key == null)
  4059. {
  4060. jw.Msg = "Ctable指向错误!";
  4061. return Ok(jw);
  4062. }
  4063. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4064. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4065. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4066. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4067. IOOperatorHelper io = new IOOperatorHelper();
  4068. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4069. foreach (var item in dbQuery)
  4070. {
  4071. if (System.IO.File.Exists(item.FilePath))
  4072. {
  4073. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4074. {
  4075. byte[] bytes = new byte[fileStream.Length];
  4076. fileStream.Read(bytes, 0, bytes.Length);
  4077. fileStream.Close();
  4078. Stream stream = new MemoryStream(bytes);
  4079. while (Zips.Keys.Contains(item.FileName))
  4080. {
  4081. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4082. }
  4083. Zips.Add(item.FileName, stream);
  4084. }
  4085. }
  4086. }
  4087. if (Zips.Count > 0)
  4088. {
  4089. var byts = io.ConvertZipStream(Zips);
  4090. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4091. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4092. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4093. }
  4094. else
  4095. {
  4096. jw.Msg = "暂无生成文件!";
  4097. }
  4098. return Ok(jw);
  4099. }
  4100. /// <summary>
  4101. /// 删除该团组下的指定文件
  4102. /// </summary>
  4103. /// <param name="dto"></param>
  4104. /// <returns></returns>
  4105. [HttpPost]
  4106. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4107. {
  4108. var jw = JsonView(false);
  4109. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4110. if (sing == null)
  4111. {
  4112. jw.Msg = "暂无";
  4113. return Ok(jw);
  4114. }
  4115. if (System.IO.File.Exists(sing.FilePath))
  4116. {
  4117. try
  4118. {
  4119. System.IO.File.Delete(sing.FilePath);
  4120. }
  4121. catch (Exception ex)
  4122. {
  4123. jw.Msg = "删除失败!" + ex.Message;
  4124. return Ok(jw);
  4125. }
  4126. }
  4127. sing.IsDel = 1;
  4128. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4129. sing.DeleteUserId = dto.UserId;
  4130. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4131. jw = JsonView(true, "删除成功!");
  4132. return Ok(jw);
  4133. }
  4134. #endregion
  4135. #region 团组英文资料
  4136. /// <summary>
  4137. /// 查询团组英文所有资料
  4138. /// </summary>
  4139. /// <param name="dto"></param>
  4140. /// <returns></returns>
  4141. [HttpPost]
  4142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4143. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4144. {
  4145. try
  4146. {
  4147. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4148. if (groupData.Code != 0)
  4149. {
  4150. return Ok(JsonView(false, groupData.Msg));
  4151. }
  4152. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4153. }
  4154. catch (Exception ex)
  4155. {
  4156. return Ok(JsonView(false, "程序错误!"));
  4157. throw;
  4158. }
  4159. }
  4160. /// <summary>
  4161. /// 团组英文资料操作(Status:1.新增,2.修改)
  4162. /// </summary>
  4163. /// <param name="dto"></param>
  4164. /// <returns></returns>
  4165. [HttpPost]
  4166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4167. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4168. {
  4169. try
  4170. {
  4171. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4172. if (groupData.Code != 0)
  4173. {
  4174. return Ok(JsonView(false, groupData.Msg));
  4175. }
  4176. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4177. }
  4178. catch (Exception ex)
  4179. {
  4180. return Ok(JsonView(false, "程序错误!"));
  4181. throw;
  4182. }
  4183. }
  4184. /// <summary>
  4185. /// 团组英文资料Id查询数据
  4186. /// </summary>
  4187. /// <param name="dto"></param>
  4188. /// <returns></returns>
  4189. [HttpPost]
  4190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4191. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4192. {
  4193. try
  4194. {
  4195. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4196. if (_DelegationEnData != null)
  4197. {
  4198. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4199. }
  4200. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4201. }
  4202. catch (Exception ex)
  4203. {
  4204. return Ok(JsonView(false, "程序错误!"));
  4205. throw;
  4206. }
  4207. }
  4208. /// <summary>
  4209. /// 团组英文资料删除
  4210. /// </summary>
  4211. /// <param name="dto"></param>
  4212. /// <returns></returns>
  4213. [HttpPost]
  4214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4215. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4216. {
  4217. try
  4218. {
  4219. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4220. if (!res)
  4221. {
  4222. return Ok(JsonView(false, "删除失败"));
  4223. }
  4224. return Ok(JsonView(true, "删除成功!"));
  4225. }
  4226. catch (Exception ex)
  4227. {
  4228. return Ok(JsonView(false, "程序错误!"));
  4229. throw;
  4230. }
  4231. }
  4232. #endregion
  4233. #region 导出邀请函
  4234. /// <summary>
  4235. /// 导出邀请函页面初始化
  4236. /// </summary>
  4237. /// <param name="dto"></param>
  4238. /// <returns></returns>
  4239. [HttpPost]
  4240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4241. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4242. {
  4243. try
  4244. {
  4245. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4246. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4247. if (dto.DiId == 0)
  4248. {
  4249. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4250. }
  4251. else
  4252. {
  4253. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4254. }
  4255. return Ok(JsonView(true, "查询成功!", new
  4256. {
  4257. deleClient = crm_Deles,
  4258. delegations = grp_Delegations
  4259. }));
  4260. }
  4261. catch (Exception ex)
  4262. {
  4263. return Ok(JsonView(false, "程序错误!"));
  4264. throw;
  4265. }
  4266. }
  4267. /// <summary>
  4268. /// 导出邀请函
  4269. /// </summary>
  4270. /// <param name="dto"></param>
  4271. /// <returns></returns>
  4272. [HttpPost]
  4273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4274. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4275. {
  4276. #region 参数验证
  4277. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4278. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4279. #endregion
  4280. try
  4281. {
  4282. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4283. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4284. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4285. From Grp_TourClientList tcl
  4286. Left Join
  4287. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4288. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4289. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4290. From Crm_DeleClient dc
  4291. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4292. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4293. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4294. Where dc.IsDel = 0) temp
  4295. On temp.DcId =tcl.ClientId
  4296. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4297. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4298. List<string> texts = new List<string>();
  4299. if (datas.Count != 0)
  4300. {
  4301. foreach (TourClientListDetailsView item in datas)
  4302. {
  4303. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4304. {
  4305. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4306. }
  4307. else
  4308. {
  4309. string name = item.LastName + item.FirstName;
  4310. texts.Add(name);
  4311. }
  4312. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4313. {
  4314. if (!transDic.ContainsKey(item.Job))
  4315. {
  4316. texts.Add(item.Job);
  4317. }
  4318. }
  4319. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4320. {
  4321. texts.Add(item.CompanyFullName);
  4322. }
  4323. }
  4324. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4325. if (transData.Count > 0)
  4326. {
  4327. foreach (TranslateResult item in transData)
  4328. {
  4329. if (!transDic.ContainsKey(item.Query))
  4330. {
  4331. transDic.Add(item.Query, item.Translation);
  4332. }
  4333. }
  4334. }
  4335. List<GuestList> list = new List<GuestList>();
  4336. foreach (TourClientListDetailsView dele in datas)
  4337. {
  4338. GuestList guestList = new GuestList();
  4339. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4340. {
  4341. guestList.Name = dele.Pinyin;
  4342. }
  4343. else
  4344. {
  4345. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4346. guestList.Name = Name;
  4347. }
  4348. if (dele.Sex == 0)
  4349. {
  4350. guestList.Sex = "Male";
  4351. }
  4352. else if (dele.Sex == 1)
  4353. {
  4354. guestList.Sex = "Female";
  4355. }
  4356. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4357. if (!string.IsNullOrEmpty(dele.Job))
  4358. {
  4359. guestList.Job = dele.Job;
  4360. }
  4361. list.Add(guestList);
  4362. }
  4363. //载入模板
  4364. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4365. DocumentBuilder builder = new DocumentBuilder(doc);
  4366. //获取word里所有表格
  4367. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4368. //获取所填表格的序数
  4369. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4370. var rowStart = tableOne.Rows[0]; //获取第1行
  4371. //循环赋值
  4372. for (int i = 0; i < list.Count; i++)
  4373. {
  4374. builder.MoveToCell(0, i + 1, 0, 0);
  4375. builder.Write(list[i].Name.ToString());
  4376. builder.MoveToCell(0, i + 1, 1, 0);
  4377. builder.Write(list[i].Sex.ToString());
  4378. builder.MoveToCell(0, i + 1, 2, 0);
  4379. builder.Write(list[i].DOB.ToString());
  4380. builder.MoveToCell(0, i + 1, 3, 0);
  4381. builder.Write(list[i].Job.ToString());
  4382. }
  4383. //删除多余行
  4384. while (tableOne.Rows.Count > list.Count + 1)
  4385. {
  4386. tableOne.Rows.RemoveAt(list.Count + 1);
  4387. }
  4388. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4389. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4390. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4391. doc.Save(filePath);
  4392. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4393. return Ok(JsonView(true, "操作成功!", Url));
  4394. }
  4395. else
  4396. {
  4397. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4398. }
  4399. }
  4400. catch (Exception ex)
  4401. {
  4402. return Ok(JsonView(false, ex.Message));
  4403. throw;
  4404. }
  4405. }
  4406. #endregion
  4407. #region 团组经理模块 出入境费用
  4408. /// <summary>
  4409. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4410. /// </summary>
  4411. /// <returns></returns>
  4412. [HttpPost]
  4413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4414. public async Task<IActionResult> SetDayAndCostAreaChange()
  4415. {
  4416. try
  4417. {
  4418. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4419. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4420. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4421. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4422. foreach (var item in unite) //处理交集数据
  4423. {
  4424. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4425. }
  4426. foreach (var item in merge) //处理差集数据
  4427. {
  4428. int nationalTravelFeeId = 0;
  4429. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4430. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4431. else
  4432. {
  4433. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4434. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4435. }
  4436. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4437. }
  4438. //只更新dayAndCost 的 nationalTravelFeeId;
  4439. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4440. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4441. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4442. }
  4443. catch (Exception ex)
  4444. {
  4445. return Ok(JsonView(false, ex.Message));
  4446. throw;
  4447. }
  4448. }
  4449. /// <summary>
  4450. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4451. /// </summary>
  4452. /// <returns></returns>
  4453. [HttpPost]
  4454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4455. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4456. {
  4457. try
  4458. {
  4459. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4460. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4461. //SetDataInfoView
  4462. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4463. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4464. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4465. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4466. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4467. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4468. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4469. //默认币种显示
  4470. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4471. {
  4472. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4473. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4474. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4475. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4476. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4477. };
  4478. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4479. if (_currencyRate.Count > 0)
  4480. {
  4481. foreach (var item in _currencyInfos)
  4482. {
  4483. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4484. if (rateInfo != null)
  4485. {
  4486. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4487. rate1 *= 1.035M;
  4488. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4489. }
  4490. }
  4491. }
  4492. return Ok(JsonView(true, "查询成功!", new
  4493. {
  4494. GroupNameData = groupNameData.Data,
  4495. CurrencyData = _CurrencyData,
  4496. WordTypeData = _WordTypeData,
  4497. ExcelTypeData = _ExcelTypeData,
  4498. CurrencyInit = _currencyInfos
  4499. }));
  4500. }
  4501. catch (Exception ex)
  4502. {
  4503. return Ok(JsonView(false, ex.Message));
  4504. throw;
  4505. }
  4506. }
  4507. /// <summary>
  4508. /// 团组模块 - 出入境费用
  4509. /// 实时汇率 tips
  4510. /// 签证费用 tips
  4511. /// 机票费用 tips
  4512. /// </summary>
  4513. /// <returns></returns>
  4514. [HttpPost]
  4515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4516. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4517. {
  4518. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4519. //默认币种显示
  4520. var _currencyInfos = _currencyInit;
  4521. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4522. List<dynamic> reteInfos = new List<dynamic>();
  4523. if (_currencyRate.Count > 0)
  4524. {
  4525. foreach (var item in _currencyInfos)
  4526. {
  4527. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4528. if (rateInfo != null)
  4529. {
  4530. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4531. decimal rate1 = item.Rate;
  4532. rate1 *= 1.03M;
  4533. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4534. reteInfos.Add(new
  4535. {
  4536. currCode = item.CurrencyCode,
  4537. currName = item.CurrencyName,
  4538. rate = rate2,
  4539. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4540. });
  4541. }
  4542. }
  4543. }
  4544. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4545. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4546. return Ok(JsonView(true, "查询成功!", new
  4547. {
  4548. //GroupNameData = groupNameData.Data,
  4549. visaData = visaData.Data,
  4550. airData = airData.Data,
  4551. reteInfos = reteInfos
  4552. }));
  4553. }
  4554. /// <summary>
  4555. /// 团组模块 - 出入境费用 - Info
  4556. /// </summary>
  4557. /// <returns></returns>
  4558. [HttpPost]
  4559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4560. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4561. {
  4562. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4563. }
  4564. /// <summary>
  4565. /// 团组模块 - 出入境费用 - Add And Update
  4566. /// </summary>
  4567. /// <returns></returns>
  4568. [HttpPost]
  4569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4570. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4571. {
  4572. try
  4573. {
  4574. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4575. if (dto.DayOtherPriceData.Any())
  4576. {
  4577. var inserList = dto.DayOtherPriceData
  4578. .Where(x => x.Id == 0)
  4579. .Select(x => new Grp_DayOtherPrice
  4580. {
  4581. Cost = x.Cost,
  4582. Id = x.Id,
  4583. CreateTime = DateTime.Now,
  4584. CreateUserId = dto.UserId,
  4585. Currency = x.Currency,
  4586. Diid = x.DiId,
  4587. Index = x.Index,
  4588. IsDel = 0,
  4589. SetDataId = x.SetDataId,
  4590. SubTotal = x.SubTotal,
  4591. Remark = x.Remark
  4592. })
  4593. .ToList();
  4594. var updateList = dto.DayOtherPriceData
  4595. .Where(x => x.Id != 0)
  4596. .Select(x => new Grp_DayOtherPrice
  4597. {
  4598. Cost = x.Cost,
  4599. Id = x.Id,
  4600. CreateTime = DateTime.Now,
  4601. CreateUserId = dto.UserId,
  4602. Currency = x.Currency,
  4603. Diid = x.DiId,
  4604. Index = x.Index,
  4605. IsDel = 0,
  4606. SetDataId = x.SetDataId,
  4607. SubTotal = x.SubTotal,
  4608. Remark = x.Remark
  4609. })
  4610. .ToList();
  4611. //添加
  4612. _sqlSugar.BeginTran();
  4613. if (inserList.Any())
  4614. {
  4615. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4616. }
  4617. if (updateList.Any())
  4618. {
  4619. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4620. }
  4621. _sqlSugar.CommitTran();
  4622. }
  4623. if (data.Code != 0)
  4624. {
  4625. return Ok(JsonView(false, data.Msg));
  4626. }
  4627. //生成默认文件pdf并且通知人员
  4628. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4629. {
  4630. DiId = dto.DiId,
  4631. ExportType = 1,
  4632. SubTypeId = 1005
  4633. }, "pdf");
  4634. //发送通知
  4635. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4636. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4637. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4638. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4639. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4640. //汇率信息记录
  4641. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4642. return Ok(JsonView(true, data.Msg, data.Data));
  4643. }
  4644. catch (Exception ex)
  4645. {
  4646. return Ok(JsonView(false, ex.Message));
  4647. }
  4648. }
  4649. /// <summary>
  4650. /// 团组模块 - 出入境费用 - Confirm 费用
  4651. /// </summary>
  4652. /// <returns></returns>
  4653. [HttpPost]
  4654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4655. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4656. {
  4657. //TODO:测试完毕需把对应的用户ID更改
  4658. //1、数据表添加字段
  4659. //2、更改字段接口()
  4660. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4661. //3、确认成功 给财务发送消息
  4662. if (_view.Code == 200)
  4663. {
  4664. if (dto.Type == 1)
  4665. {
  4666. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4667. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4668. }
  4669. }
  4670. return Ok(_view);
  4671. }
  4672. /// <summary>
  4673. /// 团组模块 - 出入境费用 - File downlaod
  4674. /// </summary>
  4675. /// <param name="dto"></param>
  4676. /// <returns></returns>
  4677. [HttpPost]
  4678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4679. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4680. {
  4681. try
  4682. {
  4683. if (dto.DiId < 1)
  4684. {
  4685. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4686. }
  4687. if (dto.ExportType < 1)
  4688. {
  4689. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4690. }
  4691. if (dto.SubTypeId < 1)
  4692. {
  4693. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4694. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4695. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4696. 3 团组成员名单 1 团组成员名单", ""));
  4697. }
  4698. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4699. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4700. if (_EnterExitCosts == null)
  4701. {
  4702. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4703. }
  4704. //数据源
  4705. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4706. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4707. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4708. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4709. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4710. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4711. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4712. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4713. .Select((x, a, b) => new
  4714. {
  4715. x.Index,
  4716. itemName = a.Name,
  4717. CurrencyStr = b.Name,
  4718. x.Cost,
  4719. x.SubTotal,
  4720. x.Remark
  4721. })
  4722. .OrderBy((x) => x.Index)
  4723. .ToList(); //其他款项费用
  4724. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4725. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4726. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4727. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4728. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4729. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4730. .Select((tcl, dc, cc) => new ClientInfo
  4731. {
  4732. LastName = dc.LastName,
  4733. FirstName = dc.FirstName,
  4734. Sex = dc.Sex,
  4735. Birthday = dc.BirthDay,
  4736. Company = cc.CompanyFullName,
  4737. Job = dc.Job
  4738. })
  4739. .ToList();
  4740. foreach (var item in DeleClientList)
  4741. {
  4742. EncryptionProcessor.DecryptProperties(item);
  4743. }
  4744. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4745. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4746. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4747. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4748. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4749. if (dto.ExportType == 1) //明细表
  4750. {
  4751. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4752. {
  4753. //获取模板
  4754. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4755. //载入模板
  4756. Document doc = new Document(tempPath);
  4757. DocumentBuilder builder = new DocumentBuilder(doc);
  4758. //利用键值对存放数据
  4759. Dictionary<string, string> dic = new Dictionary<string, string>();
  4760. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4761. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4762. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4763. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4764. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4765. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4766. //境内费用(其他费用)
  4767. if (_EnterExitCosts.ChoiceOne == 1)
  4768. {
  4769. string row1_1 = "";
  4770. if (_EnterExitCosts.Visa > 0)
  4771. {
  4772. //insidePayTotal += _EnterExitCosts.Visa;
  4773. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4774. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4775. {
  4776. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4777. }
  4778. }
  4779. string row1_2 = "";
  4780. if (_EnterExitCosts.YiMiao > 0)
  4781. {
  4782. //insidePayTotal += _EnterExitCosts.YiMiao;
  4783. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4784. }
  4785. if (_EnterExitCosts.HeSuan > 0)
  4786. {
  4787. //insidePayTotal += _EnterExitCosts.HeSuan;
  4788. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4789. }
  4790. if (_EnterExitCosts.Service > 0)
  4791. {
  4792. //insidePayTotal += _EnterExitCosts.Service;
  4793. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4794. }
  4795. string row1_3 = "";
  4796. if (_EnterExitCosts.Safe > 0)
  4797. {
  4798. //insidePayTotal += _EnterExitCosts.Safe;
  4799. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4800. }
  4801. if (_EnterExitCosts.Ticket > 0)
  4802. {
  4803. //insidePayTotal += _EnterExitCosts.Ticket;
  4804. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4805. }
  4806. string row1 = "";
  4807. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4808. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4809. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4810. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4811. dic.Add("Row1Str", row1);
  4812. }
  4813. string airTotalStr = string.Empty,
  4814. airPriceStr = string.Empty;
  4815. //经济舱
  4816. if (_EnterExitCosts.SumJJC == 1)
  4817. {
  4818. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4819. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4820. }
  4821. //公务舱
  4822. if (_EnterExitCosts.SumGWC == 1)
  4823. {
  4824. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4825. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4826. }
  4827. //头等舱
  4828. if (_EnterExitCosts.SumTDC == 1)
  4829. {
  4830. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4831. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4832. }
  4833. dic.Add("AirTotalStr", airTotalStr);
  4834. dic.Add("AirPriceStr", airPriceStr);
  4835. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4836. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4837. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4838. int table1Row = 0,
  4839. table2Row = 0,
  4840. table3Row = 0,
  4841. table4Row = 0,
  4842. table5Row = 0;
  4843. //住宿费
  4844. if (_EnterExitCosts.ChoiceThree == 1)
  4845. {
  4846. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4847. table1Row = dac1.Count;
  4848. #region 填充word表格内容
  4849. for (int i = 0; i < dac1.Count; i++)
  4850. {
  4851. Grp_DayAndCost dac = dac1[i];
  4852. if (dac == null) continue;
  4853. builder.MoveToCell(0, i, 0, 0);
  4854. builder.Write("第" + dac.Days.ToString() + "晚:");
  4855. builder.MoveToCell(0, i, 1, 0);
  4856. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4857. //builder.Write(dac.Place == null ? "" : dac.Place);
  4858. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4859. builder.MoveToCell(0, i, 2, 0);
  4860. builder.Write("费用标准:");
  4861. string curr = "";
  4862. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4863. if (currData != null)
  4864. {
  4865. curr = currData.Name;
  4866. }
  4867. builder.MoveToCell(0, i, 3, 0);
  4868. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4869. builder.MoveToCell(0, i, 4, 0);
  4870. builder.Write("费用小计:");
  4871. builder.MoveToCell(0, i, 5, 0);
  4872. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4873. }
  4874. #endregion
  4875. }
  4876. else dic.Add("SubZS", "0.00");
  4877. //删除多余行
  4878. while (table1.Rows.Count > table1Row)
  4879. {
  4880. table1.Rows.RemoveAt(table1Row);
  4881. }
  4882. //伙食费
  4883. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4884. if (_EnterExitCosts.ChoiceFour == 1)
  4885. {
  4886. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4887. table2Row = dac2.Count;
  4888. #region 填充word表格内容
  4889. for (int i = 0; i < dac2.Count; i++)
  4890. {
  4891. Grp_DayAndCost dac = dac2[i];
  4892. if (dac == null) continue;
  4893. builder.MoveToCell(1, i, 0, 0);
  4894. builder.Write("第" + dac.Days.ToString() + "天:");
  4895. builder.MoveToCell(1, i, 1, 0);
  4896. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4897. builder.MoveToCell(1, i, 2, 0);
  4898. builder.Write("费用标准:");
  4899. string curr = "";
  4900. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4901. if (currData != null)
  4902. {
  4903. curr = currData.Name;
  4904. }
  4905. builder.MoveToCell(1, i, 3, 0);
  4906. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4907. builder.MoveToCell(1, i, 4, 0);
  4908. builder.Write("费用小计:");
  4909. builder.MoveToCell(1, i, 5, 0);
  4910. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4911. }
  4912. #endregion
  4913. }
  4914. else dic.Add("SubHS", "0.00");
  4915. //删除多余行
  4916. while (table2.Rows.Count > table2Row)
  4917. {
  4918. table2.Rows.RemoveAt(table2Row);
  4919. }
  4920. //公杂费
  4921. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4922. if (_EnterExitCosts.ChoiceFive == 1)
  4923. {
  4924. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4925. table3Row = dac3.Count;
  4926. #region 填充word表格内容
  4927. for (int i = 0; i < dac3.Count; i++)
  4928. {
  4929. Grp_DayAndCost dac = dac3[i];
  4930. if (dac == null) continue;
  4931. builder.MoveToCell(2, i, 0, 0);
  4932. builder.Write("第" + dac.Days.ToString() + "天:");
  4933. builder.MoveToCell(2, i, 1, 0);
  4934. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4935. builder.MoveToCell(2, i, 2, 0);
  4936. builder.Write("费用标准:");
  4937. string curr = "";
  4938. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4939. if (currData != null)
  4940. {
  4941. curr = currData.Name;
  4942. }
  4943. builder.MoveToCell(2, i, 3, 0);
  4944. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4945. builder.MoveToCell(2, i, 4, 0);
  4946. builder.Write("费用小计:");
  4947. builder.MoveToCell(2, i, 5, 0);
  4948. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4949. }
  4950. //删除多余行
  4951. while (table3.Rows.Count > table3Row)
  4952. {
  4953. table3.Rows.RemoveAt(table3Row);
  4954. }
  4955. #endregion
  4956. }
  4957. else dic.Add("SubGZF", "0.00");
  4958. //删除多余行
  4959. while (table3.Rows.Count > table3Row)
  4960. {
  4961. table3.Rows.RemoveAt(table3Row);
  4962. }
  4963. //培训费
  4964. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4965. if (_EnterExitCosts.ChoiceSix == 1)
  4966. {
  4967. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4968. dic.Add("SubPX", pxStr);
  4969. table4Row = dac4.Count;
  4970. #region 填充word表格内容
  4971. for (int i = 0; i < dac4.Count; i++)
  4972. {
  4973. Grp_DayAndCost dac = dac4[i];
  4974. if (dac == null) continue;
  4975. builder.MoveToCell(3, i, 0, 0);
  4976. builder.Write("第" + dac.Days.ToString() + "天:");
  4977. builder.MoveToCell(3, i, 1, 0);
  4978. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4979. builder.MoveToCell(3, i, 2, 0);
  4980. builder.Write("费用标准:");
  4981. string curr = "";
  4982. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4983. if (currData != null)
  4984. {
  4985. curr = currData.Name;
  4986. }
  4987. builder.MoveToCell(3, i, 3, 0);
  4988. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4989. builder.MoveToCell(3, i, 4, 0);
  4990. builder.Write("费用小计:");
  4991. builder.MoveToCell(3, i, 5, 0);
  4992. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4993. }
  4994. #endregion
  4995. }
  4996. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  4997. //删除多余行
  4998. while (table4.Rows.Count > table4Row)
  4999. {
  5000. table4.Rows.RemoveAt(table4Row);
  5001. }
  5002. //其他费用
  5003. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5004. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5005. {
  5006. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5007. dic.Add("titleQi", qtStr);
  5008. table5Row = dac5.Count;
  5009. #region 填充word表格内容
  5010. for (int i = 0; i < dac5.Count; i++)
  5011. {
  5012. var dac = dac5[i];
  5013. if (dac == null) continue;
  5014. builder.MoveToCell(4, i, 0, 0);
  5015. builder.Write("第" + dac.Index.ToString() + "项:");
  5016. builder.MoveToCell(4, i, 1, 0);
  5017. builder.Write(dac.itemName);
  5018. builder.MoveToCell(4, i, 2, 0);
  5019. builder.Write("费用标准:");
  5020. builder.MoveToCell(4, i, 3, 0);
  5021. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5022. builder.MoveToCell(4, i, 4, 0);
  5023. builder.Write("费用小计:");
  5024. builder.MoveToCell(4, i, 5, 0);
  5025. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5026. builder.MoveToCell(4, i, 6, 0);
  5027. builder.Write("备注:");
  5028. builder.MoveToCell(4, i, 7, 0);
  5029. builder.Write(dac.Remark);
  5030. }
  5031. #endregion
  5032. }
  5033. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5034. //删除多余行
  5035. while (table5.Rows.Count > table5Row)
  5036. {
  5037. table5.Rows.RemoveAt(table5Row);
  5038. }
  5039. //加上其他费用
  5040. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5041. decimal subJJC = 0.00M,
  5042. subGWC = 0.00M,
  5043. subTDC = 0.00M;
  5044. //经济舱
  5045. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5046. //公务舱
  5047. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5048. //头等舱
  5049. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5050. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5051. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5052. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5053. #region 填充word模板书签内容
  5054. foreach (var key in dic.Keys)
  5055. {
  5056. Bookmark bookmark = doc.Range.Bookmarks[key];
  5057. if (bookmark != null)
  5058. {
  5059. builder.MoveToBookmark(key);
  5060. builder.Write(dic[key]);
  5061. }
  5062. }
  5063. #endregion
  5064. //文件名
  5065. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5066. AsposeHelper.removewatermark_v2180();
  5067. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5068. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5069. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5070. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5071. }
  5072. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5073. {
  5074. //获取模板
  5075. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5076. //载入模板
  5077. Document doc = new Document(tempPath);
  5078. DocumentBuilder builder = new DocumentBuilder(doc);
  5079. Dictionary<string, string> dic = new Dictionary<string, string>();
  5080. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5081. {
  5082. List<string> list = new List<string>();
  5083. try
  5084. {
  5085. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5086. foreach (var item in spilitArr)
  5087. {
  5088. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5089. var depCode = spDotandEmpty[2].Substring(0, 3);
  5090. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5091. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5092. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5093. list.Add(depName);
  5094. list.Add(arrName);
  5095. }
  5096. list = list.Distinct().ToList();
  5097. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5098. }
  5099. catch (Exception)
  5100. {
  5101. dic.Add("ReturnCode", "行程录入不正确!");
  5102. }
  5103. }
  5104. else
  5105. {
  5106. dic.Add("ReturnCode", "未录入行程!");
  5107. }
  5108. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5109. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5110. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5111. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5112. {
  5113. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5114. dic.Add("Day", sp.Days.ToString());
  5115. }
  5116. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5117. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5118. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5119. //dic.Add("Names", Names);
  5120. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5121. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5122. decimal dac1totalPrice = 0.00M;
  5123. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5124. foreach (var dac in dac1)
  5125. {
  5126. if (dac.SubTotal == 0.00M)
  5127. {
  5128. continue;
  5129. }
  5130. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5131. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5132. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5133. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5134. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5135. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5136. builder.Write(currency);//币种
  5137. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5138. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5139. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5140. builder.Write("");//人数
  5141. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5142. builder.Write("");//天数
  5143. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5144. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5145. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5146. decimal rate = 0.00M;
  5147. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5148. builder.Write(rate.ToString("#0.0000"));//汇率
  5149. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5150. decimal rbmPrice = dac.SubTotal;
  5151. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5152. accommodationStartIndex++;
  5153. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5154. }
  5155. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5156. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5157. {
  5158. table1.Rows.RemoveAt(i - 1);
  5159. foodandotherStartIndex--;
  5160. }
  5161. if (dac2.Count == dac3.Count)//国家 币种 金额
  5162. {
  5163. for (int i = 0; i < dac2.Count; i++)
  5164. {
  5165. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5166. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5167. }
  5168. }
  5169. decimal dac2totalPrice = 0.00M;
  5170. foreach (var dac in dac2)
  5171. {
  5172. if (dac.SubTotal == 0)
  5173. {
  5174. continue;
  5175. }
  5176. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5177. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5178. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5179. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5180. builder.Write(currency);//币种
  5181. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5182. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5183. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5184. builder.Write("");//人数
  5185. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5186. builder.Write("");//天数
  5187. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5188. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5189. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5190. decimal rate = 0.00M;
  5191. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5192. builder.Write(rate.ToString("#0.0000"));//汇率
  5193. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5194. decimal rbmPrice = dac.SubTotal;
  5195. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5196. foodandotherStartIndex++;
  5197. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5198. }
  5199. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5200. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5201. {
  5202. table1.Rows.RemoveAt(i - 1);
  5203. }
  5204. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5205. string otherFeeStr = "";
  5206. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5207. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5208. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5209. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5210. foreach (var otherInfo in dac5)
  5211. {
  5212. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5213. }
  5214. #endregion
  5215. if (otherFeeStr.Length > 0)
  5216. {
  5217. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5218. otherFeeStr = $"({otherFeeStr})";
  5219. dic.Add("OtherFeeStr", otherFeeStr);
  5220. }
  5221. //总计
  5222. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5223. //国际旅费
  5224. string outsideAir = string.Empty;
  5225. string allPriceAir = string.Empty;
  5226. if (_EnterExitCosts.SumJJC == 1)
  5227. {
  5228. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5229. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5230. }
  5231. if (_EnterExitCosts.SumGWC == 1)
  5232. {
  5233. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5234. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5235. }
  5236. if (_EnterExitCosts.SumTDC == 1)
  5237. {
  5238. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5239. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5240. }
  5241. dic.Add("InTravelPrice", $"({outsideAir})");
  5242. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5243. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5244. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5245. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5246. foreach (var key in dic.Keys)
  5247. {
  5248. builder.MoveToBookmark(key);
  5249. builder.Write(dic[key]);
  5250. }
  5251. //模板文件名
  5252. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5253. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5254. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5255. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5256. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5257. }
  5258. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5259. {
  5260. //获取模板
  5261. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5262. //载入模板
  5263. WorkbookDesigner designer = new WorkbookDesigner();
  5264. designer.Workbook = new Workbook(tempPath);
  5265. Dictionary<string, string> dic = new Dictionary<string, string>();
  5266. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5267. {
  5268. List<string> list = new List<string>();
  5269. try
  5270. {
  5271. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5272. foreach (var item in spilitArr)
  5273. {
  5274. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5275. var depCode = spDotandEmpty[2].Substring(0, 3);
  5276. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5277. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5278. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5279. list.Add(depName);
  5280. list.Add(arrName);
  5281. }
  5282. list = list.Distinct().ToList();
  5283. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5284. }
  5285. catch (Exception)
  5286. {
  5287. dic.Add("ReturnCode", "行程录入不正确!");
  5288. }
  5289. }
  5290. else
  5291. {
  5292. dic.Add("ReturnCode", "未录入行程!");
  5293. }
  5294. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5295. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5296. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5297. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5298. {
  5299. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5300. dic.Add("Day", sp.Days.ToString());
  5301. }
  5302. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5303. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5304. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5305. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5306. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5307. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5308. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5309. designer.SetDataSource("Name", Names);
  5310. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5311. designer.SetDataSource("Day", dic["Day"] + "天");
  5312. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5313. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5314. int startIndex = 10;
  5315. const int startIndexcopy = 10;
  5316. if (dac2.Count == dac3.Count)//国家 币种 金额
  5317. {
  5318. for (int i = 0; i < dac2.Count; i++)
  5319. {
  5320. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5321. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5322. }
  5323. }
  5324. DataTable dtdac1 = new DataTable();
  5325. List<string> place = new List<string>();
  5326. dtdac1.Columns.AddRange(new DataColumn[] {
  5327. new DataColumn(){ ColumnName = "city"},
  5328. new DataColumn(){ ColumnName = "curr"},
  5329. new DataColumn(){ ColumnName = "criterion"},
  5330. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5331. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5332. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5333. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5334. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5335. });
  5336. DataTable dtdac2 = new DataTable();
  5337. dtdac2.Columns.AddRange(new DataColumn[] {
  5338. new DataColumn(){ ColumnName = "city"},
  5339. new DataColumn(){ ColumnName = "curr"},
  5340. new DataColumn(){ ColumnName = "criterion"},
  5341. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5342. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5343. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5344. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5345. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5346. });
  5347. dtdac1.TableName = "tb1";
  5348. dtdac2.TableName = "tb2";
  5349. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5350. foreach (var item in dac1)
  5351. {
  5352. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5353. if (place.Contains(item.Place))
  5354. {
  5355. continue;
  5356. }
  5357. DataRow row = dtdac1.NewRow();
  5358. row["city"] = item.Place;
  5359. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5360. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5361. row["curr"] = currency;
  5362. row["rate"] = rate.ToString("#0.0000");
  5363. row["criterion"] = item.Cost.ToString("#0.00");
  5364. row["number"] = 1;
  5365. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5366. //row["costRMB"] = rbmPrice;
  5367. dtdac1.Rows.Add(row);
  5368. place.Add(item.Place);
  5369. }
  5370. place = new List<string>();
  5371. foreach (var item in dac2)
  5372. {
  5373. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5374. if (place.Contains(item.Place))
  5375. {
  5376. continue;
  5377. }
  5378. DataRow row = dtdac2.NewRow();
  5379. row["city"] = item.Place;
  5380. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5381. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5382. row["curr"] = currency;
  5383. row["rate"] = rate.ToString("#0.0000");
  5384. row["criterion"] = item.Cost.ToString("#0.00");
  5385. row["number"] = 1;
  5386. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5387. //row["cost"] = item.SubTotal;
  5388. //row["costRMB"] = rbmPrice;
  5389. dtdac2.Rows.Add(row);
  5390. place.Add(item.Place);
  5391. //dac2totalPrice += rbmPrice;
  5392. }
  5393. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5394. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5395. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5396. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5397. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5398. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5399. string cell4Str1 = string.Empty;
  5400. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5401. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5402. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5403. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5404. string cellStr = $" 5.其他费用(";
  5405. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5406. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5407. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5408. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5409. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5410. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5411. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5412. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5413. foreach (var otherInfo in dac5)
  5414. {
  5415. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5416. }
  5417. #endregion
  5418. if (cellStr.Length > 8)
  5419. {
  5420. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5421. }
  5422. cellStr += ")";
  5423. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5424. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5425. decimal pxFee = dac4.Sum(it => it.Cost);
  5426. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5427. string celllastStr1 = "";
  5428. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5429. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5430. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5431. celllastStr1 += $",国际旅费 元";
  5432. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5433. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5434. designer.SetDataSource("cell4Str", cell4Str);
  5435. designer.SetDataSource("cellStr", cellStr);
  5436. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5437. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5438. designer.SetDataSource("celllastStr", celllastStr);
  5439. Workbook wb = designer.Workbook;
  5440. var sheet = wb.Worksheets[0];
  5441. //绑定datatable数据集
  5442. designer.SetDataSource(dtdac1);
  5443. designer.SetDataSource(dtdac2);
  5444. designer.Process();
  5445. var rowStart = dtdac1.Rows.Count;
  5446. while (rowStart > 0)
  5447. {
  5448. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5449. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5450. startIndex++;
  5451. rowStart--;
  5452. }
  5453. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5454. startIndex += 1; //总计行
  5455. rowStart = dtdac2.Rows.Count;
  5456. while (rowStart > 0)
  5457. {
  5458. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5459. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5460. startIndex++;
  5461. rowStart--;
  5462. }
  5463. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5464. wb.CalculateFormula(true);
  5465. //模板文件名
  5466. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5467. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5468. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5469. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5470. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5471. }
  5472. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5473. {
  5474. //获取模板
  5475. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5476. //载入模板
  5477. Document doc = new Document(tempPath);
  5478. DocumentBuilder builder = new DocumentBuilder(doc);
  5479. Dictionary<string, string> dic = new Dictionary<string, string>();
  5480. dic.Add("GroupName", _DelegationInfo.TeamName);
  5481. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5482. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5483. string missionLeaderJob = "";//负责人job
  5484. int groupNumber = 0; //团人数
  5485. if (DeleClientList.Count > 0)
  5486. {
  5487. missionLeader = DeleClientList[0]?.Name ?? "";
  5488. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5489. }
  5490. dic.Add("MissionLeader", missionLeader); //团负责人
  5491. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5492. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5493. #region MyRegion
  5494. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5495. //{
  5496. // List<string> list = new List<string>();
  5497. // try
  5498. // {
  5499. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5500. // foreach (var item in spilitArr)
  5501. // {
  5502. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5503. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5504. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5505. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5506. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5507. // list.Add(depName);
  5508. // list.Add(arrName);
  5509. // }
  5510. // list = list.Distinct().ToList();
  5511. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5512. // }
  5513. // catch (Exception)
  5514. // {
  5515. // dic.Add("ReturnCode", "行程录入不正确!");
  5516. // }
  5517. //}
  5518. //else
  5519. //{
  5520. // dic.Add("ReturnCode", "未录入行程!");
  5521. //}
  5522. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5523. dic.Add("ReturnCode", string.Join("、", countrys));
  5524. #endregion
  5525. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5526. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5527. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5528. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5529. //{
  5530. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5531. // dic.Add("Day", sp.Days.ToString());
  5532. //}
  5533. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5534. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5535. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5536. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5537. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5538. //培训人员名单
  5539. int cultivateRowIndex = 7;
  5540. foreach (var item in DeleClientList)
  5541. {
  5542. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5543. builder.Write(item.Name);
  5544. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5545. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5546. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5547. string birthDay = "";
  5548. if (item.Birthday != null)
  5549. {
  5550. DateTime dt = Convert.ToDateTime(item.Birthday);
  5551. birthDay = $"{dt.Year}.{dt.Month}";
  5552. }
  5553. builder.Write(birthDay);
  5554. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5555. builder.Write(item.Company);
  5556. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5557. builder.Write(item.Job);
  5558. cultivateRowIndex++;
  5559. }
  5560. //删除多余行
  5561. //cultivateRowIndex -= 2;
  5562. int delRows = 10 + 7 - cultivateRowIndex;
  5563. if (delRows > 0)
  5564. {
  5565. for (int i = 0; i < delRows; i++)
  5566. {
  5567. table1.Rows.RemoveAt(cultivateRowIndex);
  5568. //cultivateRowIndex++;
  5569. }
  5570. }
  5571. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5572. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5573. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5574. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5575. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5576. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5577. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5578. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5579. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5580. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5581. //其他费用
  5582. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5583. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5584. //其他费用合计
  5585. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5586. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5587. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5588. //公务舱合计
  5589. //国际旅费
  5590. string outsideJJ = "";
  5591. string allPriceJJ = "";
  5592. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5593. {
  5594. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5595. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5596. }
  5597. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5598. {
  5599. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5600. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5601. }
  5602. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5603. {
  5604. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5605. dic.Add("AirFeeTotal", airFeeTotalStr);
  5606. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5607. dic.Add("FeeTotal", feeTotalStr);
  5608. }
  5609. foreach (var key in dic.Keys)
  5610. {
  5611. builder.MoveToBookmark(key);
  5612. builder.Write(dic[key]);
  5613. }
  5614. //模板文件名
  5615. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5616. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5617. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5618. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5619. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5620. }
  5621. }
  5622. else if (dto.ExportType == 2) //表格
  5623. {
  5624. //利用键值对存放数据
  5625. Dictionary<string, string> dic = new Dictionary<string, string>();
  5626. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5627. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5628. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5629. dic.Add("Day", sp.Days.ToString());
  5630. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5631. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5632. {
  5633. //获取模板
  5634. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5635. //载入模板
  5636. Document doc = new Document(tempPath);
  5637. DocumentBuilder builder = new DocumentBuilder(doc);
  5638. dic.Add("TeamName", _DelegationInfo.TeamName);
  5639. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5640. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5641. string missionLeaderName = "",
  5642. missionLeaderJob = "";
  5643. if (DeleClientList.Count > 0)
  5644. {
  5645. missionLeaderName = DeleClientList[0].Name;
  5646. missionLeaderJob = DeleClientList[0].Job;
  5647. }
  5648. dic.Add("MissionLeaderName", missionLeaderName);
  5649. dic.Add("MissionLeaderJob", missionLeaderJob);
  5650. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5651. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5652. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5653. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5654. int rowCount = 10;//总人数行
  5655. int startRowIndex = 7; //起始行
  5656. for (int i = 0; i < DeleClientList.Count; i++)
  5657. {
  5658. builder.MoveToCell(0, startRowIndex, 0, 0);
  5659. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5660. builder.MoveToCell(0, startRowIndex, 1, 0);
  5661. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5662. builder.Write(sex);//性别
  5663. builder.MoveToCell(0, startRowIndex, 2, 0);
  5664. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5665. builder.MoveToCell(0, startRowIndex, 3, 0);
  5666. builder.Write(DeleClientList[i].Company);//工作单位
  5667. builder.MoveToCell(0, startRowIndex, 4, 0);
  5668. builder.Write(DeleClientList[i].Job);//职务及级别
  5669. builder.MoveToCell(0, startRowIndex, 5, 0);
  5670. builder.Write("");//人员属性
  5671. builder.MoveToCell(0, startRowIndex, 6, 0);
  5672. builder.Write("");//上次出国时间
  5673. startRowIndex++;
  5674. }
  5675. int nullRow = rowCount - DeleClientList.Count;//空行
  5676. for (int i = 0; i < nullRow; i++)
  5677. {
  5678. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5679. }
  5680. foreach (var key in dic.Keys)
  5681. {
  5682. builder.MoveToBookmark(key);
  5683. builder.Write(dic[key]);
  5684. }
  5685. //模板文件名
  5686. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5687. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5688. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5689. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5690. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5691. }
  5692. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5693. {
  5694. //获取模板
  5695. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5696. //载入模板
  5697. Document doc = new Document(tempPath);
  5698. DocumentBuilder builder = new DocumentBuilder(doc);
  5699. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5700. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5701. dic.Add("Names", Names);
  5702. int accommodationRows = 12, foodandotherRows = 12;
  5703. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5704. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5705. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5706. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5707. int accommodationStartIndex = 6;
  5708. decimal dac1totalPrice = 0.00M;
  5709. foreach (var dac in dac1)
  5710. {
  5711. if (dac.SubTotal == 0)
  5712. {
  5713. continue;
  5714. }
  5715. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5716. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5717. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5718. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5719. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5720. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5721. builder.Write(currency);//币种
  5722. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5723. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5724. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5725. builder.Write("");//人数
  5726. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5727. builder.Write("");//天数
  5728. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5729. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5730. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5731. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5732. builder.Write(rate.ToString("#0.0000"));//汇率
  5733. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5734. decimal rbmPrice = rate * dac.SubTotal;
  5735. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5736. accommodationStartIndex++;
  5737. dac1totalPrice += rbmPrice;
  5738. }
  5739. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5740. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5741. builder.Write("小计");
  5742. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5743. builder.Write(dac1totalPrice.ToString("#0.00"));
  5744. accommodationStartIndex++;
  5745. int nullRow = accommodationRows - dac1.Count;
  5746. //删除空行
  5747. //if (nullRow > 0)
  5748. //{
  5749. // int rowIndex = accommodationStartIndex;
  5750. // for (int i = 0; i < nullRow; i++)
  5751. // {
  5752. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5753. // row.Remove();
  5754. // rowIndex++;
  5755. // }
  5756. //}
  5757. if (dac2.Count == dac3.Count)//国家 币种 金额
  5758. {
  5759. for (int i = 0; i < dac2.Count; i++)
  5760. {
  5761. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5762. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5763. }
  5764. }
  5765. int foodandotherStartIndex = 19;//
  5766. decimal dac2totalPrice = 0.00M;
  5767. foreach (var dac in dac2)
  5768. {
  5769. if (dac.SubTotal == 0)
  5770. {
  5771. continue;
  5772. }
  5773. //foodandotherStartIndex = 12;
  5774. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5775. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5776. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5777. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5778. builder.Write(currency);//币种
  5779. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5780. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5781. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5782. builder.Write("");//人数
  5783. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5784. builder.Write("");//天数
  5785. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5786. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5787. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5788. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5789. builder.Write(rate.ToString("#0.0000"));//汇率
  5790. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5791. decimal rbmPrice = rate * dac.SubTotal;
  5792. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5793. foodandotherStartIndex++;
  5794. dac2totalPrice += rbmPrice;
  5795. }
  5796. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5797. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5798. //删除空行
  5799. //if (dac2.Count < foodandotherRows)
  5800. //{
  5801. // while (table2.Rows.Count > dac2.Count)
  5802. // {
  5803. // table2.Rows.RemoveAt(dac2.Count);
  5804. // }
  5805. //}
  5806. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5807. string otherFeeStr = "";
  5808. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5809. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5810. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5811. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5812. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5813. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5814. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5815. foreach (var otherInfo in dac5)
  5816. {
  5817. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5818. }
  5819. #endregion
  5820. if (otherFeeStr.Length > 0)
  5821. {
  5822. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5823. otherFeeStr = $"({otherFeeStr})";
  5824. dic.Add("OtherFeeStr", otherFeeStr);
  5825. }
  5826. foreach (var key in dic.Keys)
  5827. {
  5828. builder.MoveToBookmark(key);
  5829. builder.Write(dic[key]);
  5830. }
  5831. //模板文件名
  5832. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5833. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5834. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5835. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5836. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5837. }
  5838. }
  5839. else if (dto.ExportType == 3)
  5840. {
  5841. if (dto.SubTypeId == 1) //团组成员名单
  5842. {
  5843. if (DeleClientList.Count < 1)
  5844. {
  5845. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5846. }
  5847. //获取模板
  5848. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5849. //载入模板
  5850. Document doc = new Document(tempPath);
  5851. DocumentBuilder builder = new DocumentBuilder(doc);
  5852. //获取word里所有表格
  5853. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5854. //获取所填表格的序数
  5855. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5856. var rowStart = tableOne.Rows[0]; //获取第1行
  5857. //循环赋值
  5858. for (int i = 0; i < DeleClientList.Count; i++)
  5859. {
  5860. builder.MoveToCell(0, i + 1, 0, 0);
  5861. builder.Write(DeleClientList[i].Name);
  5862. builder.MoveToCell(0, i + 1, 1, 0);
  5863. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5864. builder.Write(sex);
  5865. builder.MoveToCell(0, i + 1, 2, 0);
  5866. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5867. builder.MoveToCell(0, i + 1, 3, 0);
  5868. builder.Write(DeleClientList[i].Company);
  5869. builder.MoveToCell(0, i + 1, 4, 0);
  5870. builder.Write(DeleClientList[i].Job);
  5871. }
  5872. //删除多余行
  5873. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5874. {
  5875. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5876. }
  5877. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5878. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5879. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5880. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5881. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5882. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5883. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5884. }
  5885. }
  5886. return Ok(JsonView(400, "操作失败!", ""));
  5887. }
  5888. catch (Exception ex)
  5889. {
  5890. return Ok(JsonView(400, ex.Message, ""));
  5891. }
  5892. }
  5893. /// <summary>
  5894. /// 获取三公费用标准city
  5895. /// </summary>
  5896. /// <param name="placeData"></param>
  5897. /// <param name="nationalTravelFeeId"></param>
  5898. /// <returns></returns>
  5899. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5900. {
  5901. string _city = string.Empty;
  5902. if (placeData.Count < 1) return _city;
  5903. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5904. if (data == null) return _city;
  5905. string country = data.Country;
  5906. string city = data.City;
  5907. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5908. else _city = city;
  5909. return _city;
  5910. }
  5911. /// <summary>
  5912. /// 团组模块 - 出入境费用 - 明细表导出
  5913. /// </summary>
  5914. /// <returns></returns>
  5915. [HttpPost]
  5916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5917. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5918. {
  5919. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5920. if (data.Code != 0)
  5921. {
  5922. return Ok(JsonView(false, data.Msg));
  5923. }
  5924. return Ok(JsonView(true, data.Msg, data.Data));
  5925. }
  5926. /// <summary>
  5927. /// 团组模块 - 出入境费用 - 一键清空
  5928. /// </summary>
  5929. /// <returns></returns>
  5930. [HttpPost]
  5931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5932. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5933. {
  5934. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5935. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5936. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5937. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5938. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5939. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5940. .SetColumns(x => new Grp_DayOtherPrice
  5941. {
  5942. IsDel = 1,
  5943. DeleteUserId = dto.UserId,
  5944. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5945. })
  5946. .ExecuteCommandAsync();
  5947. if (_view.Code == 0)
  5948. {
  5949. return Ok(JsonView(true, "操作成功"));
  5950. }
  5951. return Ok(JsonView(false, "操作失败"));
  5952. }
  5953. /// <summary>
  5954. /// 团组模块 - 出入境费用 - 子项删除
  5955. /// </summary>
  5956. /// <returns></returns>
  5957. [HttpPost]
  5958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5959. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5960. {
  5961. try
  5962. {
  5963. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5964. if (data.Code != 0)
  5965. {
  5966. return Ok(JsonView(false, data.Msg));
  5967. }
  5968. return Ok(JsonView(true, "操作成功!", data.Data));
  5969. }
  5970. catch (Exception ex)
  5971. {
  5972. return Ok(JsonView(false, ex.Message));
  5973. }
  5974. }
  5975. /// <summary>
  5976. /// 删除三公其他费用
  5977. /// </summary>
  5978. /// <param name="dto"></param>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5982. {
  5983. var jw = JsonView(false,"删除失败!");
  5984. var data = new Grp_DayOtherPrice()
  5985. {
  5986. Id = dto.Id,
  5987. IsDel = 1,
  5988. DeleteUserId = dto.DeleteUserId,
  5989. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  5990. };
  5991. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  5992. if (del > 0)
  5993. {
  5994. jw.Code = 200;
  5995. jw.Msg = "删除成功!";
  5996. }
  5997. return Ok(jw);
  5998. }
  5999. /// <summary>
  6000. /// 团组模块 - 出入境国家费用标准 List
  6001. /// </summary>
  6002. /// <returns></returns>
  6003. [HttpPost]
  6004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6005. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6006. {
  6007. try
  6008. {
  6009. Stopwatch sw = new Stopwatch();
  6010. sw.Start();
  6011. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6012. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6013. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6014. Where gntf.Isdel = 0");
  6015. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6016. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6017. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6018. //foreach (var item in nationalTravel)
  6019. //{
  6020. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6021. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6022. // if (otherData != null)
  6023. // {
  6024. // cityData.Remove(otherData);
  6025. // cityData.Add(otherData);
  6026. // }
  6027. // nationalTravelFeeData1.Add(new
  6028. // {
  6029. // Country = item.Country,
  6030. // CityData = cityData
  6031. // });
  6032. //}
  6033. sw.Stop();
  6034. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6035. }
  6036. catch (Exception ex)
  6037. {
  6038. return Ok(JsonView(false, ex.Message));
  6039. throw;
  6040. }
  6041. }
  6042. /// <summary>
  6043. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6044. /// </summary>
  6045. /// <returns></returns>
  6046. [HttpPost]
  6047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6048. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6049. {
  6050. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6051. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6052. List<string> countryData = new List<string>();
  6053. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6054. countryData = countryData.Distinct().ToList();
  6055. List<dynamic> dataSource = new List<dynamic>();
  6056. foreach (var item in countryData)
  6057. {
  6058. List<string> cityData1 = new List<string>();
  6059. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6060. var countryData2 = new
  6061. {
  6062. CountryName = item,
  6063. CityData = cityData1
  6064. };
  6065. dataSource.Add(countryData2);
  6066. }
  6067. return Ok(JsonView(true, "查询成功!", dataSource));
  6068. }
  6069. /// <summary>
  6070. /// 团组模块 - 出入境国家费用标准 Page List
  6071. /// </summary>
  6072. /// <returns></returns>
  6073. [HttpPost]
  6074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6075. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6076. {
  6077. int portId = dto.PortType;
  6078. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6079. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6080. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6081. string whereSql = string.Empty;
  6082. if (!string.IsNullOrEmpty(dto.Country))
  6083. {
  6084. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6085. }
  6086. if (!string.IsNullOrEmpty(dto.City))
  6087. {
  6088. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6089. }
  6090. string pageSql = string.Format(@"Select * From (
  6091. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6092. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6093. From Grp_NationalTravelFee gntf
  6094. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6095. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6096. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6097. RefAsync<int> total = 0;
  6098. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6099. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6100. }
  6101. /// <summary>
  6102. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6103. /// </summary>
  6104. /// <returns></returns>
  6105. [HttpPost]
  6106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6107. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6108. {
  6109. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6110. int portId = dto.PortType;
  6111. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6112. string whereSql = string.Empty;
  6113. if (!string.IsNullOrEmpty(dto.Country))
  6114. {
  6115. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6116. }
  6117. if (!string.IsNullOrEmpty(dto.City))
  6118. {
  6119. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6120. }
  6121. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6122. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6123. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6124. From Grp_NationalTravelFee gntf
  6125. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6126. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6127. Where gntf.Isdel = 0 {0} ", whereSql);
  6128. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6129. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6130. }
  6131. /// <summary>
  6132. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6133. /// </summary>
  6134. /// <returns></returns>
  6135. [HttpPost]
  6136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6137. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6138. {
  6139. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6140. if (data.Code != 0)
  6141. {
  6142. return Ok(JsonView(false, data.Msg));
  6143. }
  6144. return Ok(JsonView(true, "操作成功!", data.Data));
  6145. }
  6146. /// <summary>
  6147. /// 团组模块 - 出入境国家费用标准 - Del
  6148. /// </summary>
  6149. /// <returns></returns>
  6150. [HttpPost]
  6151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6152. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6153. {
  6154. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6155. {
  6156. Id = dto.Id,
  6157. DeleteUserId = dto.DeleteUserId,
  6158. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6159. IsDel = 1
  6160. };
  6161. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6162. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6163. .WhereColumns(it => new { it.Id })
  6164. .ExecuteCommandAsync();
  6165. if (delStatus <= 0)
  6166. {
  6167. return Ok(JsonView(false, "删除失败!"));
  6168. }
  6169. return Ok(JsonView(true, "操作成功!"));
  6170. }
  6171. /// <summary>
  6172. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6173. /// 注:Get 请求Headers 加 Token
  6174. /// </summary>
  6175. /// <param name="groupId"></param>
  6176. /// <returns></returns>
  6177. [HttpGet("{groupId}")]
  6178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6179. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6180. {
  6181. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6182. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6183. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6184. data.ForEach(x =>
  6185. {
  6186. x.CreateUserId = _currUserInfo.UserId;
  6187. });
  6188. if (data.Count > 0)
  6189. {
  6190. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6191. if (add > 0)
  6192. {
  6193. return Ok(JsonView(true, "操作成功!"));
  6194. }
  6195. }
  6196. return Ok(JsonView(false, "未操作!"));
  6197. }
  6198. #endregion
  6199. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6200. /// <summary>
  6201. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6202. /// </summary>
  6203. /// <returns></returns>
  6204. [HttpPost]
  6205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6206. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6207. {
  6208. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6209. //SetDataInfoView
  6210. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6211. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6212. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6213. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6214. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6215. //默认币种显示
  6216. var _currencyInfos = _currencyInit;
  6217. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6218. if (_currencyRate.Count > 0)
  6219. {
  6220. foreach (var item in _currencyInfos)
  6221. {
  6222. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6223. if (rateInfo != null)
  6224. {
  6225. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6226. rate1 *= 1.035M;
  6227. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6228. }
  6229. }
  6230. }
  6231. return Ok(JsonView(true, "查询成功!", new
  6232. {
  6233. WordTypeData = _WordTypeData,
  6234. ExcelTypeData = _ExcelTypeData,
  6235. CurrencyInit = _currencyInfos
  6236. }));
  6237. }
  6238. /// <summary>
  6239. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6240. /// </summary>
  6241. /// <returns></returns>
  6242. [HttpPost]
  6243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6244. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6245. {
  6246. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6247. RefAsync<int> total = 0;
  6248. int diId = 0;
  6249. var status = int.TryParse(dto.GroupName, out diId);
  6250. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6251. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6252. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6253. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6254. .Select(x => new
  6255. {
  6256. Id = x.Id,
  6257. GroupName = x.TeamName
  6258. })
  6259. .OrderByDescending(x => x.Id)
  6260. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6261. return Ok(JsonView(true, "查询成功!", data, total));
  6262. }
  6263. /// <summary>
  6264. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6265. /// </summary>
  6266. /// <returns></returns>
  6267. [HttpPost]
  6268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6269. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6270. {
  6271. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6272. RefAsync<int> total = 0;
  6273. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6274. .Where(x => x.IsDel == 0 && x.STid == 66)
  6275. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6276. .Select(x => new
  6277. {
  6278. id = x.Id,
  6279. name = x.Name,
  6280. remark = x.Remark,
  6281. })
  6282. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6283. return Ok(JsonView(true, "查询成功!", data, total));
  6284. }
  6285. /// <summary>
  6286. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  6287. /// </summary>
  6288. /// <returns></returns>
  6289. [HttpPost]
  6290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6291. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6292. {
  6293. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6294. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6295. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6296. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6297. var groupOtherRateData = groupRateData.TeamRates;
  6298. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6299. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6300. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6301. groupOtherRateData = groupOtherRateData
  6302. .Select(x => new TeamRateDescAddCurrencyIdView {
  6303. CurrencyId = x.CurrencyId,
  6304. CurrencyName = x.CurrencyName,
  6305. CurrencyCode = x.CurrencyCode,
  6306. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6307. }).ToList();
  6308. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  6309. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  6310. }
  6311. /// <summary>
  6312. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6313. /// </summary>
  6314. /// <returns></returns>
  6315. [HttpPost]
  6316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6317. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6318. {
  6319. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6320. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6321. var tipsData = new List<int>() {1,2,3 };
  6322. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6323. if (dto.TipsType == 1)
  6324. {
  6325. //默认币种显示
  6326. var _currencyInfos = _currencyInit;
  6327. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6328. List<dynamic> reteInfos = new List<dynamic>();
  6329. if (_currencyRate.Count > 0)
  6330. {
  6331. foreach (var item in _currencyInfos)
  6332. {
  6333. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6334. if (rateInfo != null)
  6335. {
  6336. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6337. decimal rate1 = item.Rate;
  6338. rate1 *= 1.03M;
  6339. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6340. reteInfos.Add(new
  6341. {
  6342. currCode = item.CurrencyCode,
  6343. currName = item.CurrencyName,
  6344. rate = rate2,
  6345. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6346. });
  6347. }
  6348. }
  6349. }
  6350. return Ok(JsonView(true, "查询成功!", reteInfos));
  6351. }
  6352. else if (dto.TipsType == 2)
  6353. {
  6354. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6355. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6356. }
  6357. else if (dto.TipsType == 3)
  6358. {
  6359. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6360. return Ok(JsonView(true, "查询成功!", airData.Data));
  6361. }
  6362. return Ok(JsonView(false));
  6363. }
  6364. /// <summary>
  6365. /// 团组模块 - 出入境国家费用标准-移动端 List
  6366. /// </summary>
  6367. /// <returns></returns>
  6368. [HttpPost]
  6369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6370. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6371. {
  6372. Stopwatch sw = new Stopwatch();
  6373. sw.Start();
  6374. RefAsync<int> total = 0;
  6375. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6376. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6377. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6378. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6379. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6380. .Select((ntf, sd, u) => new
  6381. {
  6382. Id = ntf.Id,
  6383. Area = $"{ntf.Country}-{ntf.City}",
  6384. Currency = ntf.Currency,
  6385. CurrencyCode = sd.Name,
  6386. CurrencyName = sd.Remark,
  6387. RoomCost = ntf.RoomCost,
  6388. FoodCost = ntf.FoodCost,
  6389. PublicCost = ntf.PublicCost,
  6390. LastUpdateUserId = ntf.LastUpdateUserId,
  6391. LastUpdateUserName = u.CnName,
  6392. LastUpdateTime = ntf.LastUpdateTime,
  6393. })
  6394. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6395. sw.Stop();
  6396. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6397. }
  6398. /// <summary>
  6399. /// 团组模块 - 出入境费用-移动端 - Info
  6400. /// </summary>
  6401. /// <returns></returns>
  6402. [HttpPost]
  6403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6404. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6405. {
  6406. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6407. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6408. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6409. return Ok(data);
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6417. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6418. {
  6419. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6420. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6421. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6422. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6423. if (eecInfo == null) return Ok(mobileInfo);
  6424. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6425. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6426. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6427. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6428. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6429. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6430. {
  6431. SubId = dac.Id,
  6432. DiId = dac.DiId,
  6433. Type = dac.Type,
  6434. Days = dac.Days,
  6435. NationalTravelFeeId = dac.NationalTravelFeeId,
  6436. Arae = $"{ntf.Country}-{ntf.City}",
  6437. Cost = dac.Cost,
  6438. Currency = dac.Currency,
  6439. CurrencyName = sd.Name,
  6440. SubTotal = dac.SubTotal,
  6441. })
  6442. .ToList();
  6443. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6444. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6445. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6446. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6447. mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  6448. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6449. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6450. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6451. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6452. //其他款项
  6453. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6454. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6455. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6456. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6457. .OrderBy((dop, sd1, sd2) => dop.Index)
  6458. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6459. {
  6460. SubId = dop.Id,
  6461. DiId = dop.Diid,
  6462. Index = dop.Index,
  6463. SetDataId = dop.SetDataId,
  6464. SetDataName = sd1.Name,
  6465. Cost = dop.Cost,
  6466. Currency = dop.Currency,
  6467. CurrencyName = sd2.Remark,
  6468. SubTotal = dop.SubTotal,
  6469. Remark = dop.Remark,
  6470. })
  6471. .ToArray();
  6472. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6473. return Ok(mobileInfo);
  6474. }
  6475. /// <summary>
  6476. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6477. /// </summary>
  6478. /// <returns></returns>
  6479. [HttpPost]
  6480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6481. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6482. {
  6483. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6484. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6485. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6486. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6487. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6488. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6489. var subType = dto.SubType;
  6490. if (subType == 1) //1:境内费用
  6491. {
  6492. var oneData = new ChoiceOneMobileSubInfoView()
  6493. {
  6494. Id = eecInfo.Id,
  6495. ChoiceOne = eecInfo.ChoiceOne,
  6496. ChoiceOneTotalCost = eecInfo.InsidePay,
  6497. Visa = eecInfo.Visa,
  6498. VisaRemark = eecInfo.VisaRemark,
  6499. YiMiao = eecInfo.YiMiao,
  6500. HeSuan = eecInfo.HeSuan,
  6501. Service = eecInfo.Service,
  6502. Ticket = eecInfo.Ticket,
  6503. Safe = eecInfo.Safe,
  6504. };
  6505. return Ok(JsonView(oneData));
  6506. }
  6507. else if (subType == 2) //2:国际旅费
  6508. {
  6509. var twoData = new ChoiceTwoMobileSubInfoView() {
  6510. Id = eecInfo.Id,
  6511. ChoiceTwoJJ = eecInfo.SumJJC,
  6512. OutsideJJPay = eecInfo.OutsideJJPay,
  6513. ChoiceTwoGW = eecInfo.SumGWC,
  6514. OutsideGWPay = eecInfo.OutsideGWPay,
  6515. ChoiceTwoTD = eecInfo.SumTDC,
  6516. OutsideTDPay = eecInfo.OutsideTDPay,
  6517. AirJJ = eecInfo.AirJJ,
  6518. AirGW = eecInfo.AirGW,
  6519. AirTD = eecInfo.AirTD,
  6520. CityTranffic = eecInfo.CityTranffic
  6521. };
  6522. return Ok(JsonView(twoData));
  6523. }
  6524. else if (subType == 3) //3:住宿费
  6525. {
  6526. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6527. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6528. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6529. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6530. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6531. {
  6532. SubId = dac.Id,
  6533. DiId = dac.DiId,
  6534. Type = dac.Type,
  6535. Days = dac.Days,
  6536. NationalTravelFeeId = dac.NationalTravelFeeId,
  6537. Arae = $"{ntf.Country}-{ntf.City}",
  6538. Cost = dac.Cost,
  6539. Currency = dac.Currency,
  6540. CurrencyName = sd.Name,
  6541. SubTotal = dac.SubTotal,
  6542. })
  6543. .ToArray();
  6544. var data = new ChoiceMobileSubInfo3To6View() {
  6545. ParentId = eecInfo.Id,
  6546. Choice = eecInfo.ChoiceThree,
  6547. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6548. Details = dayAndCostDatas
  6549. };
  6550. return Ok(JsonView(data));
  6551. }
  6552. else if (subType == 4) //4:伙食费
  6553. {
  6554. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6555. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6556. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6557. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6558. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6559. {
  6560. SubId = dac.Id,
  6561. DiId = dac.DiId,
  6562. Type = dac.Type,
  6563. Days = dac.Days,
  6564. NationalTravelFeeId = dac.NationalTravelFeeId,
  6565. Arae = $"{ntf.Country}-{ntf.City}",
  6566. Cost = dac.Cost,
  6567. Currency = dac.Currency,
  6568. CurrencyName = sd.Name,
  6569. SubTotal = dac.SubTotal,
  6570. })
  6571. .ToArray();
  6572. var data = new ChoiceMobileSubInfo3To6View()
  6573. {
  6574. ParentId = eecInfo.Id,
  6575. Choice = eecInfo.ChoiceFour,
  6576. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6577. Details = dayAndCostDatas
  6578. };
  6579. return Ok(JsonView(data));
  6580. }
  6581. else if (subType == 5) //5:公杂费
  6582. {
  6583. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6584. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6585. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6586. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6587. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6588. {
  6589. SubId = dac.Id,
  6590. DiId = dac.DiId,
  6591. Type = dac.Type,
  6592. Days = dac.Days,
  6593. NationalTravelFeeId = dac.NationalTravelFeeId,
  6594. Arae = $"{ntf.Country}-{ntf.City}",
  6595. Cost = dac.Cost,
  6596. Currency = dac.Currency,
  6597. CurrencyName = sd.Name,
  6598. SubTotal = dac.SubTotal,
  6599. })
  6600. .ToArray();
  6601. var data = new ChoiceMobileSubInfo3To6View()
  6602. {
  6603. ParentId = eecInfo.Id,
  6604. Choice = eecInfo.ChoiceFive,
  6605. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6606. Details = dayAndCostDatas
  6607. };
  6608. return Ok(JsonView(data));
  6609. }
  6610. else if (subType == 6) //6:培训费
  6611. {
  6612. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6613. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6614. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6615. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6616. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6617. {
  6618. SubId = dac.Id,
  6619. DiId = dac.DiId,
  6620. Type = dac.Type,
  6621. Days = dac.Days,
  6622. NationalTravelFeeId = dac.NationalTravelFeeId,
  6623. Arae = $"{ntf.Country}-{ntf.City}",
  6624. Cost = dac.Cost,
  6625. Currency = dac.Currency,
  6626. CurrencyName = sd.Name,
  6627. SubTotal = dac.SubTotal,
  6628. })
  6629. .ToArray();
  6630. var data = new ChoiceMobileSubInfo3To6View()
  6631. {
  6632. ParentId = eecInfo.Id,
  6633. Choice = eecInfo.ChoiceSix,
  6634. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6635. Details = dayAndCostDatas
  6636. };
  6637. return Ok(JsonView(data));
  6638. }
  6639. else if (subType == 7) //7:其他
  6640. {
  6641. //其他款项
  6642. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6643. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6644. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6645. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6646. .OrderBy((dop, sd1, sd2) => dop.Index)
  6647. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6648. {
  6649. SubId = dop.Id,
  6650. DiId = dop.Diid,
  6651. Index = dop.Index,
  6652. SetDataId = dop.SetDataId,
  6653. SetDataName = sd1.Name,
  6654. Cost = dop.Cost,
  6655. Currency = dop.Currency,
  6656. CurrencyName = sd2.Name,
  6657. SubTotal = dop.SubTotal,
  6658. Remark = dop.Remark,
  6659. })
  6660. .ToArray();
  6661. var data = new ChoiceSevenMobileSubInfoView()
  6662. {
  6663. ParentId = eecInfo.Id,
  6664. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6665. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6666. Details = otherData
  6667. };
  6668. return Ok(JsonView(data));
  6669. }
  6670. return Ok(JsonView(false));
  6671. }
  6672. #region op
  6673. /// <summary>
  6674. /// 移动端更新费用消息通知
  6675. /// </summary>
  6676. /// <param name="diid"></param>
  6677. /// <param name="id"></param>
  6678. /// <param name="currUserId"></param>
  6679. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6680. {
  6681. try
  6682. {
  6683. ////生成默认文件pdf并且通知人员
  6684. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6685. //{
  6686. // DiId = diid,
  6687. // ExportType = 1,
  6688. // SubTypeId = 1005
  6689. //}, "pdf");
  6690. ////发送通知
  6691. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6692. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6693. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6694. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6695. ////汇率信息记录
  6696. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6697. }
  6698. catch (Exception ex)
  6699. {
  6700. //记录日志
  6701. throw;
  6702. }
  6703. }
  6704. /// <summary>
  6705. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6706. /// </summary>
  6707. /// <returns></returns>
  6708. [HttpPost]
  6709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6710. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6711. {
  6712. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6713. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6714. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6715. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6716. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6717. int id = dto.Id;
  6718. if (id <= 0) //add
  6719. {
  6720. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6721. if (add < 1) return Ok(JsonView(false));
  6722. id = add;
  6723. }
  6724. else //update
  6725. {
  6726. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6727. if (upd < 1) return Ok(JsonView(false));
  6728. }
  6729. #region 汇率变更时更改币种相关费用
  6730. var opDayCosts = new List<Grp_DayAndCost>();
  6731. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6732. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6733. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6734. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6735. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6736. .Select((dac, sd) => new {
  6737. dac.Id,
  6738. dac.DiId,
  6739. CurrencyCode = sd.Name,
  6740. dac.Cost
  6741. })
  6742. .ToList();
  6743. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6744. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6745. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6746. .Select((dop, sd) => new {
  6747. dop.Id,
  6748. dop.Diid,
  6749. CurrencyCode = sd.Name,
  6750. dop.Cost
  6751. })
  6752. .ToList();
  6753. if (dayCosts.Count > 0)
  6754. {
  6755. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6756. foreach (var dc in new_dayCosts)
  6757. {
  6758. var thisCurrency = dc.Key.ToUpper();
  6759. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6760. if (thisRate == 0.00M) continue;
  6761. foreach (var dcSub in dc)
  6762. {
  6763. opDayCosts.Add(new Grp_DayAndCost() {
  6764. Id = dcSub.Id,
  6765. DiId = dcSub.DiId,
  6766. Cost = dcSub.Cost,
  6767. SubTotal = dcSub.Cost * thisRate,
  6768. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6769. });
  6770. }
  6771. }
  6772. if (opDayCosts.Count > 0)
  6773. {
  6774. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6775. }
  6776. }
  6777. if (dayOtherCosts.Count > 0)
  6778. {
  6779. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6780. foreach (var dc in new_dayOtherCosts)
  6781. {
  6782. var thisCurrency = dc.Key.ToUpper();
  6783. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6784. if (thisRate == 0.00M) continue;
  6785. foreach (var dcSub in dc)
  6786. {
  6787. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6788. {
  6789. Id = dcSub.Id,
  6790. Diid = dcSub.Diid,
  6791. Cost = dcSub.Cost,
  6792. SubTotal = dcSub.Cost * thisRate,
  6793. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6794. });
  6795. }
  6796. }
  6797. if (opDayOtherCosts.Count > 0)
  6798. {
  6799. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6800. }
  6801. }
  6802. #endregion
  6803. //消息通知
  6804. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6805. //汇率信息记录
  6806. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  6807. return Ok(JsonView(true));
  6808. }
  6809. /// <summary>
  6810. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6811. /// </summary>
  6812. /// <returns></returns>
  6813. [HttpPost]
  6814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6815. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6816. {
  6817. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6818. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6819. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6820. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6821. int id = dto.Id;
  6822. if (id <= 0) //add
  6823. {
  6824. checkboxInfo.CreateUserId = dto.CurrUserId;
  6825. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6826. if (add < 1) return Ok(JsonView(false));
  6827. }
  6828. else //update
  6829. {
  6830. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6831. .UpdateColumns(x => new {
  6832. x.ChoiceOne,
  6833. x.ChoiceTwo,
  6834. x.SumJJC,
  6835. x.SumGWC,
  6836. x.SumTDC,
  6837. x.ChoiceThree,
  6838. x.ChoiceFour,
  6839. x.ChoiceFive,
  6840. x.ChoiceSix,
  6841. x.OtherExpenses_Checked
  6842. })
  6843. .Where(x => x.Id == id)
  6844. .ExecuteCommandAsync();
  6845. if (upd < 1) return Ok(JsonView(false));
  6846. }
  6847. return Ok(JsonView(true));
  6848. }
  6849. /// <summary>
  6850. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  6851. /// </summary>
  6852. /// <returns></returns>
  6853. [HttpPost]
  6854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6855. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  6856. {
  6857. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  6858. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  6859. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6860. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6861. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6862. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  6863. var checkboxInfo = new Grp_EnterExitCost() {
  6864. Id = id,
  6865. DiId = diId,
  6866. CreateUserId = currUserId
  6867. };
  6868. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  6869. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  6870. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  6871. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  6872. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  6873. if (id <= 0) //add
  6874. {
  6875. checkboxInfo.CreateUserId = dto.CurrUserId;
  6876. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6877. if (add < 1) return Ok(JsonView(false));
  6878. }
  6879. else //update
  6880. {
  6881. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  6882. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  6883. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  6884. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  6885. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  6886. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  6887. .Where(x => x.Id == id)
  6888. .ExecuteCommandAsync();
  6889. if (upd < 1) return Ok(JsonView(false));
  6890. }
  6891. return Ok(JsonView(true));
  6892. }
  6893. /// <summary>
  6894. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6895. /// </summary>
  6896. /// <returns></returns>
  6897. [HttpPost]
  6898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6899. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6900. {
  6901. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6902. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6903. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6904. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6905. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6906. int id = dto.Id;
  6907. if (id <= 0) //add
  6908. {
  6909. info.CreateUserId = dto.CurrUserId;
  6910. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  6911. if (add < 1) return Ok(JsonView(false));
  6912. id = add;
  6913. }
  6914. else //update
  6915. {
  6916. var upd = await _sqlSugar.Updateable(info)
  6917. .UpdateColumns(x => new {
  6918. x.ChoiceOne,
  6919. x.InsidePay,
  6920. x.VisaRemark,
  6921. x.Visa,
  6922. x.Service,
  6923. x.Safe,
  6924. x.Ticket,
  6925. x.HeSuan,
  6926. x.YiMiao,
  6927. })
  6928. .Where(x => x.Id == id)
  6929. .ExecuteCommandAsync();
  6930. if (upd < 1) return Ok(JsonView(false));
  6931. }
  6932. //消息通知
  6933. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6934. return Ok(JsonView(new { itemTotal = info.InsidePay }));
  6935. }
  6936. /// <summary>
  6937. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  6938. /// </summary>
  6939. /// <returns></returns>
  6940. [HttpPost]
  6941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6942. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  6943. {
  6944. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6945. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6946. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6947. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6948. info.AirJJC_Checked = dto.ChoiceTwoJJ;
  6949. info.AirGWC_Checked = dto.ChoiceTwoGW;
  6950. info.AirTDC_Checked = dto.ChoiceTwoTD;
  6951. int id = dto.Id;
  6952. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  6953. if (id <= 0) //add
  6954. {
  6955. info.CreateUserId = dto.CurrUserId;
  6956. var addInfo = await _sqlSugar.Insertable(info).ExecuteReturnEntityAsync();
  6957. if (addInfo == null) return Ok(JsonView(false));
  6958. id = addInfo.Id;
  6959. }
  6960. else //update
  6961. {
  6962. var upd = await _sqlSugar.Updateable(info)
  6963. .UpdateColumns(x => new {
  6964. x.AirJJC_Checked,
  6965. x.OutsideJJPay,
  6966. x.AirGWC_Checked,
  6967. x.OutsideGWPay,
  6968. x.AirTDC_Checked,
  6969. x.OutsideTDPay,
  6970. x.AirJJ,
  6971. x.AirGW,
  6972. x.AirTD,
  6973. x.CityTranffic
  6974. })
  6975. .Where(x => x.Id == id)
  6976. .ExecuteCommandAsync();
  6977. if (upd <1) return Ok(JsonView(false));
  6978. }
  6979. jjcItemTotal = info.AirJJ + info.CityTranffic;
  6980. gwcItemTotal = info.AirGW + info.CityTranffic;
  6981. tdcItemTotal = info.AirTD + info.CityTranffic;
  6982. //消息通知
  6983. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6984. return Ok(JsonView(new
  6985. {
  6986. choiceTwoJJ = dto.ChoiceTwoJJ,
  6987. jjcItemTotal = jjcItemTotal,
  6988. choiceTwoGW = dto.ChoiceTwoGW,
  6989. gwcItemTotal = gwcItemTotal,
  6990. choiceTwoTD = dto.ChoiceTwoTD,
  6991. tdcItemTotal = tdcItemTotal
  6992. }));
  6993. }
  6994. /// <summary>
  6995. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  6996. /// </summary>
  6997. /// <returns></returns>
  6998. [HttpPost]
  6999. [ApiExplorerSettings(IgnoreApi = true)]
  7000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7001. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  7002. {
  7003. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7004. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7005. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7006. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  7007. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7008. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7009. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  7010. var infos = infos1.Select(x => new Grp_DayAndCost
  7011. {
  7012. Id = x.Id,
  7013. DiId = dto.DiId,
  7014. Type = dto.FeeType,
  7015. Days = x.Days,
  7016. NationalTravelFeeId = x.NationalTravelFeeId,
  7017. Cost = x.Cost,
  7018. Currency = x.Currency,
  7019. SubTotal = x.SubTotal,
  7020. CreateUserId = dto.CurrUserId
  7021. })
  7022. .ToList();
  7023. var adds = infos.Where(x => x.Id <= 0).ToList();
  7024. var upds = infos.Where(x => x.Id > 0).ToList();
  7025. if (adds.Count > 0)
  7026. {
  7027. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7028. if (add < 1) return Ok(JsonView(false));
  7029. }
  7030. if (upds.Count > 0)
  7031. {
  7032. var upd = await _sqlSugar.Updateable(adds)
  7033. .UpdateColumns(x => new
  7034. {
  7035. x.Days,
  7036. x.NationalTravelFeeId,
  7037. x.Cost,
  7038. x.Currency,
  7039. x.SubTotal
  7040. })
  7041. .WhereColumns(x => new { x.Id })
  7042. .ExecuteCommandAsync();
  7043. if (upd < 1) return Ok(JsonView(false));
  7044. }
  7045. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7046. //消息通知
  7047. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7048. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7049. return Ok(JsonView(new { itemTotal = itemTotal }));
  7050. }
  7051. /// <summary>
  7052. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7053. /// </summary>
  7054. /// <returns></returns>
  7055. [HttpPost]
  7056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7057. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7058. {
  7059. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  7060. int subId = dto.SubId, feeType = dto.FeeType;
  7061. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7062. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7063. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7064. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7065. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7066. subInfo.Id = subId;
  7067. subInfo.DiId = dto.DiId;
  7068. if (feeType == 3) subInfo.Type = 1;
  7069. else if (feeType == 4) subInfo.Type = 1;
  7070. else if (feeType == 5) subInfo.Type = 1;
  7071. else if (feeType == 6) subInfo.Type = 1;
  7072. subInfo.CreateUserId = dto.CurrUserId;
  7073. //子表op
  7074. if (subId < 1)
  7075. {
  7076. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7077. if (subAdd < 1) return Ok(JsonView(false));
  7078. }
  7079. else
  7080. {
  7081. var subUpd = await _sqlSugar.Updateable(subInfo)
  7082. .UpdateColumns(x => new
  7083. {
  7084. x.Days,
  7085. x.NationalTravelFeeId,
  7086. x.Cost,
  7087. x.Currency,
  7088. x.SubTotal
  7089. })
  7090. .WhereColumns(x => new { x.Id })
  7091. .ExecuteCommandAsync();
  7092. if (subUpd < 1) return Ok(JsonView(false));
  7093. }
  7094. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  7095. //消息通知
  7096. var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First().Id;
  7097. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7098. return Ok(JsonView(new { itemTotal = itemTotal }));
  7099. }
  7100. /// <summary>
  7101. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7102. /// </summary>
  7103. /// <returns></returns>
  7104. [HttpPost]
  7105. [ApiExplorerSettings(IgnoreApi = true)]
  7106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7107. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7108. {
  7109. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7110. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7111. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7112. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7113. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7114. {
  7115. Id = x.Id,
  7116. Diid = dto.DiId,
  7117. SetDataId = x.SetDataId,
  7118. Index = x.Index,
  7119. Cost = x.Cost,
  7120. Currency = x.Currency,
  7121. SubTotal = x.SubTotal,
  7122. CreateUserId = dto.CurrUserId,
  7123. Remark = x.Remark
  7124. }).ToList();
  7125. var adds = infos.Where(x => x.Id <= 0).ToList();
  7126. var upds = infos.Where(x => x.Id > 0).ToList();
  7127. if (adds.Count > 0)
  7128. {
  7129. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7130. if (add < 1) return Ok(JsonView(false));
  7131. }
  7132. if (upds.Count > 0)
  7133. {
  7134. var upd = await _sqlSugar.Updateable(adds)
  7135. .UpdateColumns(x => new
  7136. {
  7137. x.Index,
  7138. x.SetDataId,
  7139. x.Cost,
  7140. x.Currency,
  7141. x.SubTotal,
  7142. x.Remark
  7143. })
  7144. .WhereColumns(x => new { x.Id })
  7145. .ExecuteCommandAsync();
  7146. if (upd < 1) return Ok(JsonView(false));
  7147. }
  7148. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7149. //消息通知
  7150. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7151. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7152. return Ok(JsonView(new { itemTotal = itemTotal }));
  7153. }
  7154. /// <summary>
  7155. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  7156. /// </summary>
  7157. /// <returns></returns>
  7158. [HttpPost]
  7159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7160. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7161. {
  7162. int subId = dto.SubId;
  7163. int diId = dto.Diid;
  7164. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7165. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7166. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7167. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7168. subInfo.Id = subId;
  7169. subInfo.Diid = dto.Diid;
  7170. subInfo.CreateUserId = dto.CurrUserId;
  7171. #region 子表op
  7172. if (subId < 1)//add
  7173. {
  7174. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7175. if (subAdd < 1) return Ok(JsonView(false));
  7176. }
  7177. else //upd
  7178. {
  7179. var subUpd = await _sqlSugar.Updateable(subInfo)
  7180. .UpdateColumns(x => new
  7181. {
  7182. x.Index,
  7183. x.SetDataId,
  7184. x.Cost,
  7185. x.Currency,
  7186. x.SubTotal,
  7187. x.Remark
  7188. })
  7189. .WhereColumns(x => new { x.Id })
  7190. .ExecuteCommandAsync();
  7191. if (subUpd < 1) return Ok(JsonView(false));
  7192. }
  7193. #endregion
  7194. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  7195. //消息通知
  7196. var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).First().Id;
  7197. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  7198. return Ok(JsonView(new { itemTotal = itemTotal }));
  7199. }
  7200. /// <summary>
  7201. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  7202. /// </summary>
  7203. /// <returns></returns>
  7204. [HttpPost]
  7205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7206. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  7207. {
  7208. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7209. if (data.Code != 0)
  7210. {
  7211. return Ok(JsonView(false, data.Msg));
  7212. }
  7213. return Ok(JsonView(true, "操作成功!", data.Data));
  7214. }
  7215. /// <summary>
  7216. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  7217. /// </summary>
  7218. /// <param name="dto"></param>
  7219. /// <returns></returns>
  7220. [HttpPost]
  7221. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  7222. {
  7223. var data = new Grp_DayOtherPrice()
  7224. {
  7225. Id = dto.Id,
  7226. IsDel = 1,
  7227. DeleteUserId = dto.DeleteUserId,
  7228. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7229. };
  7230. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7231. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  7232. return Ok(JsonView(false,"删除失败!"));
  7233. }
  7234. #endregion
  7235. #endregion
  7236. #region 签证费用录入
  7237. /// <summary>
  7238. /// 根据diid查询签证费用列表
  7239. /// </summary>
  7240. /// <param name="dto"></param>
  7241. /// <returns></returns>
  7242. [HttpPost]
  7243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7244. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7245. {
  7246. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7247. if (groupData.Code != 0)
  7248. {
  7249. return Ok(JsonView(false, groupData.Msg));
  7250. }
  7251. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7252. }
  7253. /// <summary>
  7254. /// 根据签证费用Id查询单条数据及c表数据
  7255. /// </summary>
  7256. /// <param name="dto"></param>
  7257. /// <returns></returns>
  7258. [HttpPost]
  7259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7260. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7261. {
  7262. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7263. if (groupData.Code != 0)
  7264. {
  7265. return Ok(JsonView(false, groupData.Msg));
  7266. }
  7267. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7268. }
  7269. /// <summary>
  7270. /// 签证费用删除
  7271. /// </summary>
  7272. /// <param name="dto"></param>
  7273. /// <returns></returns>
  7274. [HttpPost]
  7275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7276. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7277. {
  7278. _sqlSugar.BeginTran();
  7279. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7280. if (!res)
  7281. {
  7282. _sqlSugar.RollbackTran();
  7283. return Ok(JsonView(false, "删除失败"));
  7284. }
  7285. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7286. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7287. .SetColumns(a => new Grp_CreditCardPayment()
  7288. {
  7289. IsDel = 1,
  7290. DeleteUserId = dto.DeleteUserId,
  7291. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7292. })
  7293. .ExecuteCommand();
  7294. if (resSub < 1)
  7295. {
  7296. _sqlSugar.RollbackTran();
  7297. return Ok(JsonView(false, "删除失败"));
  7298. }
  7299. _sqlSugar.CommitTran();
  7300. return Ok(JsonView(true, "删除成功!"));
  7301. }
  7302. /// <summary>
  7303. /// 签证费用录入下拉框初始化
  7304. /// </summary>
  7305. /// <returns></returns>
  7306. [HttpPost]
  7307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7308. public async Task<IActionResult> VisaPriceAddSelect()
  7309. {
  7310. //支付方式
  7311. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7312. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7313. //币种
  7314. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7315. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7316. //乘客类型
  7317. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7318. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7319. //卡类型
  7320. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7321. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7322. //代办费类型
  7323. var agencyFeeTypeData = new List<dynamic>() {
  7324. new { id = 0 , Text = "未选择" },
  7325. new { id = 1 , Text = "小公务" },
  7326. new { id = 2 , Text = "大公务" },
  7327. };
  7328. //签证费用标准国家Data
  7329. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7330. var data = new
  7331. {
  7332. Payment = _Payment,
  7333. CurrencyList = _CurrencyList,
  7334. PassengerType = _PassengerType,
  7335. BankCard = _BankCard,
  7336. AgencyFeeType = agencyFeeTypeData,
  7337. CountryFeeData = visaCountryFeeData
  7338. };
  7339. return Ok(JsonView(true, "查询成功!", data));
  7340. }
  7341. /// <summary>
  7342. /// 签证费用录入操作(Status:1.新增,2.修改)
  7343. /// </summary>
  7344. /// <param name="dto"></param>
  7345. /// <returns></returns>
  7346. [HttpPost]
  7347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7348. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7349. {
  7350. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7351. if (groupData.Code != 0)
  7352. {
  7353. return Ok(JsonView(false, groupData.Msg));
  7354. }
  7355. #region 应用推送
  7356. try
  7357. {
  7358. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7359. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7360. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7361. //2024-10-21 新增LZ UID
  7362. var userIds = new List<int>() { 21 };
  7363. string title = $"系统通知";
  7364. string content = "";
  7365. var diId = dto.DiId;
  7366. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7367. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7368. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7369. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7370. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7371. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7372. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7373. }
  7374. catch (Exception ex)
  7375. {
  7376. }
  7377. #endregion
  7378. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7379. }
  7380. #endregion
  7381. #region 签证提成录入
  7382. /// <summary>
  7383. /// 签证提成录入
  7384. /// 基础数据
  7385. /// </summary>
  7386. /// <param name="_dto"></param>
  7387. /// <returns></returns>
  7388. [HttpGet]
  7389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7390. public async Task<IActionResult> VisaCommissionInit()
  7391. {
  7392. return Ok(await _visaCommissionRep.Init());
  7393. }
  7394. /// <summary>
  7395. /// 签证提成录入
  7396. /// Item
  7397. /// </summary>
  7398. /// <param name="_dto"></param>
  7399. /// <returns></returns>
  7400. [HttpPost]
  7401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7402. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7403. {
  7404. var validator = new VisaCommissionItemDtoValidator();
  7405. var validatorRes = await validator.ValidateAsync(_dto);
  7406. if (!validatorRes.IsValid)
  7407. {
  7408. StringBuilder sb = new StringBuilder();
  7409. foreach (var item in validatorRes.Errors)
  7410. {
  7411. sb.AppendLine(item.ErrorMessage);
  7412. }
  7413. return Ok(JsonView(false, sb.ToString()));
  7414. }
  7415. return Ok(await _visaCommissionRep.Item(_dto));
  7416. }
  7417. /// <summary>
  7418. /// 签证提成录入
  7419. /// Save
  7420. /// </summary>
  7421. /// <param name="_dto"></param>
  7422. /// <returns></returns>
  7423. [HttpPost]
  7424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7425. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7426. {
  7427. //参数验证
  7428. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7429. foreach (var item in _dto.Items)
  7430. {
  7431. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7432. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7433. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7434. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7435. }
  7436. return Ok(await _visaCommissionRep.Save(_dto));
  7437. }
  7438. /// <summary>
  7439. /// 签证提成录入
  7440. /// Create
  7441. /// </summary>
  7442. /// <param name="_dto"></param>
  7443. /// <returns></returns>
  7444. [HttpPost]
  7445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7446. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7447. {
  7448. var validator = new VisaCommissionCreateDtoValidator();
  7449. var validatorRes = await validator.ValidateAsync(_dto);
  7450. if (!validatorRes.IsValid)
  7451. {
  7452. StringBuilder sb = new StringBuilder();
  7453. foreach (var item in validatorRes.Errors)
  7454. {
  7455. sb.AppendLine(item.ErrorMessage);
  7456. }
  7457. return Ok(JsonView(false, sb.ToString()));
  7458. }
  7459. return Ok(await _visaCommissionRep.Create(_dto));
  7460. }
  7461. /// <summary>
  7462. /// 签证提成录入
  7463. /// Put(编辑)
  7464. /// </summary>
  7465. /// <param name="id"></param>
  7466. /// <param name="_dto"></param>
  7467. /// <returns></returns>
  7468. [HttpPut]
  7469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7470. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7471. {
  7472. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7473. var validator = new VisaCommissionCreateDtoValidator();
  7474. var validatorRes = await validator.ValidateAsync(_dto);
  7475. if (!validatorRes.IsValid)
  7476. {
  7477. StringBuilder sb = new StringBuilder();
  7478. foreach (var item in validatorRes.Errors)
  7479. {
  7480. sb.AppendLine(item.ErrorMessage);
  7481. }
  7482. return Ok(JsonView(false, sb.ToString()));
  7483. }
  7484. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7485. }
  7486. /// <summary>
  7487. /// 签证提成录入
  7488. /// Del
  7489. /// </summary>
  7490. /// <param name="id"></param>
  7491. /// <param name="currUserId"></param>
  7492. /// <returns></returns>
  7493. [HttpPost]
  7494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7495. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7496. {
  7497. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7498. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7499. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7500. }
  7501. #endregion
  7502. #region op费用录入
  7503. /// <summary>
  7504. /// 根据diid查询op费用列表
  7505. /// </summary>
  7506. /// <param name="dto"></param>
  7507. /// <returns></returns>
  7508. [HttpPost]
  7509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7510. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7511. {
  7512. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7513. if (groupData.Code != 0)
  7514. {
  7515. return Ok(JsonView(false, groupData.Msg));
  7516. }
  7517. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7518. }
  7519. /// <summary>
  7520. /// 根据op费用Id查询单条数据及c表数据
  7521. /// </summary>
  7522. /// <param name="dto"></param>
  7523. /// <returns></returns>
  7524. [HttpPost]
  7525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7526. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7527. {
  7528. try
  7529. {
  7530. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7531. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7532. var data = new
  7533. {
  7534. CarTouristGuideGround = _groupData,
  7535. CreditCardPayment = _creditCardPayment
  7536. };
  7537. return Ok(JsonView(true, "查询成功!", data));
  7538. }
  7539. catch (Exception ex)
  7540. {
  7541. return Ok(JsonView(false, "程序错误!"));
  7542. }
  7543. }
  7544. /// <summary>
  7545. /// op费用删除
  7546. /// </summary>
  7547. /// <param name="dto"></param>
  7548. /// <returns></returns>
  7549. [HttpPost]
  7550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7551. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7552. {
  7553. try
  7554. {
  7555. _sqlSugar.BeginTran();
  7556. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7557. if (!res)
  7558. {
  7559. return Ok(JsonView(false, "删除失败"));
  7560. }
  7561. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7562. {
  7563. IsDel = 1,
  7564. DeleteUserId = dto.DeleteUserId,
  7565. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7566. }).ExecuteCommandAsync();
  7567. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7568. {
  7569. IsDel = 1,
  7570. DeleteUserId = dto.DeleteUserId,
  7571. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7572. }).ExecuteCommandAsync();
  7573. #region 删除超支相关数据
  7574. //删除导入的超支数据
  7575. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7576. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7577. {
  7578. IsDel = 1,
  7579. DeleteUserId = dto.DeleteUserId,
  7580. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7581. }).ExecuteCommand();
  7582. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7583. {
  7584. IsDel = 1,
  7585. DeleteUserId = dto.DeleteUserId,
  7586. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7587. }).ExecuteCommand();
  7588. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7589. {
  7590. IsDel = 1,
  7591. DeleteUserId = dto.DeleteUserId,
  7592. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7593. }).ExecuteCommand();
  7594. #endregion
  7595. _sqlSugar.CommitTran();
  7596. return Ok(JsonView(true, "删除成功!"));
  7597. }
  7598. catch (Exception ex)
  7599. {
  7600. _sqlSugar.RollbackTran();
  7601. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7602. }
  7603. }
  7604. /// <summary>
  7605. /// op费用录入操作(Status:1.新增,2.修改)
  7606. /// </summary>
  7607. /// <param name="dto"></param>
  7608. /// <returns></returns>
  7609. [HttpPost]
  7610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7611. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7612. {
  7613. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7614. if (groupData.Code != 0)
  7615. {
  7616. return Ok(JsonView(false, groupData.Msg));
  7617. }
  7618. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7619. }
  7620. /// <summary>
  7621. /// 填写费用详细页面初始化绑定
  7622. /// </summary>
  7623. /// <param name="dto"></param>
  7624. /// <returns></returns>
  7625. [HttpPost]
  7626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7627. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7628. {
  7629. try
  7630. {
  7631. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7632. if (groupData.Code != 0)
  7633. {
  7634. return Ok(JsonView(false, groupData.Msg));
  7635. }
  7636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7637. }
  7638. catch (Exception ex)
  7639. {
  7640. return Ok(JsonView(false, ex.Message));
  7641. }
  7642. }
  7643. /// <summary>
  7644. /// 根据op费用Id查询详细数据
  7645. /// </summary>
  7646. /// <param name="dto"></param>
  7647. /// <returns></returns>
  7648. [HttpPost]
  7649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7650. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7651. {
  7652. try
  7653. {
  7654. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7655. if (groupData.Code != 0)
  7656. {
  7657. return Ok(JsonView(false, groupData.Msg));
  7658. }
  7659. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7660. }
  7661. catch (Exception ex)
  7662. {
  7663. return Ok(JsonView(false, ex.Message));
  7664. }
  7665. }
  7666. /// <summary>
  7667. /// OP费用录入填写详情
  7668. /// </summary>
  7669. /// <param name="dto"></param>
  7670. /// <returns></returns>
  7671. [HttpPost]
  7672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7673. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7674. {
  7675. try
  7676. {
  7677. #region 参数校验
  7678. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7679. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7680. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7681. #endregion
  7682. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7683. if (groupData.Code != 0)
  7684. {
  7685. return Ok(JsonView(false, groupData.Msg));
  7686. }
  7687. //自动审核
  7688. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7689. #region 应用推送
  7690. try
  7691. {
  7692. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7693. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7694. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7695. //2024-10-21 新增LZ UID
  7696. var userIds = new List<int>() { 21 };
  7697. string title = $"系统通知";
  7698. var diId = dto.DiId;
  7699. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7700. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7701. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7702. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7703. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7704. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7705. }
  7706. catch (Exception ex)
  7707. {
  7708. }
  7709. #endregion
  7710. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7711. }
  7712. catch (Exception ex)
  7713. {
  7714. return Ok(JsonView(false, ex.Message));
  7715. }
  7716. }
  7717. /// <summary>
  7718. /// 获取三公详细所有城市
  7719. /// </summary>
  7720. /// <returns></returns>
  7721. [HttpGet]
  7722. public IActionResult OpCarCityResult()
  7723. {
  7724. var jw = JsonView(false);
  7725. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7726. {
  7727. x.Id,
  7728. x.Country,
  7729. x.City,
  7730. }).ToList();
  7731. if (data.Count > 0)
  7732. {
  7733. jw = JsonView(true, "获取成功!", data);
  7734. }
  7735. else
  7736. {
  7737. jw.Msg = "城市数据为空!";
  7738. jw.Data = new string[0];
  7739. }
  7740. return Ok(jw);
  7741. }
  7742. /// <summary>
  7743. /// 导出地接费用明细
  7744. /// </summary>
  7745. /// <param name="dto"></param>
  7746. /// <returns></returns>
  7747. [HttpPost]
  7748. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7749. {
  7750. var jw = JsonView(false);
  7751. if (dto.Diid < 1)
  7752. {
  7753. jw.Msg = "请输入正确的diid!";
  7754. return Ok(jw);
  7755. }
  7756. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7757. if (group == null)
  7758. {
  7759. jw.Msg = "未找到团组信息!";
  7760. return Ok(jw);
  7761. }
  7762. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7763. if (localGuideArr.Count == 0)
  7764. {
  7765. jw.Msg = "该团组暂无地接信息!";
  7766. return Ok(jw);
  7767. }
  7768. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7769. var overspendSoure = new Dictionary<int, int>
  7770. {
  7771. { 91, 982 }, //车
  7772. { 92 , 1059} ,//导游
  7773. { 994 , 1073}, //翻译
  7774. { 988 , 1074 }, //早餐
  7775. { 93 , 1075 }, //午餐
  7776. { 989 , 1076 }, //晚餐
  7777. };
  7778. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7779. foreach (var groupArr in localGroup)
  7780. {
  7781. var keyValue = groupArr.Key;
  7782. if (int.TryParse(keyValue, out int cityid))
  7783. {
  7784. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7785. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7786. }
  7787. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7788. foreach (var item in groupArr)
  7789. {
  7790. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7791. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7792. new Grp_CarTouristGuideGroundReservationsContentExtend
  7793. {
  7794. Count = a.Count,
  7795. CreateTime = a.CreateTime,
  7796. CreateUserId = a.CreateUserId,
  7797. CTGGRId = a.CTGGRId,
  7798. Currency = a.Currency,
  7799. DatePrice = a.DatePrice,
  7800. DeleteTime = a.DeleteTime,
  7801. DeleteUserId = a.DeleteUserId,
  7802. DiId = a.DiId,
  7803. Id = a.Id,
  7804. IsDel = a.IsDel,
  7805. Price = a.Price,
  7806. PriceContent = a.PriceContent,
  7807. Remark = a.Remark,
  7808. SId = a.SId,
  7809. SidName = b.Name,
  7810. Units = a.Units,
  7811. }
  7812. ).ToList();
  7813. if (content.Count > 0)
  7814. {
  7815. contentArr.Add(content);
  7816. }
  7817. }
  7818. //open excel
  7819. //set excel
  7820. //save excel
  7821. try
  7822. {
  7823. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7824. IWorkbook workbook;
  7825. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7826. {
  7827. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7828. }
  7829. else
  7830. {
  7831. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7832. }
  7833. ISheet sheet = workbook.GetSheetAt(0);
  7834. var rowStartIndex = 2;
  7835. var clounmCount = 10;
  7836. var initStyleRow = sheet.GetRow(2);
  7837. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7838. //var overspendArrDetail =
  7839. var existsId = new List<CarCompare>();
  7840. var lastElem = arr.Last();
  7841. var thisSid = -1;
  7842. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7843. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7844. {
  7845. Name = "未知币种!",
  7846. Remark = "未知币种!",
  7847. };
  7848. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7849. Action cloneRowFn = () =>
  7850. {
  7851. rowStartIndex++;
  7852. var cloneRow = sheet.CreateRow(rowStartIndex);
  7853. // 复制样式
  7854. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7855. {
  7856. ICell sourceCell = initStyleRow.GetCell(i);
  7857. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7858. // 确保单元格存在样式
  7859. if (sourceCell.CellStyle != null)
  7860. {
  7861. targetCell.CellStyle = sourceCell.CellStyle;
  7862. }
  7863. }
  7864. };
  7865. var mergeRow = () =>
  7866. {
  7867. for (int i = 2; i < sheet.LastRowNum; i++)
  7868. {
  7869. var row = sheet.GetRow(i);
  7870. var cellFirst = row.GetCell(0);
  7871. var thisIndex = i + 1;
  7872. while (thisIndex < sheet.LastRowNum)
  7873. {
  7874. var nextRow = sheet.GetRow(thisIndex);
  7875. var nextCellFirst = nextRow.GetCell(0);
  7876. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7877. {
  7878. thisIndex++;
  7879. }
  7880. else
  7881. {
  7882. break;
  7883. }
  7884. }
  7885. thisIndex--;
  7886. if (thisIndex != i)
  7887. {
  7888. //合并row
  7889. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7890. i, // 起始行索引(0-based)
  7891. thisIndex, // 结束行索引(0-based)
  7892. 0, // 起始列索引(0-based)
  7893. 0 // 结束列索引(0-based)
  7894. );
  7895. sheet.AddMergedRegion(cellRangeAddress);
  7896. i = thisIndex;
  7897. }
  7898. }
  7899. };
  7900. var chaoshiNumber = 0;
  7901. var totalNumber = 0.00M;
  7902. string lastStr = "";
  7903. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7904. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7905. {
  7906. b.IsAuditGM,
  7907. x.Id,
  7908. x.Area,
  7909. b.PayPercentage,
  7910. b.PayMoney,
  7911. }).ToList();
  7912. string yesPayment = "", noPayment = "";
  7913. foreach (var item in queryCarArrByCityAndDiid)
  7914. {
  7915. if (item.IsAuditGM == 1)
  7916. {
  7917. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7918. }
  7919. else
  7920. {
  7921. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7922. }
  7923. }
  7924. lastStr = yesPayment + noPayment;
  7925. foreach (var item in arr)
  7926. {
  7927. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  7928. {
  7929. if (thisSid != item.SId)
  7930. {
  7931. if (thisSid == -1)
  7932. {
  7933. thisSid = item.SId;
  7934. }
  7935. else
  7936. {
  7937. //合并小计行
  7938. //创建合并区域的实例
  7939. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7940. rowStartIndex, // 起始行索引(0-based)
  7941. rowStartIndex, // 结束行索引(0-based)
  7942. 0, // 起始列索引(0-based)
  7943. 3 // 结束列索引(0-based)
  7944. );
  7945. sheet.AddMergedRegion(cellRangeAddress);
  7946. var CellStyle = workbook.CreateCellStyle();
  7947. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7948. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7949. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7950. for (int i = 0; i <= clounmCount; i++)
  7951. {
  7952. if (i > 6)
  7953. {
  7954. var CellStyle1 = workbook.CreateCellStyle();
  7955. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7956. IFont Font = workbook.CreateFont(); // 创建字体
  7957. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7958. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7959. CellStyle1.SetFont(Font);
  7960. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7961. }
  7962. else
  7963. {
  7964. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7965. }
  7966. }
  7967. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7968. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7969. //超时合计
  7970. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7971. //超时数
  7972. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7973. //超时合计费用
  7974. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7975. thisSid = item.SId;
  7976. cloneRowFn();
  7977. chaoshiNumber = 0;
  7978. totalNumber = 0;
  7979. }
  7980. }
  7981. IRow row = sheet.GetRow(rowStartIndex);
  7982. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7983. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  7984. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  7985. if (isOpenOverspendSoure)
  7986. {
  7987. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7988. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  7989. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  7990. }
  7991. for (int i = 0; i <= clounmCount; i++)
  7992. {
  7993. var cell = row.GetCell(i);
  7994. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  7995. if (cell == null)
  7996. {
  7997. cell = row.CreateCell(i);
  7998. }
  7999. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  8000. fontRed.CloneStyleFrom(cell.CellStyle);
  8001. IFont Font = workbook.CreateFont(); // 创建字体
  8002. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8003. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8004. fontRed.SetFont(Font);
  8005. byte[] rgb = new byte[3] { 255, 242, 204 };
  8006. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8007. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8008. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8009. if (workbook is XSSFWorkbook)
  8010. {
  8011. BackgroundColor255_242_204.FillForegroundColor = 0;
  8012. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8013. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8014. }
  8015. else
  8016. {
  8017. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8018. }
  8019. if (i == 1 || i > 6)
  8020. {
  8021. if (i > 6)
  8022. {
  8023. fontRed.FillForegroundColor = 0;
  8024. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8025. fontRed.FillPattern = FillPattern.SolidForeground;
  8026. }
  8027. cell.CellStyle = fontRed;
  8028. }
  8029. if (i > 2 && i < 7)
  8030. {
  8031. cell.CellStyle = BackgroundColor255_242_204;
  8032. }
  8033. cell.SetCellValue(setCellValue); //写入单元格
  8034. }
  8035. if (overspendSoure.ContainsKey(thisSid))
  8036. {
  8037. var overspendId = overspendSoure[thisSid];
  8038. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8039. }
  8040. cloneRowFn();
  8041. existsId.Add(new CarCompare
  8042. {
  8043. DataPrice = item.DatePrice.ObjToDate(),
  8044. Sid = item.SId
  8045. });
  8046. }
  8047. if (item.Equals(lastElem))
  8048. {
  8049. //合并小计行
  8050. //创建合并区域的实例
  8051. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8052. rowStartIndex, // 起始行索引(0-based)
  8053. rowStartIndex, // 结束行索引(0-based)
  8054. 0, // 起始列索引(0-based)
  8055. 3 // 结束列索引(0-based)
  8056. );
  8057. sheet.AddMergedRegion(cellRangeAddress);
  8058. var CellStyle = workbook.CreateCellStyle();
  8059. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8060. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8061. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8062. for (int i = 0; i <= clounmCount; i++)
  8063. {
  8064. if (i > 6)
  8065. {
  8066. var CellStyle1 = workbook.CreateCellStyle();
  8067. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8068. IFont Font = workbook.CreateFont(); // 创建字体
  8069. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8070. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8071. CellStyle1.SetFont(Font);
  8072. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8073. }
  8074. else
  8075. {
  8076. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8077. }
  8078. }
  8079. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8080. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8081. //超时合计
  8082. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8083. //超时数
  8084. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8085. //超时合计费用
  8086. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8087. cloneRowFn();
  8088. // 创建合并区域的实例
  8089. cellRangeAddress = new CellRangeAddress(
  8090. rowStartIndex, // 起始行索引(0-based)
  8091. rowStartIndex, // 结束行索引(0-based)
  8092. 0, // 起始列索引(0-based)
  8093. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8094. );
  8095. // 添加合并区域
  8096. sheet.AddMergedRegion(cellRangeAddress);
  8097. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8098. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8099. }
  8100. }
  8101. mergeRow();
  8102. // 保存修改后的Excel文件到新文件
  8103. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8104. // new FileStream(newFilePath, FileMode.CreateNew)
  8105. using (var stream = new MemoryStream())
  8106. {
  8107. workbook.Write(stream, true);
  8108. stream.Flush();
  8109. stream.Seek(0, SeekOrigin.Begin);
  8110. MemoryStream memoryStream = new MemoryStream();
  8111. stream.CopyTo(memoryStream);
  8112. memoryStream.Seek(0, SeekOrigin.Begin);
  8113. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8114. }
  8115. workbook.Close();
  8116. workbook.Dispose();
  8117. }
  8118. catch (Exception ex)
  8119. {
  8120. jw.Msg = "出现异常!" + ex.Message;
  8121. return Ok(jw);
  8122. }
  8123. }
  8124. if (Zips.Count > 0)
  8125. {
  8126. IOOperatorHelper io = new IOOperatorHelper();
  8127. var byts = io.ConvertZipStream(Zips);
  8128. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8129. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8130. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8131. }
  8132. else
  8133. {
  8134. jw.Msg = "暂无生成文件!";
  8135. }
  8136. return Ok(jw);
  8137. }
  8138. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8139. {
  8140. string outStr = string.Empty;
  8141. switch (i)
  8142. {
  8143. case 0:
  8144. outStr = arr[0].SidName;
  8145. break;
  8146. case 1:
  8147. outStr = arr[0].DataPriceStr;
  8148. break;
  8149. case 2:
  8150. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8151. break;
  8152. case 4:
  8153. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8154. break;
  8155. case 7:
  8156. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8157. {
  8158. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8159. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8160. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8161. }
  8162. break;
  8163. case 8:
  8164. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8165. {
  8166. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8167. }
  8168. break;
  8169. case 9:
  8170. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8171. {
  8172. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8173. }
  8174. break;
  8175. case 10:
  8176. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8177. {
  8178. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8179. }
  8180. break;
  8181. }
  8182. return outStr;
  8183. }
  8184. #region OP行程单
  8185. /// <summary>
  8186. /// OP行程单初始化
  8187. /// </summary>
  8188. /// <param name="dto"></param>
  8189. /// <returns></returns>
  8190. [HttpPost]
  8191. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8192. {
  8193. var jw = JsonView(false);
  8194. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8195. var group = groupList.First();
  8196. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8197. if (group == null)
  8198. {
  8199. jw.Msg = "暂无团组!";
  8200. return Ok(jw);
  8201. }
  8202. group = groupList.Find(x => x.Id == diid);
  8203. if (group == null)
  8204. {
  8205. jw.Msg = "请输入正确的团组ID!";
  8206. return Ok(jw);
  8207. }
  8208. string city = string.Empty;
  8209. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8210. if (blackCode.Count > 0)
  8211. {
  8212. var black = blackCode.First();
  8213. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8214. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8215. if (blackSp.Length > 0)
  8216. {
  8217. try
  8218. {
  8219. var cityArrCode = new List<string>(20);
  8220. foreach (var item in blackSp)
  8221. {
  8222. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8223. var IndexSelect = itemSp[2];
  8224. var cityArrCodeLength = cityArrCode.Count - 1;
  8225. var startCity = IndexSelect.Substring(0, 3);
  8226. if (cityArrCodeLength > 0)
  8227. {
  8228. var arrEndCity = cityArrCode[cityArrCodeLength];
  8229. if (arrEndCity != startCity)
  8230. {
  8231. cityArrCode.Add(startCity.ToUpper());
  8232. }
  8233. }
  8234. else
  8235. {
  8236. cityArrCode.Add(startCity.ToUpper());
  8237. }
  8238. var endCity = IndexSelect.Substring(3, 3);
  8239. cityArrCode.Add(endCity.ToUpper());
  8240. }
  8241. var cityThree = string.Empty;
  8242. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8243. cityThree = cityThree.TrimEnd(',');
  8244. if (string.IsNullOrWhiteSpace(cityThree))
  8245. {
  8246. throw new
  8247. Exception("error");
  8248. }
  8249. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8250. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8251. foreach (var item in cityArrCode)
  8252. {
  8253. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8254. if (find != null)
  8255. {
  8256. city += find.City + "/";
  8257. }
  8258. else
  8259. {
  8260. city += item + "三字码未收入/";
  8261. }
  8262. }
  8263. city = city.TrimEnd('/');
  8264. }
  8265. catch (Exception e)
  8266. {
  8267. city = "黑屏代码格式不正确!";
  8268. }
  8269. }
  8270. }
  8271. else
  8272. {
  8273. city = "未录入黑屏代码";
  8274. }
  8275. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8276. {
  8277. Date = x.Date,
  8278. Days = x.Days,
  8279. Diffgroup = x.Diffgroup,
  8280. Diid = x.Diid,
  8281. Traffic_First = x.Traffic_First,
  8282. Traffic_Second = x.Traffic_Second,
  8283. Trip = x.Trip,
  8284. WeekDay = x.WeekDay,
  8285. Id = x.Id
  8286. }).ToList();
  8287. jw.Data = new
  8288. {
  8289. groupList = groupList.Select(x => new
  8290. {
  8291. x.Id,
  8292. x.TeamName,
  8293. x.TourCode
  8294. }).ToList(),
  8295. groupInfo = new
  8296. {
  8297. group.VisitDays,
  8298. group.TourCode,
  8299. group.VisitPNumber,
  8300. group.TeamName,
  8301. city
  8302. },
  8303. OpTravelList
  8304. };
  8305. jw.Code = 200;
  8306. jw.Msg = "操作成功!";
  8307. return Ok(jw);
  8308. }
  8309. /// <summary>
  8310. /// 删除团组行程单
  8311. /// </summary>
  8312. /// <returns></returns>
  8313. [HttpPost]
  8314. public IActionResult DelTravel(DelOpTravelDto dto)
  8315. {
  8316. var jw = JsonView(false);
  8317. if (dto.UserId <= 0 || dto.Diid <= 0)
  8318. {
  8319. jw.Msg = "请输入正确的参数!";
  8320. return Ok(jw);
  8321. }
  8322. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8323. .SetColumns(x => new Grp_TravelList
  8324. {
  8325. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8326. DeleteUserId = dto.UserId,
  8327. IsDel = 1,
  8328. }).ExecuteCommand();
  8329. jw = JsonView(true);
  8330. return Ok(jw);
  8331. }
  8332. /// <summary>
  8333. /// 行程单保存
  8334. /// </summary>
  8335. /// <returns></returns>
  8336. [HttpPost]
  8337. public IActionResult TravelSave(TravelSaveDto dto)
  8338. {
  8339. var jw = JsonView(false);
  8340. if (dto.Arr.Count > 0)
  8341. {
  8342. try
  8343. {
  8344. _sqlSugar.BeginTran();
  8345. foreach (var item in dto.Arr)
  8346. {
  8347. if (item.Id == 0)
  8348. {
  8349. throw new Exception("请传入正确的Id");
  8350. }
  8351. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8352. .SetColumns(x => new Grp_TravelList
  8353. {
  8354. Trip = item.Trip
  8355. }).ExecuteCommand();
  8356. }
  8357. _sqlSugar.CommitTran();
  8358. jw = JsonView(true);
  8359. }
  8360. catch (Exception ex)
  8361. {
  8362. _sqlSugar.RollbackTran();
  8363. jw.Msg = "程序异常!" + ex.Message;
  8364. }
  8365. }
  8366. else
  8367. {
  8368. jw.Msg = "请传入正确的参数!";
  8369. }
  8370. return Ok(jw);
  8371. }
  8372. /// <summary>
  8373. /// 导出行程单
  8374. /// </summary>
  8375. /// <param name="dto"></param>
  8376. /// <returns></returns>
  8377. [HttpPost]
  8378. public IActionResult ExportTravel(ExportTravelDto dto)
  8379. {
  8380. var jw = JsonView(false);
  8381. jw.Data = "";
  8382. int diid = 0;
  8383. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8384. if (Find == null)
  8385. {
  8386. jw.Msg = "请选择正确的团组!";
  8387. return Ok(jw);
  8388. }
  8389. else
  8390. {
  8391. diid = Find.Id;
  8392. }
  8393. //数据源
  8394. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8395. DataTable dtBlack = null;
  8396. try
  8397. {
  8398. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8399. }
  8400. catch (Exception)
  8401. {
  8402. jw.Msg = "机票黑屏代码有误!";
  8403. return Ok(jw);
  8404. }
  8405. string CityStr = string.Empty;
  8406. if (dtBlack.Rows.Count == 0)
  8407. {
  8408. jw.Msg = "机票黑屏代码有误!";
  8409. return Ok(jw);
  8410. }
  8411. else
  8412. {
  8413. foreach (DataRow row in dtBlack.Rows)
  8414. {
  8415. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8416. {
  8417. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8418. return Ok(jw);
  8419. }
  8420. }
  8421. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8422. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8423. }
  8424. //创建数据源Table
  8425. DataTable dtSource = new DataTable();
  8426. dtSource.Columns.Add("Days", typeof(string));
  8427. dtSource.Columns.Add("Date", typeof(string));
  8428. dtSource.Columns.Add("Week", typeof(string));
  8429. dtSource.Columns.Add("Traffic", typeof(string));
  8430. dtSource.Columns.Add("Trip", typeof(string));
  8431. //获取数据,放到datatable
  8432. foreach (var item in _travelList)
  8433. {
  8434. DataRow dr = dtSource.NewRow();
  8435. dr["Days"] = item.Days;
  8436. dr["Date"] = item.Date;
  8437. dr["Week"] = item.WeekDay;
  8438. dr["Traffic"] = item.Traffic_First
  8439. + "\r\n"
  8440. + item.Traffic_Second;
  8441. dr["Trip"] = item.Trip;
  8442. dtSource.Rows.Add(dr);
  8443. }
  8444. Dictionary<string, string> dic = new Dictionary<string, string>();
  8445. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8446. dic.Add("City", CityStr);
  8447. dic.Add("Days", Find.VisitDays.ToString());
  8448. dic.Add("DeleCode", Find.TourCode);
  8449. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8450. //模板路径
  8451. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8452. //载入模板
  8453. Document doc = null;
  8454. DocumentBuilder builder = null;
  8455. try
  8456. {
  8457. //载入模板
  8458. doc = new Document(tempPath);
  8459. builder = new DocumentBuilder(doc);
  8460. }
  8461. catch (Exception)
  8462. {
  8463. jw.Msg = "模板位置不存在!";
  8464. return Ok(jw);
  8465. }
  8466. foreach (var key in dic.Keys)
  8467. {
  8468. Bookmark bookmark = doc.Range.Bookmarks[key];
  8469. if (bookmark != null)
  8470. {
  8471. builder.MoveToBookmark(key);
  8472. builder.Write(dic[key]);
  8473. }
  8474. }
  8475. //获取word里所有表格
  8476. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8477. //获取所填表格的序数
  8478. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8479. try
  8480. {
  8481. //循环赋值
  8482. for (int i = 0; i < dtSource.Rows.Count; i++)
  8483. {
  8484. builder.MoveToCell(0, i + 1, 0, 0);
  8485. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8486. builder.MoveToCell(0, i + 1, 1, 0);
  8487. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8488. builder.MoveToCell(0, i + 1, 2, 0);
  8489. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8490. var trip = dtSource.Rows[i]["Trip"].ToString();
  8491. builder.MoveToCell(0, i + 1, 3, 0);
  8492. builder.Write(trip);
  8493. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8494. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8495. // 获取特定索引的段落
  8496. Paragraph paragraph = (Paragraph)paragraphs[0];
  8497. Run run = paragraph.Runs[0];
  8498. Aspose.Words.Font font = run.Font;
  8499. font.Name = "黑体";
  8500. //设置双休红色
  8501. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8502. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8503. paragraph = (Paragraph)paragraphs[1];
  8504. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8505. {
  8506. run = paragraph.Runs[0];
  8507. font = run.Font;
  8508. font.Color = Color.Red;
  8509. }
  8510. }
  8511. }
  8512. catch (Exception ex)
  8513. {
  8514. }
  8515. //删除多余行
  8516. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8517. {
  8518. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8519. }
  8520. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8521. if (!Directory.Exists(savePath))
  8522. {
  8523. try
  8524. {
  8525. Directory.CreateDirectory(savePath);
  8526. }
  8527. catch
  8528. {
  8529. }
  8530. }
  8531. string path = savePath + Find.TeamName + "出访日程";
  8532. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8533. try
  8534. {
  8535. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8536. string postfix = ".docx";
  8537. if (dto.IsPDF == 1)
  8538. {
  8539. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8540. postfix = ".pdf";
  8541. }
  8542. doc.Save(path + postfix, saveFormat);
  8543. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8544. }
  8545. catch (Exception)
  8546. {
  8547. jw = JsonView(false);
  8548. }
  8549. return Ok(jw);
  8550. }
  8551. /// <summary>
  8552. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8553. /// </summary>
  8554. /// <param name="num"></param>
  8555. /// <returns></returns>
  8556. string GetNum(string num)
  8557. {
  8558. string str = "";
  8559. switch (num)
  8560. {
  8561. case "1":
  8562. str = "一";
  8563. break;
  8564. case "2":
  8565. str = "二";
  8566. break;
  8567. case "3":
  8568. str = "三";
  8569. break;
  8570. case "4":
  8571. str = "四";
  8572. break;
  8573. case "5":
  8574. str = "五";
  8575. break;
  8576. case "6":
  8577. str = "六";
  8578. break;
  8579. case "7":
  8580. str = "七";
  8581. break;
  8582. case "8":
  8583. str = "八";
  8584. break;
  8585. case "9":
  8586. str = "九";
  8587. break;
  8588. case "10":
  8589. str = "十";
  8590. break;
  8591. case "11":
  8592. str = "十一";
  8593. break;
  8594. case "12":
  8595. str = "十二";
  8596. break;
  8597. case "一":
  8598. str = "1";
  8599. break;
  8600. case "二":
  8601. str = "2";
  8602. break;
  8603. case "三":
  8604. str = "3";
  8605. break;
  8606. case "四":
  8607. str = "4";
  8608. break;
  8609. case "五":
  8610. str = "5";
  8611. break;
  8612. case "六":
  8613. str = "6";
  8614. break;
  8615. case "七":
  8616. str = "7";
  8617. break;
  8618. case "八":
  8619. str = "8";
  8620. break;
  8621. case "九":
  8622. str = "9";
  8623. break;
  8624. case "十":
  8625. str = "10";
  8626. break;
  8627. case "十一":
  8628. str = "11";
  8629. break;
  8630. case "十二":
  8631. str = "12";
  8632. break;
  8633. }
  8634. return str;
  8635. }
  8636. #endregion
  8637. #endregion
  8638. #region 团组成本
  8639. /// <summary>
  8640. /// 团组成本数据初始化
  8641. /// </summary>
  8642. /// <param name="dto"></param>
  8643. /// <returns></returns>
  8644. [HttpPost]
  8645. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8646. {
  8647. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8648. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8649. WHEN COUNT(*) >= 0 THEN 'True'
  8650. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8651. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8652. ").ToList(); //团组列表
  8653. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8654. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8655. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8656. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8657. if (groupinfoValue != null)
  8658. {
  8659. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8660. var spArr = new string[1] { countryArr };
  8661. if (countryArr.Contains("|"))
  8662. {
  8663. spArr = countryArr.Split("|");
  8664. }
  8665. else if (countryArr.Contains("、"))
  8666. {
  8667. spArr = countryArr.Split("、");
  8668. }
  8669. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8670. {
  8671. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8672. if (dbQueryCountry != null)
  8673. {
  8674. visaCountryInfoArr.Add(dbQueryCountry);
  8675. }
  8676. }
  8677. }
  8678. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8679. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8680. var create = _GroupCostRepository.
  8681. CreateGroupCostByBlackCode(dto.Diid);
  8682. if (groupCost.Count == 0 && create.Code == 0)
  8683. {
  8684. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8685. }
  8686. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8687. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8688. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8689. groupCostMap = groupCostMap.Select(x =>
  8690. {
  8691. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8692. {
  8693. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8694. }
  8695. return x;
  8696. }).ToList();
  8697. //GroupCostParameter.Add(new
  8698. // Grp_GroupCostParameter());
  8699. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8700. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8701. return Ok(JsonView(new
  8702. {
  8703. groupList,
  8704. groupInfo,
  8705. groupChecks,
  8706. groupCost = groupCostMap,
  8707. hotelNumber,
  8708. GroupCostParameter = GroupCostParameterMap,
  8709. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8710. {
  8711. x.VisaCountry,
  8712. x.VisaPrice,
  8713. x.Id,
  8714. }).ToList(),
  8715. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8716. blackCodeIsTrue = create.Code == 0 ? true : false,
  8717. hotelIsTrue = hotelIsTrue,
  8718. }));
  8719. }
  8720. /// <summary>
  8721. /// 团组成本信息保存
  8722. /// </summary>
  8723. /// <param name="dto"></param>
  8724. /// <returns></returns>
  8725. [HttpPost]
  8726. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8727. {
  8728. if (dto.Diid <= 0 || dto.Userid <= 0)
  8729. {
  8730. return Ok(JsonView(false));
  8731. }
  8732. JsonView jw = null;
  8733. bool isTrue = false;
  8734. #region 复制团组成本
  8735. //if (dto.Diid == 2581)
  8736. //{
  8737. // dto.Diid = 2599;
  8738. // dto.CheckBoxs.ForEach(x =>
  8739. // {
  8740. // x.Diid = 2599;
  8741. // });
  8742. // dto.GroupCosts.ForEach(x =>
  8743. // {
  8744. // x.Diid = 2599;
  8745. // });
  8746. // dto.CostTypeHotelNumbers.ForEach(x =>
  8747. // {
  8748. // x.Diid = 2599;
  8749. // });
  8750. // dto.GroupCostParameters.ForEach(x =>
  8751. // {
  8752. // x.DiId = 2599;
  8753. // });
  8754. //}
  8755. #endregion
  8756. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8757. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8758. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8759. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8760. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8761. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8762. try
  8763. {
  8764. _sqlSugar.BeginTran();
  8765. isTrue = await _GroupCostRepository.
  8766. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8767. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8768. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8769. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8770. _sqlSugar.CommitTran();
  8771. jw = JsonView(true, "保存成功!", isTrue);
  8772. }
  8773. catch (Exception)
  8774. {
  8775. _sqlSugar.RollbackTran();
  8776. jw = JsonView(false);
  8777. }
  8778. return Ok(jw);
  8779. }
  8780. /// <summary>
  8781. /// 司兼导数据
  8782. /// </summary>
  8783. /// <param name="dto"></param>
  8784. /// <returns></returns>
  8785. [HttpPost]
  8786. public IActionResult GetCarGuides(CarGuidesDto dto)
  8787. {
  8788. JsonView jw = null;
  8789. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8790. jw = JsonView(true, "获取成功!", Data);
  8791. return Ok(jw);
  8792. }
  8793. /// <summary>
  8794. /// 导游数据
  8795. /// </summary>
  8796. /// <param name="dto"></param>
  8797. /// <returns></returns>
  8798. [HttpPost]
  8799. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8800. {
  8801. JsonView jw = null;
  8802. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8803. // 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
  8804. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8805. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8806. jw = JsonView(true, "获取成功!", Data);
  8807. return Ok(jw);
  8808. }
  8809. /// <summary>
  8810. /// 成本车数据
  8811. /// </summary>
  8812. /// <param name="dto"></param>
  8813. /// <returns></returns>
  8814. [HttpPost]
  8815. public IActionResult GetCarInfo(CarGuidesDto dto)
  8816. {
  8817. JsonView jw = null;
  8818. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8819. jw = JsonView(true, "获取成功!", Data);
  8820. return Ok(jw);
  8821. }
  8822. /// <summary>
  8823. /// 景点数据
  8824. /// </summary>
  8825. /// <param name="dto"></param>
  8826. /// <returns></returns>
  8827. [HttpPost]
  8828. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8829. {
  8830. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8831. return Ok(JsonView(true, "获取成功!", Data));
  8832. }
  8833. /// <summary>
  8834. /// 成本通知
  8835. /// </summary>
  8836. /// <param name="dto"></param>
  8837. /// <returns></returns>
  8838. [HttpPost]
  8839. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8840. {
  8841. if (dto.Diid < 0)
  8842. {
  8843. return Ok(JsonView(false));
  8844. }
  8845. JsonView jw = null;
  8846. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8847. if (GroupCostParameter != null)
  8848. {
  8849. int IsShare = 0;
  8850. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8851. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8852. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8853. string msg = string.Empty;
  8854. if (isTrue)
  8855. {
  8856. if (IsShare == 0)
  8857. {
  8858. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8859. }
  8860. else
  8861. {
  8862. #region 企微通知对应岗位用户
  8863. try
  8864. {
  8865. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8866. }
  8867. catch (Exception ex)
  8868. {
  8869. }
  8870. #endregion
  8871. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8872. }
  8873. jw = JsonView(isTrue, msg, new { IsShare });
  8874. }
  8875. else
  8876. {
  8877. msg = "修改失败!";
  8878. jw = JsonView(isTrue, msg);
  8879. }
  8880. }
  8881. else
  8882. {
  8883. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8884. }
  8885. return Ok(jw);
  8886. }
  8887. /// <summary>
  8888. /// 导出报价单
  8889. /// </summary>
  8890. /// <param name="dto"></param>
  8891. /// <returns></returns>
  8892. [HttpPost]
  8893. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8894. {
  8895. if (dto.Diid == 0)
  8896. {
  8897. return Ok(JsonView(false, "请传递团组id"));
  8898. }
  8899. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8900. if (deleInfo.Code != 0)
  8901. {
  8902. return Ok(JsonView(false, "团组信息查询失败!"));
  8903. }
  8904. var di = deleInfo.Data as DelegationInfoWebView;
  8905. if (di != null)
  8906. {
  8907. di.TeamName = di.TeamName.Replace("|", "、");
  8908. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8909. //文件名
  8910. string strFileName = di.TeamName + "-收款账单.doc";
  8911. //获取模板
  8912. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8913. //载入模板
  8914. Document doc = new Document(tmppath);
  8915. decimal TotalPrice = 0.00M;
  8916. string itemStr = string.Empty;
  8917. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8918. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8919. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8920. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8921. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8922. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8923. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8924. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  8925. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  8926. foreach (var cost in groupCostType)
  8927. {
  8928. var List = cost.ToList();
  8929. if (cost.Key == "A")
  8930. {
  8931. foreach (var ListItem in List)
  8932. {
  8933. if (ListItem.number > 0)
  8934. {
  8935. if (ListItem.code.Contains("TBR"))
  8936. {
  8937. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8938. }
  8939. else
  8940. {
  8941. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8942. }
  8943. TotalPrice += (ListItem.number * ListItem.price);
  8944. }
  8945. }
  8946. }
  8947. else
  8948. {
  8949. itemStr = itemStr.Insert(0, "A段\r\n");
  8950. itemStr += "B段\r\n";
  8951. foreach (var ListItem in List)
  8952. {
  8953. if (ListItem.number > 0)
  8954. {
  8955. if (ListItem.code.Contains("TBR"))
  8956. {
  8957. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8958. }
  8959. else
  8960. {
  8961. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8962. }
  8963. TotalPrice += (ListItem.number * ListItem.price);
  8964. }
  8965. }
  8966. }
  8967. }
  8968. #region 替换Word模板书签内容
  8969. Dictionary<string, string> marks = new Dictionary<string, string>();
  8970. marks.Add("To", di.ClientUnit);//付款方
  8971. marks.Add("ToTel", di.TellPhone);//付款方电话
  8972. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  8973. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  8974. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  8975. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  8976. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  8977. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  8978. marks.Add("PayItemContent", itemStr);//详细信息
  8979. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  8980. #endregion
  8981. ////注
  8982. //if (doc.Range.Bookmarks["Attention"] != null)
  8983. //{
  8984. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  8985. // mark.Text = frList[0].Attention;
  8986. //}
  8987. foreach (var item in marks.Keys)
  8988. {
  8989. if (doc.Range.Bookmarks[item] != null)
  8990. {
  8991. Bookmark mark = doc.Range.Bookmarks[item];
  8992. mark.Text = marks[item];
  8993. }
  8994. }
  8995. byte[] bytes = null;
  8996. using (MemoryStream stream = new MemoryStream())
  8997. {
  8998. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8999. bytes = stream.ToArray();
  9000. }
  9001. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9002. return Ok(JsonView(true, "", new
  9003. {
  9004. Data = bytes,
  9005. strFileName,
  9006. }));
  9007. }
  9008. else
  9009. {
  9010. return Ok(JsonView(false, "团组信息不存在!"));
  9011. }
  9012. }
  9013. /// <summary>
  9014. /// 导出团组成本
  9015. /// </summary>
  9016. /// <param name="dto"></param>
  9017. /// <returns></returns>
  9018. [HttpPost]
  9019. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9020. {
  9021. var jw = JsonView(false);
  9022. if (dto.Diid == 0)
  9023. {
  9024. return Ok(JsonView(false, "请传递团组id"));
  9025. }
  9026. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9027. if (deleInfo.Code != 0)
  9028. {
  9029. return Ok(JsonView(false, "团组信息查询失败!"));
  9030. }
  9031. var di = deleInfo.Data as DelegationInfoWebView;
  9032. if (di == null)
  9033. {
  9034. return Ok(JsonView(false, "团组信息查询失败!"));
  9035. }
  9036. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9037. WorkbookDesigner designer = new WorkbookDesigner();
  9038. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9039. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9040. for (int i = 0; i < List_GC.Count; i++)
  9041. {
  9042. GroupCost_Excel gc = new GroupCost_Excel();
  9043. gc.Id = List_GC[i].Id;
  9044. gc.Diid = List_GC[i].Diid.ToString();
  9045. gc.DAY = List_GC[i].DAY;
  9046. string week = "";
  9047. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9048. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9049. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9050. gc.ITIN = List_GC[i].ITIN;
  9051. gc.CarType = List_GC[i].CarType;
  9052. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9053. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9054. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9055. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9056. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9057. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9058. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9059. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9060. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9061. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9062. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9063. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9064. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9065. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9066. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9067. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9068. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9069. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9070. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9071. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9072. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9073. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9074. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9075. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9076. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9077. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9078. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9079. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9080. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9081. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9082. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9083. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9084. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9085. List_GC1.Add(gc);
  9086. }
  9087. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9088. dt.TableName = "TB";
  9089. //报表标题等不用dt的值
  9090. designer.SetDataSource("TeamName", dto.title.TeamName);
  9091. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9092. designer.SetDataSource("Tax", dto.title.Tax);
  9093. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9094. designer.SetDataSource("Currency", dto.title.Currency);
  9095. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9096. designer.SetDataSource("Rate", dto.title.Rate);
  9097. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9098. var Aparams = hotels.Find(x => x.Type == "Default");
  9099. if (Aparams == null)
  9100. {
  9101. return Ok(jw);
  9102. }
  9103. //酒店数量
  9104. var txtSGRNumber = Aparams.SGR.ToString();
  9105. var txtTBRNumber = Aparams.TBR.ToString();
  9106. var txtJSESNumber = Aparams.JSES.ToString();
  9107. var txtSUITENumbe = Aparams.SUITE.ToString();
  9108. if (dto.costType == "B")
  9109. {
  9110. Aparams = hotels.Find(x => x.Type == "A");
  9111. var Bparams = hotels.Find(x => x.Type == "B");
  9112. if (Aparams == null || Bparams == null)
  9113. {
  9114. return Ok(jw);
  9115. }
  9116. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9117. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9118. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9119. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9120. }
  9121. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9122. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9123. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9124. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9125. var ws = designer.Workbook.Worksheets[0];
  9126. int Row = List_GC.Count;
  9127. int startIndex = 11;
  9128. int HideRows = 0;
  9129. List<int> hideRowsList = new List<int>();
  9130. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9131. #region A段left数据
  9132. var left = dto.leftInfo.Find(x => x.Type == "A");
  9133. if (left == null)
  9134. {
  9135. return Ok(jw);
  9136. }
  9137. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9138. if (leftBindData != null)
  9139. {
  9140. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9141. designer.SetDataSource("VisaRS", leftBindData.rs);
  9142. designer.SetDataSource("VisaXS", leftBindData.xs);
  9143. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9144. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9145. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9146. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9147. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9148. }
  9149. else
  9150. {
  9151. hideRowsList.Add(Row + startIndex + HideRows);
  9152. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9153. }
  9154. HideRows += 2;
  9155. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9156. if (leftBindData != null)
  9157. {
  9158. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9159. designer.SetDataSource("BXRS", leftBindData.rs);
  9160. designer.SetDataSource("BXXS", leftBindData.xs);
  9161. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9162. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9163. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9164. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9165. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9166. }
  9167. else
  9168. {
  9169. hideRowsList.Add(Row + startIndex + HideRows);
  9170. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9171. }
  9172. HideRows += 2;
  9173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9174. if (leftBindData != null)
  9175. {
  9176. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9177. designer.SetDataSource("HSRS", leftBindData.rs);
  9178. designer.SetDataSource("HSXS", leftBindData.xs);
  9179. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9180. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9181. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9182. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9183. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9184. }
  9185. else
  9186. {
  9187. hideRowsList.Add(Row + startIndex + HideRows);
  9188. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9189. }
  9190. HideRows += 2;
  9191. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9192. if (leftBindData != null)
  9193. {
  9194. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9195. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9196. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9197. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9198. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9199. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9200. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9201. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9202. }
  9203. else
  9204. {
  9205. hideRowsList.Add(Row + startIndex + HideRows);
  9206. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9207. }
  9208. HideRows += 2;
  9209. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9210. if (leftBindData != null)
  9211. {
  9212. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9213. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9214. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9215. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9216. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9217. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9218. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9219. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9220. }
  9221. else
  9222. {
  9223. hideRowsList.Add(Row + startIndex + HideRows);
  9224. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9225. }
  9226. HideRows += 2;
  9227. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9228. if (leftBindData != null)
  9229. {
  9230. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9231. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9232. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9233. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9234. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9235. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9236. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9237. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9238. }
  9239. else
  9240. {
  9241. hideRowsList.Add(Row + startIndex + HideRows);
  9242. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9243. }
  9244. HideRows += 2;
  9245. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9246. if (leftBindData != null)
  9247. {
  9248. ////TBR
  9249. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9250. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9251. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9252. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9253. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9254. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9255. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9256. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9257. }
  9258. else
  9259. {
  9260. hideRowsList.Add(Row + startIndex + HideRows);
  9261. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9262. }
  9263. HideRows += 2;
  9264. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9265. if (leftBindData != null)
  9266. {
  9267. ////SGR
  9268. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9269. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9270. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9271. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9272. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9273. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9274. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9275. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9276. }
  9277. else
  9278. {
  9279. hideRowsList.Add(Row + startIndex + HideRows);
  9280. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9281. }
  9282. HideRows += 2;
  9283. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9284. if (leftBindData != null)
  9285. {
  9286. ////JS/ES
  9287. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9288. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9289. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9290. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9291. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9292. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9293. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9294. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9295. }
  9296. else
  9297. {
  9298. hideRowsList.Add(Row + startIndex + HideRows);
  9299. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9300. }
  9301. HideRows += 2;
  9302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9303. if (leftBindData != null)
  9304. {
  9305. ////SUITE
  9306. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9307. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9308. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9309. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9310. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9311. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9312. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9313. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9314. }
  9315. else
  9316. {
  9317. hideRowsList.Add(Row + startIndex + HideRows);
  9318. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9319. }
  9320. HideRows += 2;
  9321. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9322. if (leftBindData != null)
  9323. {
  9324. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9325. designer.SetDataSource("DJRS", leftBindData.rs);
  9326. designer.SetDataSource("DJXS", leftBindData.xs);
  9327. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9328. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9329. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9330. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9331. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9332. }
  9333. else
  9334. {
  9335. hideRowsList.Add(Row + startIndex + HideRows);
  9336. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9337. }
  9338. HideRows += 2;
  9339. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9340. if (leftBindData != null)
  9341. {
  9342. designer.SetDataSource("HCPCB", leftBindData.cb);
  9343. designer.SetDataSource("HCPRS", leftBindData.rs);
  9344. designer.SetDataSource("HCPXS", leftBindData.xs);
  9345. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9346. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9347. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9348. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9349. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9350. }
  9351. else
  9352. {
  9353. hideRowsList.Add(Row + startIndex + HideRows);
  9354. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9355. }
  9356. HideRows += 2;
  9357. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9358. if (leftBindData != null)
  9359. {
  9360. designer.SetDataSource("CPCB", leftBindData.cb);
  9361. designer.SetDataSource("CPRS", leftBindData.rs);
  9362. designer.SetDataSource("CPXS", leftBindData.xs);
  9363. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9364. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9365. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9366. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9367. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9368. }
  9369. else
  9370. {
  9371. hideRowsList.Add(Row + startIndex + HideRows);
  9372. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9373. }
  9374. HideRows += 2;
  9375. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9376. if (leftBindData != null)
  9377. {
  9378. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9379. designer.SetDataSource("GWRS", leftBindData.rs);
  9380. designer.SetDataSource("GWXS", leftBindData.xs);
  9381. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9382. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9383. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9384. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9385. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9386. }
  9387. else
  9388. {
  9389. hideRowsList.Add(Row + startIndex + HideRows);
  9390. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9391. }
  9392. HideRows += 2;
  9393. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9394. if (leftBindData != null)
  9395. {
  9396. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9397. designer.SetDataSource("LYJRS", leftBindData.rs);
  9398. designer.SetDataSource("LYJXS", leftBindData.xs);
  9399. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9400. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9401. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9402. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9403. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9404. }
  9405. else
  9406. {
  9407. hideRowsList.Add(Row + startIndex + HideRows);
  9408. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9409. }
  9410. #endregion
  9411. #region A段Right信息
  9412. var right = dto.rightInfo.Find(x => x.Type == "A");
  9413. if (right == null)
  9414. {
  9415. return Ok(jw);
  9416. }
  9417. HideRows += 4;
  9418. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9419. if (rightBindData != null)
  9420. {
  9421. //经济舱 + 双人间 TBR
  9422. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9423. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9424. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9425. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9426. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9427. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9428. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9429. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9430. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9431. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9432. }
  9433. else
  9434. {
  9435. hideRowsList.Add(Row + startIndex + HideRows);
  9436. }
  9437. HideRows += 2;
  9438. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9439. if (rightBindData != null)
  9440. {
  9441. //经济舱 + 单人间 SGR
  9442. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9443. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9444. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9445. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9446. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9447. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9448. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9449. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9450. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9451. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9452. }
  9453. else
  9454. {
  9455. hideRowsList.Add(Row + startIndex + HideRows);
  9456. }
  9457. HideRows += 2;
  9458. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9459. if (rightBindData != null)
  9460. {
  9461. //公务舱 + 单人间 SGR
  9462. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9463. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9464. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9465. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9466. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9467. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9468. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9469. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9470. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9471. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9472. }
  9473. else
  9474. {
  9475. hideRowsList.Add(Row + startIndex + HideRows);
  9476. }
  9477. HideRows += 2;
  9478. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9479. if (rightBindData != null)
  9480. {
  9481. //公务舱 + 小套房 JSES
  9482. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9483. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9484. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9485. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9486. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9487. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9488. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9489. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9490. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9491. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9492. }
  9493. else
  9494. {
  9495. hideRowsList.Add(Row + startIndex + HideRows);
  9496. }
  9497. HideRows += 2;
  9498. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9499. if (rightBindData != null)
  9500. {
  9501. //公务舱 + 小套房 JSES
  9502. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9503. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9504. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9505. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9506. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9507. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9508. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9509. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9510. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9511. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9512. }
  9513. else
  9514. {
  9515. hideRowsList.Add(Row + startIndex + HideRows);
  9516. }
  9517. HideRows += 2;
  9518. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9519. if (rightBindData != null)
  9520. {
  9521. //经济舱 + 大套房
  9522. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9523. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9524. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9525. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9526. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9527. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9528. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9529. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9530. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9531. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9532. }
  9533. else
  9534. {
  9535. hideRowsList.Add(Row + startIndex + HideRows);
  9536. }
  9537. HideRows += 2;
  9538. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9539. if (rightBindData != null)
  9540. {
  9541. //头等舱 + 小套房 JSES
  9542. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9543. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9544. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9545. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9546. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9547. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9548. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9549. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9550. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9551. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9552. }
  9553. else
  9554. {
  9555. hideRowsList.Add(Row + startIndex + HideRows);
  9556. }
  9557. HideRows += 2;
  9558. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9559. if (rightBindData != null)
  9560. {
  9561. //头等舱 + 大套房
  9562. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9563. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9564. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9565. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9566. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9567. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9568. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9569. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9570. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9571. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9572. }
  9573. else
  9574. {
  9575. hideRowsList.Add(Row + startIndex + HideRows);
  9576. }
  9577. #endregion
  9578. #region B段标题清空
  9579. designer.SetDataSource("CostBDRCB", "");
  9580. designer.SetDataSource("CostBRS", "");
  9581. designer.SetDataSource("CostBXS", "");
  9582. designer.SetDataSource("CostBZCB", "");
  9583. designer.SetDataSource("CostBDRBJ", "");
  9584. designer.SetDataSource("CostBZBJ", "");
  9585. designer.SetDataSource("CostBDRLR", "");
  9586. designer.SetDataSource("CostBZLR", "");
  9587. designer.SetDataSource("CostBDRCBOM", "");
  9588. designer.SetDataSource("CostBRSOM", "");
  9589. designer.SetDataSource("CostBZCBOM", "");
  9590. designer.SetDataSource("CostBDRBJOM", "");
  9591. designer.SetDataSource("CostBZBJOM", "");
  9592. designer.SetDataSource("CostBDRLROM", "");
  9593. designer.SetDataSource("CostBZLROM", "");
  9594. #endregion
  9595. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9596. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9597. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9598. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9599. designer.SetDataSource("DJName", "地接(CNY)");
  9600. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9601. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9602. designer.SetDataSource("GWName", "公务(CNY)");
  9603. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9604. designer.SetDataSource("LYJName", "零用金(CNY)");
  9605. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9606. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9607. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9608. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9609. designer.SetDataSource("BXName", "保险(CNY)");
  9610. designer.SetDataSource("VisaName", "签证(CNY)");
  9611. #region B段基本数据
  9612. if (dto.costType == "B")
  9613. {
  9614. left = dto.leftInfo.Find(x => x.Type == "B");
  9615. if (left == null)
  9616. {
  9617. return Ok(jw);
  9618. }
  9619. #region B段left数据
  9620. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9621. if (leftBindData != null)
  9622. {
  9623. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9624. designer.SetDataSource("BHSRS", leftBindData.rs);
  9625. designer.SetDataSource("BHSXS", leftBindData.xs);
  9626. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9627. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9628. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9629. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9630. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9631. }
  9632. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9633. if (leftBindData != null)
  9634. {
  9635. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9636. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9637. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9638. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9639. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9640. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9641. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9642. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9643. }
  9644. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9645. if (leftBindData != null)
  9646. {
  9647. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9648. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9649. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9650. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9651. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9652. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9653. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9654. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9655. }
  9656. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9657. if (leftBindData != null)
  9658. {
  9659. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9660. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9661. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9662. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9663. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9664. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9665. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9666. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9667. }
  9668. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9669. if (leftBindData != null)
  9670. {
  9671. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9672. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9673. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9674. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9675. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9676. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9677. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9678. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9679. }
  9680. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9681. if (leftBindData != null)
  9682. {
  9683. designer.SetDataSource("BCPCB", leftBindData.cb);
  9684. designer.SetDataSource("BCPRS", leftBindData.rs);
  9685. designer.SetDataSource("BCPXS", leftBindData.xs);
  9686. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9687. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9688. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9689. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9690. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9691. }
  9692. //TBR
  9693. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9694. if (leftBindData != null)
  9695. {
  9696. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9697. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9698. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9699. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9700. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9701. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9702. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9703. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9704. }
  9705. //SGR
  9706. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9707. if (leftBindData != null)
  9708. {
  9709. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9710. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9711. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9712. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9713. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9714. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9715. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9716. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9717. }
  9718. //JS/ES
  9719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9720. if (leftBindData != null)
  9721. {
  9722. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9723. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9724. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9725. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9726. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9727. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9728. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9729. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9730. }
  9731. //SUITE
  9732. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9733. if (leftBindData != null)
  9734. {
  9735. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9736. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9737. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9738. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9739. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9740. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9741. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9742. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9743. }
  9744. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9745. if (leftBindData != null)
  9746. {
  9747. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  9748. designer.SetDataSource("BDJRS", leftBindData.rs);
  9749. designer.SetDataSource("BDJXS", leftBindData.xs);
  9750. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9751. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9752. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9753. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9754. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9755. }
  9756. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9757. if (leftBindData != null)
  9758. {
  9759. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  9760. designer.SetDataSource("BGWRS", leftBindData.rs);
  9761. designer.SetDataSource("BGWXS", leftBindData.xs);
  9762. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9763. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9764. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9765. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9766. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9767. }
  9768. #region 优化方案
  9769. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9770. //excelBind.Add("零用金", new {
  9771. //cb="",
  9772. //rs="",
  9773. //xs ="",
  9774. //zcb = "",
  9775. //});
  9776. #endregion
  9777. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9778. if (leftBindData != null)
  9779. {
  9780. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9781. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9782. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9783. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9784. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9785. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9786. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9787. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9788. }
  9789. #endregion
  9790. #region B段Right信息
  9791. right = dto.rightInfo.Find(x => x.Type == "B");
  9792. if (right == null)
  9793. {
  9794. return Ok(jw);
  9795. }
  9796. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9797. if (rightBindData != null)
  9798. {
  9799. //经济舱 + 双人间 TBR
  9800. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9801. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9802. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9803. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9804. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9805. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9806. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9807. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9808. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9809. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9810. }
  9811. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9812. if (rightBindData != null)
  9813. {
  9814. //经济舱 + 单人间 SGR
  9815. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9816. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9817. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9818. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9819. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9820. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9821. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9822. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9823. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9824. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9825. }
  9826. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9827. if (rightBindData != null)
  9828. {
  9829. //公务舱 + 单人间 SGR
  9830. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9831. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9832. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9833. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9834. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9835. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9836. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9837. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9838. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9839. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9840. }
  9841. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9842. if (rightBindData != null)
  9843. {
  9844. //公务舱 + 小套房 JSES
  9845. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9846. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9847. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9848. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9849. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9850. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9851. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9852. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9853. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9854. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9855. }
  9856. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9857. if (rightBindData != null)
  9858. {
  9859. //公务舱 + 小套房 JSES
  9860. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9861. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9862. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9863. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9864. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9865. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9866. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9867. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9868. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9869. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9870. }
  9871. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9872. if (rightBindData != null)
  9873. {
  9874. //经济舱 + 大套房
  9875. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9876. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9877. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9878. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9879. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9880. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9881. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9882. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9883. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9884. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9885. }
  9886. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9887. if (rightBindData != null)
  9888. {
  9889. //头等舱 + 小套房 JSES
  9890. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9891. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9892. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9893. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9894. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9895. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9896. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9897. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9898. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9899. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9900. }
  9901. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9902. if (rightBindData != null)
  9903. {
  9904. //头等舱 + 大套房
  9905. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9906. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9907. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9908. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9909. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9910. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9911. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9912. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9913. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9914. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9915. }
  9916. #endregion
  9917. #region 标题
  9918. designer.SetDataSource("CostBDRCB", "单人成本");
  9919. designer.SetDataSource("CostBRS", "人数");
  9920. designer.SetDataSource("CostBXS", "系数");
  9921. designer.SetDataSource("CostBZCB", "总成本");
  9922. designer.SetDataSource("CostBDRBJ", "单人报价");
  9923. designer.SetDataSource("CostBZBJ", "总报价");
  9924. designer.SetDataSource("CostBDRLR", "单人利润");
  9925. designer.SetDataSource("CostBZLR", "总利润");
  9926. designer.SetDataSource("CostBDRCBOM", "单人成本");
  9927. designer.SetDataSource("CostBRSOM", "人数");
  9928. designer.SetDataSource("CostBZCBOM", "总成本");
  9929. designer.SetDataSource("CostBDRBJOM", "单人报价");
  9930. designer.SetDataSource("CostBZBJOM", "总报价");
  9931. designer.SetDataSource("CostBDRLROM", "单人利润");
  9932. designer.SetDataSource("CostBZLROM", "总利润");
  9933. #endregion
  9934. }
  9935. #endregion
  9936. designer.SetDataSource("TzZCB2", TzZCB2);
  9937. designer.SetDataSource("TzZBJ2", TzZBJ2);
  9938. designer.SetDataSource("TzZLR2", TzZLR2);
  9939. string[] dataSourceKeys = new string[]
  9940. {
  9941. "VF",
  9942. "TGS",
  9943. "TGOF",
  9944. "TGM",
  9945. "TGA",
  9946. "TGTF",
  9947. "TGEF",
  9948. "CFM",
  9949. "CFOF",
  9950. "B",
  9951. "L",
  9952. "D",
  9953. "TBR",
  9954. "SGR",
  9955. "JSES",
  9956. "Suite",
  9957. "TV",
  9958. "1L",
  9959. "IF",
  9960. "EF",
  9961. "BRF",
  9962. "TE",
  9963. "TGT",
  9964. "DRVT",
  9965. "PC",
  9966. "TLF",
  9967. "ECT"
  9968. };
  9969. foreach (var item in dataSourceKeys)
  9970. {
  9971. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  9972. if (find != null)
  9973. {
  9974. designer.SetDataSource(item, find.text);
  9975. }
  9976. else
  9977. {
  9978. designer.SetDataSource(item, 0);
  9979. }
  9980. }
  9981. designer.SetDataSource(dt);
  9982. //根据数据源处理生成报表内容
  9983. designer.Process();
  9984. designer.Workbook.Worksheets[0].Name = "清单";
  9985. Worksheet sheet = designer.Workbook.Worksheets[0];
  9986. foreach (var Rowindex in hideRowsList)
  9987. {
  9988. ws.Cells.HideRows(Rowindex, 2);
  9989. }
  9990. byte[] bytes = null;
  9991. string strFileName = di.TeamName + "-团组-成本.xls";
  9992. using (MemoryStream stream = new MemoryStream())
  9993. {
  9994. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  9995. bytes = stream.ToArray();
  9996. }
  9997. return Ok(JsonView(true, "", new
  9998. {
  9999. Data = bytes,
  10000. strFileName,
  10001. }));
  10002. }
  10003. /// <summary>
  10004. /// 导出客户报表
  10005. /// </summary>
  10006. /// <returns></returns>
  10007. [HttpPost]
  10008. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10009. {
  10010. var jw = JsonView(false);
  10011. if (dto.Diid == 0)
  10012. {
  10013. return Ok(JsonView(false, "请传递团组id"));
  10014. }
  10015. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10016. if (deleInfo.Code != 0)
  10017. {
  10018. return Ok(JsonView(false, "团组信息查询失败!"));
  10019. }
  10020. var di = deleInfo.Data as DelegationInfoWebView;
  10021. if (di == null)
  10022. {
  10023. return Ok(JsonView(false, "团组信息查询失败!"));
  10024. }
  10025. //文件名
  10026. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10027. //获取模板
  10028. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10029. //载入模板
  10030. Document doc = new Document(tmppath);
  10031. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10032. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10033. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10034. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10035. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10036. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10037. if (AParameter == null)
  10038. {
  10039. return Ok(JsonView(false, "系数不存在!"));
  10040. }
  10041. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10042. , TzAirDesc, TzZCost;
  10043. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10044. = TzAirDesc = TzZCost = string.Empty;
  10045. TzNumber = AParameter.CostTypenumber.ToString();
  10046. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10047. CarGuides1 = dto.CarGuides1;
  10048. Meal = dto.Meal;
  10049. SubsidizedMeals = dto.SubsidizedMeals;
  10050. NightRepair = dto.NightRepair;
  10051. AttractionsTickets = dto.AttractionsTickets;
  10052. MiscellaneousFees = dto.MiscellaneousFees;
  10053. ATip = dto.ATip;
  10054. TzHotelDesc = "";
  10055. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10056. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10057. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10058. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10059. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10060. TzAirDesc = "";
  10061. TzZCost = dto.TzZCost;
  10062. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10063. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10064. var index = 1;
  10065. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10066. foreach (var item in TzHotelDescArr)
  10067. {
  10068. if (AinfoArr != null)
  10069. {
  10070. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10071. if (Ainfo != null)
  10072. {
  10073. if (int.Parse(Ainfo.rs) <= 0)
  10074. {
  10075. continue;
  10076. }
  10077. var hotelText = string.Empty;
  10078. switch (item)
  10079. {
  10080. case "SGR":
  10081. hotelText = "单人间";
  10082. break;
  10083. case "JSES":
  10084. hotelText = "小套房";
  10085. break;
  10086. case "SUITE":
  10087. hotelText = "套房";
  10088. break;
  10089. case "TBR":
  10090. hotelText = "双人间";
  10091. break;
  10092. }
  10093. if (item != "TBR")
  10094. {
  10095. 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";
  10096. }
  10097. else
  10098. {
  10099. 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";
  10100. }
  10101. index++;
  10102. }
  10103. }
  10104. }
  10105. index = 1;
  10106. foreach (var item in TzAirDescArr)
  10107. {
  10108. if (AinfoArr != null)
  10109. {
  10110. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10111. if (Ainfo != null)
  10112. {
  10113. if (int.Parse(Ainfo.rs) <= 0)
  10114. {
  10115. continue;
  10116. }
  10117. 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";
  10118. index++;
  10119. }
  10120. }
  10121. }
  10122. if (dto.costType == "B")
  10123. {
  10124. if (BParameter == null)
  10125. {
  10126. return Ok(JsonView(false, "B段系数不存在!"));
  10127. }
  10128. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10129. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10130. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10131. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10132. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10133. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10134. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10135. foreach (var item in TzHotelDescArr)
  10136. {
  10137. if (AinfoArr != null)
  10138. {
  10139. TzHotelDesc += "B段信息 \r\n";
  10140. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10141. if (Ainfo != null)
  10142. {
  10143. if (int.Parse(Ainfo.rs) <= 0)
  10144. {
  10145. continue;
  10146. }
  10147. var hotelText = string.Empty;
  10148. switch (item)
  10149. {
  10150. case "SGR":
  10151. hotelText = "单人间";
  10152. break;
  10153. case "JSES":
  10154. hotelText = "小套房";
  10155. break;
  10156. case "SUITE":
  10157. hotelText = "套房";
  10158. break;
  10159. case "TBR":
  10160. hotelText = "双人间";
  10161. break;
  10162. }
  10163. if (item != "TBR")
  10164. {
  10165. 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";
  10166. }
  10167. else
  10168. {
  10169. 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";
  10170. }
  10171. index++;
  10172. }
  10173. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10174. }
  10175. }
  10176. index = 1;
  10177. foreach (var item in TzAirDescArr)
  10178. {
  10179. if (AinfoArr != null)
  10180. {
  10181. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10182. if (Ainfo != null)
  10183. {
  10184. if (int.Parse(Ainfo.rs) <= 0)
  10185. {
  10186. continue;
  10187. }
  10188. 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";
  10189. index++;
  10190. }
  10191. }
  10192. }
  10193. }
  10194. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10195. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10196. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10197. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10198. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10199. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10200. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10201. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10202. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10203. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10204. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10205. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10206. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10207. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10208. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10209. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10210. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10211. DickeyValue.Add("TzZCost", TzZCost);
  10212. foreach (var key in DickeyValue.Keys)
  10213. {
  10214. if (doc.Range.Bookmarks[key] != null)
  10215. {
  10216. Bookmark mark = doc.Range.Bookmarks[key];
  10217. mark.Text = DickeyValue[key];
  10218. }
  10219. }
  10220. byte[] bytes = null;
  10221. string strFileName = di.TeamName + "-客户报价.doc";
  10222. using (MemoryStream stream = new MemoryStream())
  10223. {
  10224. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10225. bytes = stream.ToArray();
  10226. }
  10227. return Ok(JsonView(true, "", new
  10228. {
  10229. Data = bytes,
  10230. strFileName,
  10231. }));
  10232. }
  10233. /// <summary>
  10234. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10235. /// </summary>
  10236. /// <param name="dto"></param>
  10237. /// <returns></returns>
  10238. [HttpPost]
  10239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10240. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10241. {
  10242. try
  10243. {
  10244. #region 参数验证
  10245. if (dto.DiId < 0)
  10246. {
  10247. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10248. }
  10249. List<int> cTableIds = new List<int>() {
  10250. 76 ,//酒店预订
  10251. 77 ,//行程
  10252. 79 ,//车/导游地接
  10253. 80 ,//签证
  10254. 81 ,//邀请/公务活
  10255. 82 ,//团组客户保险
  10256. 85 ,//机票预订
  10257. 98 ,//其他款项
  10258. 285 ,//收款退还
  10259. 751 ,//酒店早餐
  10260. 1015 // 超支费用
  10261. };
  10262. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10263. {
  10264. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10265. }
  10266. #endregion
  10267. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10268. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10269. if (_GroupCostParameters.Count <= 0)
  10270. {
  10271. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10272. }
  10273. if (_GroupCostParameters[0].IsShare == 0)
  10274. {
  10275. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10276. }
  10277. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10278. //处理date为空问题
  10279. if (_GroupCosts.Count > 0)
  10280. {
  10281. for (int i = 0; i < _GroupCosts.Count; i++)
  10282. {
  10283. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10284. {
  10285. if (i > 0)
  10286. {
  10287. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10288. }
  10289. }
  10290. }
  10291. }
  10292. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10293. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10294. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10295. string currCode = "";
  10296. #region currCode 验证
  10297. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10298. if (isInt)
  10299. {
  10300. var currData = currDatas.Find(it => it.Id == intCurrency);
  10301. if (currData != null)
  10302. {
  10303. currCode = currData.Name;
  10304. }
  10305. }
  10306. else
  10307. {
  10308. currCode = _GroupCostParameters[0].Currency.Trim();
  10309. }
  10310. #endregion
  10311. //op,酒店单段模式存储
  10312. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10313. {
  10314. CurrencyCode = currCode,
  10315. Rate = _GroupCostParameters[0].Rate,
  10316. CostType = _GroupCostParameters[0].CostType,
  10317. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10318. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10319. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10320. };
  10321. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10322. if (_GroupCostParameters.Count == 2)
  10323. {
  10324. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10325. }
  10326. foreach (var item in _GroupCostParameters)
  10327. {
  10328. decimal _rate = 1;
  10329. decimal _rate1 = item.Rate;
  10330. decimal _scale = 1;
  10331. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10332. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10333. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10334. //if (userInfo != null)
  10335. //{
  10336. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10337. // {
  10338. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10339. // {
  10340. // _scale = 1.00M;
  10341. // }
  10342. // }
  10343. //}
  10344. #endregion
  10345. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10346. {
  10347. CurrencyCode = currCode,
  10348. Rate = _rate1,
  10349. CostType = item.CostType,
  10350. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10351. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10352. CostTypeNumber = item.CostTypenumber
  10353. };
  10354. if (_GroupCostParameters.Count > 1)
  10355. {
  10356. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10357. }
  10358. else
  10359. {
  10360. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10361. }
  10362. if (dto.CTable == 79)//
  10363. {
  10364. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10365. modulePromptInfo.TotalCost = item.DJCB;
  10366. }
  10367. List<string> costTypes = new List<string>() { "A", "B" };
  10368. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10369. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10370. if (_GroupCostsDuplicates.Count() == 1)
  10371. {
  10372. _GroupCostsTypeData = _GroupCosts;
  10373. }
  10374. else
  10375. {
  10376. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10377. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10378. }
  10379. /*
  10380. * 76 酒店预订
  10381. * 77 行程
  10382. * 79 车/导游地接
  10383. * 80 签证
  10384. * 81 邀请/公务活动
  10385. * 82 团组客户保险
  10386. * 85 机票预订
  10387. * 98 其他款项
  10388. * 285 收款退还
  10389. * 751 酒店早餐
  10390. * 1015 超支费用
  10391. */
  10392. switch (dto.CTable)
  10393. {
  10394. case 76: // 酒店预订
  10395. _ModuleSubPromptInfo.AddRange(
  10396. _GroupCostsTypeData.Select(it => new
  10397. {
  10398. it.DAY,
  10399. it.Date,
  10400. it.ACCON,
  10401. it.ITIN,
  10402. it.SGR,
  10403. it.TBR,
  10404. it.JS_ES,
  10405. it.Suite
  10406. })
  10407. );
  10408. break;
  10409. case 79: // 车/导游地接
  10410. _ModuleSubPromptInfo.AddRange(
  10411. _GroupCostsTypeData.Select(it => new
  10412. {
  10413. Date = it.Date, //日期
  10414. CarFee = it.CarCost * _rate * _scale, //车费用
  10415. CarType = it.CarType, //车型
  10416. DriverFee = it.CFS * _rate * _scale, //司机工资
  10417. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10418. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10419. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10420. GuideFee = it.TGS * _rate * _scale, //导游费用
  10421. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10422. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10423. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10424. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10425. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10426. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10427. Breakfast = it.B * _rate * _scale, //早餐费
  10428. Lunch = it.L * _rate * _scale, //午餐费
  10429. Dinner = it.D * _rate * _scale, //晚餐费
  10430. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10431. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10432. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10433. TicketFee = it.EF * _rate * _scale, //门票费
  10434. TicketRemark = it.EFR, //门票费描述
  10435. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10436. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10437. SpentCash = it.PC * _rate * _scale, //零用金
  10438. LeadersFee = it.TLF * _rate * _scale, //领队费
  10439. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10440. })
  10441. );
  10442. break;
  10443. case 85: // 机票
  10444. List<dynamic> datas = new List<dynamic>();
  10445. datas.Add(
  10446. new
  10447. {
  10448. AirType = "经济舱",
  10449. AirNum = item.JJCRS,
  10450. AirDRCB = item.JJCCB,
  10451. AirZCB = (item.JJCRS * item.JJCCB)
  10452. }
  10453. );
  10454. datas.Add(
  10455. new
  10456. {
  10457. AirType = "公务舱",
  10458. AirNum = item.GWCRS,
  10459. AirDRCB = item.GWCCB,
  10460. AirZCB = (item.GWCRS * item.GWCCB)
  10461. }
  10462. );
  10463. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10464. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10465. modulePromptInfo.Data = new
  10466. {
  10467. airFeeData = datas,
  10468. airInitData = initDatas
  10469. };
  10470. _ModulePromptInfos.Add(modulePromptInfo);
  10471. break;
  10472. default:
  10473. break;
  10474. }
  10475. }
  10476. if (dto.CTable != 85)
  10477. {
  10478. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10479. _ModulePromptInfos.Add(_ModulePromptInfo);
  10480. }
  10481. _view.ModulePromptInfos = _ModulePromptInfos;
  10482. return Ok(JsonView(true, "操作成功!", _view));
  10483. }
  10484. catch (Exception ex)
  10485. {
  10486. return Ok(JsonView(false, ex.Message));
  10487. }
  10488. }
  10489. /// <summary>
  10490. /// 根据黑屏代码重新生成行程
  10491. /// </summary>
  10492. /// <param name="dto"></param>
  10493. /// <returns></returns>
  10494. [HttpPost]
  10495. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10496. {
  10497. var jw = JsonView(false);
  10498. var Create = _GroupCostRepository.
  10499. CreateGroupCostByBlackCode(dto.Diid);
  10500. jw.Msg = Create.Msg;
  10501. if (Create.Code == 0)
  10502. {
  10503. jw.Code = 200;
  10504. jw.Data = new
  10505. {
  10506. groupCost = Create.Data,
  10507. blackCodeIsTrue = true
  10508. };
  10509. }
  10510. else
  10511. {
  10512. jw.Code = 400;
  10513. jw.Data = new
  10514. {
  10515. groupCost = Create.Data,
  10516. blackCodeIsTrue = false,
  10517. };
  10518. }
  10519. return Ok(jw);
  10520. }
  10521. /// <summary>
  10522. /// 成本获取OP历史车费用
  10523. /// </summary>
  10524. /// <param name="dto"></param>
  10525. /// <returns></returns>
  10526. [HttpPost]
  10527. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10528. {
  10529. var jw = JsonView(false);
  10530. try
  10531. {
  10532. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10533. //获取现有所有车的数据
  10534. if (!dto.Param.IsNullOrWhiteSpace())
  10535. {
  10536. string sql = $@"
  10537. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10538. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10539. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10540. 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
  10541. AND gctggr.ServiceEndTime is not NULL
  10542. ORDER by gctggrc.id DESC
  10543. ";
  10544. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10545. var numeberResult = await Task.Run(() =>
  10546. {
  10547. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10548. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10549. return numberArr;
  10550. });
  10551. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10552. foreach (var item in numeberResult)
  10553. {
  10554. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10555. {
  10556. Country = "数据异常!",
  10557. City = string.Empty,
  10558. };
  10559. item.Area = find.Country + " " + find.City;
  10560. }
  10561. dbResult.AddRange(numeberResult);
  10562. if (dto.Param.Contains("、"))
  10563. {
  10564. var sp = dto.Param.Split("、");
  10565. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10566. .Where(x =>
  10567. {
  10568. return System.Array.Exists(sp, e =>
  10569. {
  10570. bool where = false;
  10571. if (x.Area != null)
  10572. {
  10573. where = x.Area.Contains(e);
  10574. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10575. {
  10576. return false;
  10577. }
  10578. }
  10579. if (x.PriceName != null && !where)
  10580. {
  10581. where = x.PriceName.Contains(e);
  10582. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10583. {
  10584. return false;
  10585. }
  10586. }
  10587. return where;
  10588. });
  10589. }).ToList();
  10590. }
  10591. else
  10592. {
  10593. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10594. .Where(x =>
  10595. {
  10596. bool where = false;
  10597. if (x.Area != null)
  10598. {
  10599. where = x.Area.Contains(dto.Param);
  10600. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10601. {
  10602. return false;
  10603. }
  10604. }
  10605. if (x.PriceName != null && !where)
  10606. {
  10607. where = x.PriceName.Contains(dto.Param);
  10608. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10609. {
  10610. return false;
  10611. }
  10612. }
  10613. return where;
  10614. }
  10615. )
  10616. .ToList();
  10617. }
  10618. }
  10619. var view = dbResult.Select(x =>
  10620. {
  10621. decimal dp = 0.00M;
  10622. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10623. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10624. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10625. {
  10626. if (startB && endB)
  10627. {
  10628. var timesp = endD.Subtract(startD);
  10629. if ((timesp.Days + 1) != 0)
  10630. {
  10631. dp = x.Price / (timesp.Days + 1);
  10632. }
  10633. }
  10634. }
  10635. else
  10636. {
  10637. dp = x.Price;
  10638. }
  10639. return new
  10640. {
  10641. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10642. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10643. x.Area,
  10644. x.id,
  10645. price = x.Price.ToString("F2"),
  10646. x.PriceName,
  10647. x.PriceContent,
  10648. x.TeamName,
  10649. x.DatePrice,
  10650. dayPrice = dp.ToString("F2"),
  10651. };
  10652. }).OrderByDescending(x => x.id).ToList();
  10653. jw = JsonView(true, "获取成功!", view);
  10654. }
  10655. catch (Exception e)
  10656. {
  10657. jw = JsonView(false, e.Message);
  10658. }
  10659. return Ok(jw);
  10660. }
  10661. #endregion
  10662. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10663. /// <summary>
  10664. /// 酒店预订
  10665. /// 酒店费用列表 根据团组Id查询
  10666. /// </summary>
  10667. /// <param name="_dto"></param>
  10668. /// <returns></returns>
  10669. [HttpPost]
  10670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10671. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10672. {
  10673. #region 参数验证
  10674. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10675. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10676. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10677. #region 团组操作权限验证 76 酒店预定模块
  10678. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10679. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10680. #endregion
  10681. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10682. #region 页面操作权限验证
  10683. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10684. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10685. #endregion
  10686. #endregion
  10687. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10688. }
  10689. /// <summary>
  10690. /// 酒店预订
  10691. /// 基础数据
  10692. /// </summary>
  10693. /// <param name="_dto"></param>
  10694. /// <returns></returns>
  10695. [HttpPost]
  10696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10697. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10698. {
  10699. #region 参数验证
  10700. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10701. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10702. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10703. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10704. #region 页面操作权限验证
  10705. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10706. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10707. #endregion
  10708. #region 团组操作权限验证 76 酒店预定模块
  10709. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10710. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10711. #endregion
  10712. #endregion
  10713. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10714. }
  10715. /// <summary>
  10716. /// 酒店预订
  10717. /// 创建 入住卷号码
  10718. /// </summary>
  10719. /// <param name="_dto"></param>
  10720. /// <returns></returns>
  10721. [HttpPost]
  10722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10723. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10724. {
  10725. #region 参数验证
  10726. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10727. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10728. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10729. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10730. #region 页面操作权限验证
  10731. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10732. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10733. #endregion
  10734. #region 团组操作权限验证 76 酒店预定模块
  10735. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10736. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10737. #endregion
  10738. #endregion
  10739. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10740. if (data.Code != 0)
  10741. {
  10742. return Ok(JsonView(false, data.Msg));
  10743. }
  10744. return Ok(JsonView(true, data.Msg, data.Data));
  10745. }
  10746. /// <summary>
  10747. /// 酒店预订
  10748. /// 详情
  10749. /// </summary>
  10750. /// <param name="_dto"></param>
  10751. /// <returns></returns>
  10752. [HttpPost]
  10753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10754. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10755. {
  10756. #region 参数验证
  10757. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10758. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10759. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10760. #region 团组操作权限验证 76 酒店预定模块
  10761. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10762. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10763. #endregion
  10764. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10765. #region 页面操作权限验证
  10766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10767. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10768. #endregion
  10769. #endregion
  10770. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10771. }
  10772. /// <summary>
  10773. /// 酒店预订
  10774. /// Add Or Edit
  10775. /// </summary>
  10776. /// <param name="_dto"></param>
  10777. /// <returns></returns>
  10778. [HttpPost]
  10779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10780. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10781. {
  10782. #region 参数验证
  10783. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10784. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10785. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10786. #region 团组操作权限验证 76 酒店预定模块
  10787. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10788. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10789. #endregion
  10790. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10791. #region 页面操作权限验证
  10792. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10793. if (_dto.Id == 0) // Add
  10794. {
  10795. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10796. }
  10797. else if (_dto.Id > 1) // Edit
  10798. {
  10799. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10800. }
  10801. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10802. #endregion
  10803. #endregion
  10804. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10805. if (_view.Code != 200)
  10806. {
  10807. return Ok(_view);
  10808. }
  10809. #region 成本无酒店价格数据进入超支
  10810. _sqlSugar.BeginTran();
  10811. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10812. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10813. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10814. for (int i = 0; i < groupCost.Count; i++)
  10815. {
  10816. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10817. {
  10818. groupCost[i].Date = groupCost[i - 1].Date;
  10819. }
  10820. }
  10821. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10822. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10823. List<Fin_GroupExtraCostDto_OP>();
  10824. if (start_Bool && end_Bool)
  10825. {
  10826. while (start_Time < end_Time)
  10827. {
  10828. foreach (var item in groupCost_Grp)
  10829. {
  10830. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10831. {
  10832. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10833. {
  10834. extraCostList.Add(new
  10835. Fin_GroupExtraCostDto_OP
  10836. {
  10837. Area = _dto.AreaId,
  10838. coefficient = 1.5M,
  10839. createUser = _dto.UserId,
  10840. currency = _dto.CardPriceCurrency,
  10841. diId = _dto.DiId,
  10842. ManagerConfirm = 0,
  10843. SupervisorConfirm = 0,
  10844. SYsupervisorConfirm = 0,
  10845. editType = 1,
  10846. PortType = 1,
  10847. price = _dto.CardPrice,
  10848. PriceCount = 1,
  10849. priceType = 1027,
  10850. priceDetailType = 1044,
  10851. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10852. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10853. });
  10854. }
  10855. }
  10856. }
  10857. start_Time = start_Time.AddDays(1);
  10858. }
  10859. }
  10860. if (extraCostList.Any())
  10861. {
  10862. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10863. }
  10864. _sqlSugar.CommitTran();
  10865. #endregion
  10866. #region 应用推送
  10867. try
  10868. {
  10869. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10870. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10871. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10872. var diId = _dto.DiId;
  10873. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10874. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10875. #region 操作记录
  10876. var opInfo = new Crm_TableOperationRecord() {
  10877. TableName = "Grp_HotelReservations",
  10878. PortType = _dto.PortType,
  10879. DataId = hotelId,
  10880. CreateUserId = _dto.UserId
  10881. };
  10882. var opStatus = OperationEnum.NoOperation;
  10883. if (_dto.Id<1) //添加操作
  10884. {
  10885. opInfo.OperationItem = OperationEnum.Add;
  10886. }
  10887. else if (_dto.Id > 0)
  10888. {
  10889. opInfo.OperationItem = OperationEnum.Edit;
  10890. }
  10891. string opRemark = string.Empty;
  10892. if (ccpInfo != null)
  10893. {
  10894. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10895. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10896. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10897. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10898. }
  10899. opInfo.Remark = opRemark;
  10900. await _tableorRep.AddAsync(opInfo);
  10901. #endregion
  10902. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10903. //2024-10-21 新增LZ UID
  10904. var userIds = new List<int>() { 21 };
  10905. string title = $"费用审核";
  10906. string content = "";
  10907. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10908. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10909. try
  10910. {
  10911. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10912. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  10913. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  10914. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  10915. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  10916. }
  10917. catch (Exception ex )
  10918. {
  10919. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  10920. }
  10921. }
  10922. catch (Exception ex)
  10923. {
  10924. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  10925. }
  10926. try
  10927. {
  10928. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10929. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10930. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10931. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10932. //自动审核
  10933. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  10934. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  10935. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  10936. //2024-10-21 新增LZ UID
  10937. var userIds = new List<int>() { 21 };
  10938. string title = $"系统通知";
  10939. var diId = _dto.DiId;
  10940. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10941. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10942. string content = "";
  10943. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10944. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10945. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10946. }
  10947. catch (Exception ex)
  10948. {
  10949. }
  10950. #endregion
  10951. return Ok(_view);
  10952. }
  10953. /// <summary>
  10954. /// 酒店自动审核测试
  10955. /// Add Or Edit
  10956. /// </summary>
  10957. /// <param name="_dto"></param>
  10958. /// <returns></returns>
  10959. [HttpPost]
  10960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10961. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  10962. {
  10963. #region 应用推送
  10964. try
  10965. {
  10966. //自动审核
  10967. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  10968. }
  10969. catch (Exception ex)
  10970. {
  10971. return Ok(JsonView(false, "操作失败"));
  10972. }
  10973. #endregion
  10974. return Ok(JsonView(false, "操作成功"));
  10975. }
  10976. /// <summary>
  10977. /// 酒店预订
  10978. /// Del
  10979. /// </summary>
  10980. /// <param name="_dto"></param>
  10981. /// <returns></returns>
  10982. [HttpPost]
  10983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10984. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  10985. {
  10986. #region 参数验证
  10987. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10988. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10989. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10990. #region 团组操作权限验证 76 酒店预定模块
  10991. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10992. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10993. #endregion
  10994. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10995. #region 页面操作权限验证
  10996. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10997. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10998. #endregion
  10999. #endregion
  11000. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  11001. #region 操作记录
  11002. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11003. {
  11004. TableName = "Grp_HotelReservations",
  11005. PortType = _dto.PortType,
  11006. OperationItem = OperationEnum.Del,
  11007. DataId = _dto.Id,
  11008. CreateUserId = _dto.UserId
  11009. });
  11010. #endregion
  11011. return Ok(data);
  11012. }
  11013. /// <summary>
  11014. /// 酒店预订
  11015. /// 生成VOUCHER
  11016. /// 2024.05.06 之前版本
  11017. /// </summary>
  11018. /// <param name="_dto"></param>
  11019. /// <returns></returns>
  11020. [HttpPost]
  11021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11022. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11023. {
  11024. try
  11025. {
  11026. #region 参数验证
  11027. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11028. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11029. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11030. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11031. #region 团组操作权限验证 76 酒店预定模块
  11032. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11033. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11034. #endregion
  11035. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11036. #region 页面操作权限验证
  11037. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11038. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11039. #endregion
  11040. #endregion
  11041. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11042. //判断数据是否完整
  11043. if (hr != null)
  11044. {
  11045. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11046. {
  11047. string strFileName = "HotelStatement/";
  11048. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11049. if (dele != null)
  11050. strFileName += dele.TourCode;
  11051. //载入模板
  11052. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11053. Document doc = new Document(sss);
  11054. DocumentBuilder builder = new DocumentBuilder(doc);
  11055. #region 替换Word模板书签内容
  11056. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11057. //入住卷预定号码
  11058. if (doc.Range.Bookmarks["VNO"] != null)
  11059. {
  11060. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11061. mark.Text = hr.CheckNumber;
  11062. }
  11063. //酒店时间
  11064. if (doc.Range.Bookmarks["Date"] != null)
  11065. {
  11066. Bookmark mark = doc.Range.Bookmarks["Date"];
  11067. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11068. }
  11069. //团号
  11070. if (doc.Range.Bookmarks["TNo"] != null)
  11071. {
  11072. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11073. mark.Text = dele.TourCode;
  11074. }
  11075. //预定号码
  11076. if (doc.Range.Bookmarks["BookingId"] != null)
  11077. {
  11078. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11079. mark.Text = hr.ReservationsNo;
  11080. }
  11081. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11082. {
  11083. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11084. mark.Text = hr.DetermineNo;
  11085. }
  11086. //酒店城市
  11087. if (doc.Range.Bookmarks["City"] != null)
  11088. {
  11089. Bookmark mark = doc.Range.Bookmarks["City"];
  11090. mark.Text = hr.City;
  11091. }
  11092. //酒店名称
  11093. if (doc.Range.Bookmarks["HName"] != null)
  11094. {
  11095. Bookmark mark = doc.Range.Bookmarks["HName"];
  11096. mark.Text = hr.HotelName;
  11097. }
  11098. //酒店地址
  11099. if (doc.Range.Bookmarks["Address"] != null)
  11100. {
  11101. Bookmark mark = doc.Range.Bookmarks["Address"];
  11102. mark.Text = hr.HotelAddress;
  11103. }
  11104. //酒店电话
  11105. if (doc.Range.Bookmarks["Tel"] != null)
  11106. {
  11107. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11108. mark.Text = hr.HotelTel;
  11109. }
  11110. //酒店传真
  11111. if (doc.Range.Bookmarks["Fax"] != null)
  11112. {
  11113. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11114. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11115. {
  11116. mark.Text = hr.HotelFax;
  11117. }
  11118. }
  11119. //入住时间
  11120. if (doc.Range.Bookmarks["CIn"] != null)
  11121. {
  11122. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11123. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11124. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11125. }
  11126. //退房时间
  11127. if (doc.Range.Bookmarks["COut"] != null)
  11128. {
  11129. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11130. Bookmark mark = doc.Range.Bookmarks["COut"];
  11131. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11132. }
  11133. //客户名称
  11134. if (doc.Range.Bookmarks["GName"] != null)
  11135. {
  11136. string guestName = "";
  11137. string[] clients = new string[] { };
  11138. if (hr.GuestName.Contains(","))
  11139. {
  11140. clients = hr.GuestName.Split(",");
  11141. }
  11142. else
  11143. {
  11144. clients = new string[] { hr.GuestName };
  11145. }
  11146. List<int> clientIds_int = new List<int>();
  11147. if (clients.Length > 0)
  11148. {
  11149. foreach (var item in clients)
  11150. {
  11151. if (item.IsNumeric())
  11152. {
  11153. clientIds_int.Add(int.Parse(item));
  11154. }
  11155. }
  11156. }
  11157. if (clientIds_int.Count > 0)
  11158. {
  11159. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11160. foreach (var client in _clientDatas)
  11161. {
  11162. //男
  11163. if (client.Sex == 0) guestName += $"Mr.";
  11164. //女
  11165. else if (client.Sex == 1) guestName += $"Ms.";
  11166. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11167. {
  11168. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11169. }
  11170. //guestName += $"{client.Pinyin},";
  11171. }
  11172. if (guestName.Length > 0)
  11173. {
  11174. guestName = guestName.Substring(0, guestName.Length - 1);
  11175. }
  11176. }
  11177. else
  11178. {
  11179. guestName = hr.GuestName;
  11180. }
  11181. Bookmark mark = doc.Range.Bookmarks["GName"];
  11182. mark.Text = guestName;
  11183. }
  11184. //房间介绍
  11185. if (doc.Range.Bookmarks["ROOM"] != null)
  11186. {
  11187. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11188. mark.Text = hr.RoomExplanation;
  11189. }
  11190. //报价描述
  11191. if (doc.Range.Bookmarks["NOTE"] != null)
  11192. {
  11193. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11194. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11195. if (ss != null)
  11196. mark.Text = ss.Name;
  11197. }
  11198. //入住时间
  11199. if (doc.Range.Bookmarks["CheckIn"] != null)
  11200. {
  11201. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11202. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11203. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11204. }
  11205. //退房时间
  11206. if (doc.Range.Bookmarks["CheckOut"] != null)
  11207. {
  11208. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11209. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11210. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11211. }
  11212. //日期
  11213. if (doc.Range.Bookmarks["DT"] != null)
  11214. {
  11215. Bookmark mark = doc.Range.Bookmarks["DT"];
  11216. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11217. }
  11218. //名称
  11219. if (doc.Range.Bookmarks["VName"] != null)
  11220. {
  11221. Bookmark mark = doc.Range.Bookmarks["VName"];
  11222. mark.Text = hr.HotelName;
  11223. }
  11224. //号码
  11225. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11226. {
  11227. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11228. mark.Text = hr.CheckNumber;
  11229. }
  11230. #endregion
  11231. strFileName += "VOUCHER.doc";
  11232. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11233. doc.Save(fileDir);
  11234. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11235. return Ok(JsonView(true, "操作成功!", Url));
  11236. }
  11237. else
  11238. {
  11239. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11240. }
  11241. }
  11242. else
  11243. {
  11244. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11245. }
  11246. }
  11247. catch (Exception ex)
  11248. {
  11249. return Ok(JsonView(false, ex.Message));
  11250. }
  11251. }
  11252. /// <summary>
  11253. /// 酒店预订
  11254. /// 生成VOUCHER
  11255. /// 2024.05.06 之后版本
  11256. /// </summary>
  11257. /// <param name="_dto"></param>
  11258. /// <returns></returns>
  11259. [HttpPost]
  11260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11261. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11262. {
  11263. #region 参数验证
  11264. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11265. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11266. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11267. #region 团组操作权限验证 76 酒店预定模块
  11268. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11269. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11270. #endregion
  11271. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11272. #region 页面操作权限验证
  11273. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11274. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11275. #endregion
  11276. #endregion
  11277. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11278. //判断数据是否完整
  11279. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11280. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11281. string strFileName = "HotelStatement/";
  11282. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11283. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11284. #region 数据处理
  11285. List<int> guestIds = new List<int>();
  11286. int index = 0;
  11287. foreach (var item in hrDtas)
  11288. {
  11289. if (item.GuestName.Contains(","))
  11290. {
  11291. string[] guestIdArr = item.GuestName.Split(',');
  11292. foreach (var guestIdStr in guestIdArr)
  11293. {
  11294. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11295. if (guestBool)
  11296. {
  11297. guestIds.Add(guestId);
  11298. }
  11299. }
  11300. }
  11301. else guestNames += item.GuestName;
  11302. var voucherInfo = new HotelVoucherInfoView()
  11303. {
  11304. HotelName = item.HotelName,
  11305. CheckInDate = item.CheckInDate,
  11306. CheckOutDate = item.CheckOutDate,
  11307. ConfirmationNumber = item.DetermineNo.Trim(),
  11308. RoomType = item.RoomExplanation
  11309. };
  11310. vouchers.Add(voucherInfo);
  11311. }
  11312. if (guestIds.Count > 0)
  11313. {
  11314. guestIds = guestIds.Distinct().ToList();
  11315. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11316. if (guestDatas.Count > 0)
  11317. {
  11318. guestNames = "";
  11319. foreach (var guest in guestDatas)
  11320. {
  11321. string guestName = "";
  11322. if (guest.Sex == 0) guestName += @"MR.";
  11323. else if (guest.Sex == 1) guestName += @"MS.";
  11324. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11325. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11326. guestNames += @$"{guestName.Trim()}、";
  11327. }
  11328. if (guestNames.Length > 0)
  11329. {
  11330. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11331. }
  11332. }
  11333. }
  11334. #endregion
  11335. //载入模板
  11336. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11337. Document doc = new Document(sss);
  11338. DocumentBuilder builder = new DocumentBuilder(doc);
  11339. if (doc.Range.Bookmarks["GuestName"] != null)
  11340. {
  11341. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11342. mark.Text = guestNames;
  11343. }
  11344. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11345. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11346. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11347. for (int i = 1; i <= vouchers.Count; i++)
  11348. {
  11349. HotelVoucherInfoView hviv = vouchers[i - 1];
  11350. builder.MoveToCell(0, i, 0, 0);
  11351. builder.Write(hviv.HotelName);
  11352. builder.MoveToCell(0, i, 1, 0);
  11353. builder.Write(hviv.CheckInDate);
  11354. builder.MoveToCell(0, i, 2, 0);
  11355. builder.Write(hviv.CheckOutDate);
  11356. builder.MoveToCell(0, i, 3, 0);
  11357. builder.Write(hviv.RoomType);
  11358. builder.MoveToCell(0, i, 4, 0);
  11359. builder.Write(hviv.ConfirmationNumber);
  11360. }
  11361. //删除多余行
  11362. int currRowIndex = vouchers.Count + 1;
  11363. int delRows = 21 - currRowIndex;
  11364. if (delRows > 0)
  11365. {
  11366. for (int i = 0; i < delRows; i++)
  11367. {
  11368. table.Rows.RemoveAt(currRowIndex);
  11369. //cultivateRowIndex++;
  11370. }
  11371. }
  11372. strFileName += "VOUCHER.docx";
  11373. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11374. doc.Save(fileDir);
  11375. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11376. return Ok(JsonView(true, "操作成功!", Url));
  11377. }
  11378. /// <summary>
  11379. /// 酒店预订
  11380. /// 生成VOUCHER 批量生成
  11381. /// New
  11382. /// </summary>
  11383. /// <param name="_dto"></param>
  11384. /// <returns></returns>
  11385. [HttpPost]
  11386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11387. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11388. {
  11389. #region 参数验证
  11390. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11391. if (_dto.PageId < 1) _dto.PageId = 28;
  11392. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11393. #region 团组操作权限验证 76 酒店预定模块
  11394. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11395. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11396. #endregion
  11397. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11398. #region 页面操作权限验证
  11399. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11400. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11401. #endregion
  11402. #endregion
  11403. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11404. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11405. .OrderBy(x => x.CheckInDate)
  11406. .ToListAsync();
  11407. //判断数据是否完整
  11408. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11409. string strFileName = "HotelStatement/";
  11410. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11411. if (dele != null)
  11412. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11413. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  11414. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  11415. .Where(it => it.IsDel == 0)
  11416. .ToListAsync();
  11417. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  11418. for (int i = 0; i < hrDtas.Count; i++)
  11419. {
  11420. string guestNames = string.Empty;
  11421. List<int> guestIds = new List<int>();
  11422. var item = hrDtas[i];
  11423. //处理客户姓名
  11424. if (item.GuestName.Contains(","))
  11425. {
  11426. string[] guestIdArr = item.GuestName.Split(',');
  11427. foreach (var guestIdStr in guestIdArr)
  11428. if (int.TryParse(guestIdStr, out int guestId))
  11429. guestIds.Add(guestId);
  11430. }
  11431. else
  11432. {
  11433. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11434. if (guestIdBool)
  11435. {
  11436. guestIds.Add(guestId);
  11437. }
  11438. //NaN
  11439. if (item.GuestName.Contains("NaN"))
  11440. {
  11441. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11442. }
  11443. }
  11444. if (guestIds.Count > 0)
  11445. {
  11446. guestIds = guestIds.Distinct().ToList();
  11447. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11448. if (guestDatas1.Count > 0)
  11449. {
  11450. guestNames = "";
  11451. foreach (var guest in guestDatas1)
  11452. {
  11453. string guestName = "";
  11454. if (guest.Sex == 0) guestName += @"MR.";
  11455. else if (guest.Sex == 1) guestName += @"MS.";
  11456. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11457. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11458. guestNames += @$"{guestName.Trim()}、";
  11459. }
  11460. if (guestNames.Length > 0)
  11461. {
  11462. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11463. }
  11464. }
  11465. }
  11466. //if (!string.IsNullOrEmpty(guestNames))
  11467. //{
  11468. hrDtas[i].GuestName = guestNames;
  11469. //}
  11470. }
  11471. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11472. Document doc = new Document();
  11473. DocumentBuilder builder = new DocumentBuilder(doc);
  11474. try
  11475. {
  11476. builder.MoveToDocumentStart();
  11477. foreach (var item in hrDtas)
  11478. {
  11479. //标题
  11480. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11481. builder.ParagraphFormat.LineSpacing = 1;
  11482. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11483. builder.ParagraphFormat.Style.Font.Size = 9;
  11484. builder.ParagraphFormat.Style.Font.Bold = true;
  11485. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11486. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11487. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11488. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11489. builder.ParagraphFormat.LineSpacing = 1;
  11490. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11491. builder.ParagraphFormat.Style.Font.Size = 9;
  11492. builder.ParagraphFormat.Style.Font.Bold = true;
  11493. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11494. builder.StartTable();
  11495. // 设置边框颜色
  11496. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11497. //设置边框样式
  11498. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11499. //表格
  11500. #region 第一行
  11501. builder.InsertCell();
  11502. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11503. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11504. //builder.CellFormat.AllowAutoFit = false;
  11505. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11506. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11507. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11508. builder.CellFormat.WrapText = true; //自动换行
  11509. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11510. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11511. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11512. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11513. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11514. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11515. builder.Write("TOUR NO:");
  11516. builder.InsertCell();
  11517. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11518. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11519. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11520. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11521. builder.ParagraphFormat.Style.Font.Bold = false;
  11522. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11523. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11524. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11525. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11526. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11527. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11528. builder.Write($"{dele?.TourCode ?? "-"}");
  11529. builder.InsertCell();
  11530. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11531. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11532. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11533. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11534. builder.ParagraphFormat.Style.Font.Bold = false;
  11535. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11536. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11537. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11538. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11539. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11540. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11541. builder.Write($"CITY:");
  11542. builder.InsertCell();
  11543. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11544. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11545. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11546. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11547. builder.ParagraphFormat.Style.Font.Bold = false;
  11548. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11549. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11550. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11551. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11552. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11553. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11554. builder.Write($"{item.City}");
  11555. builder.EndRow();
  11556. #endregion
  11557. #region 第二行
  11558. builder.InsertCell();
  11559. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11560. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11561. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11562. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11563. builder.ParagraphFormat.Style.Font.Bold = false;
  11564. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11565. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11566. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11567. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11568. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11569. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11570. builder.Write("CONFIRMATION NO:");
  11571. builder.InsertCell();
  11572. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11573. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11574. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11575. builder.ParagraphFormat.Style.Font.Bold = false;
  11576. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11577. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11578. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11579. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11580. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11581. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11582. builder.CellFormat.VerticalMerge = CellMerge.None;
  11583. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11584. builder.Write($"{item.DetermineNo}");
  11585. builder.InsertCell();
  11586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11587. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11588. builder.InsertCell();
  11589. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11590. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11591. builder.EndRow();
  11592. #endregion
  11593. #region 第三行
  11594. builder.InsertCell();
  11595. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11596. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11597. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11598. builder.ParagraphFormat.Style.Font.Bold = false;
  11599. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11600. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11601. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11602. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11603. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11604. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11605. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11606. builder.Write($"HOTEL NAME:");
  11607. builder.InsertCell();
  11608. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11610. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11611. builder.ParagraphFormat.Style.Font.Bold = false;
  11612. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11613. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11614. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11615. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11616. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11617. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11618. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11619. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11620. builder.Write($"{item.HotelName}");
  11621. builder.InsertCell();
  11622. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11623. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11624. builder.InsertCell();
  11625. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11626. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11627. builder.EndRow();
  11628. #endregion
  11629. #region 第四行
  11630. builder.InsertCell();
  11631. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11632. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11633. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11634. builder.ParagraphFormat.Style.Font.Bold = false;
  11635. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11636. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11637. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11638. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11639. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11640. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11641. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11642. builder.Write($"HOTEL ADDRESS:");
  11643. builder.InsertCell();
  11644. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11645. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11646. builder.ParagraphFormat.Style.Font.Size = 8;
  11647. builder.ParagraphFormat.Style.Font.Bold = false;
  11648. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11649. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11650. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11651. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11652. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11653. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11654. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11655. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11656. builder.Write($"{item.HotelAddress}");
  11657. builder.InsertCell();
  11658. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11659. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11660. builder.InsertCell();
  11661. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11662. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11663. builder.EndRow();
  11664. #endregion
  11665. #region 第五行
  11666. builder.InsertCell();
  11667. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11668. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11669. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11670. builder.ParagraphFormat.Style.Font.Bold = false;
  11671. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11672. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11673. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11674. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11675. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11676. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11677. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11678. builder.Write("TEL:");
  11679. builder.InsertCell();
  11680. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11681. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11682. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11683. builder.ParagraphFormat.Style.Font.Bold = false;
  11684. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11685. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11686. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11687. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11688. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11689. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11690. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11691. builder.Write($"{item.HotelTel}");
  11692. builder.InsertCell();
  11693. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11694. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11695. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11696. builder.ParagraphFormat.Style.Font.Bold = false;
  11697. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11698. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11699. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11700. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11701. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11702. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11703. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11704. builder.Write($"FAX:");
  11705. builder.InsertCell();
  11706. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11707. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11708. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11709. builder.ParagraphFormat.Style.Font.Bold = false;
  11710. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11711. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11712. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11713. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11714. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11715. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11716. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11717. builder.Write($"{item.HotelFax}");
  11718. builder.EndRow();
  11719. #endregion
  11720. #region 第六行
  11721. builder.InsertCell();
  11722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11723. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11724. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11725. builder.ParagraphFormat.Style.Font.Bold = false;
  11726. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11733. builder.Write("CHECK IN:");
  11734. builder.InsertCell();
  11735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11737. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11738. builder.ParagraphFormat.Style.Font.Bold = false;
  11739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11746. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11747. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11748. builder.Write($"{checkInStr}");
  11749. builder.InsertCell();
  11750. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11751. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11752. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11753. builder.ParagraphFormat.Style.Font.Bold = false;
  11754. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11755. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11756. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11757. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11758. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11759. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11760. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11761. builder.Write($"CHECK OUT:");
  11762. builder.InsertCell();
  11763. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11764. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11765. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11766. builder.ParagraphFormat.Style.Font.Bold = false;
  11767. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11768. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11769. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11770. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11771. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11772. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11773. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11774. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11775. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11776. builder.Write($"{checkOutStr}");
  11777. builder.EndRow();
  11778. #endregion
  11779. #region 第七行
  11780. builder.InsertCell();
  11781. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11782. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11783. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11784. builder.ParagraphFormat.Style.Font.Bold = false;
  11785. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11786. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11787. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11788. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11789. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11790. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11791. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11792. builder.Write($"GUEST NAME:");
  11793. builder.InsertCell();
  11794. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11795. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11796. builder.ParagraphFormat.Style.Font.Size = 8;
  11797. builder.ParagraphFormat.Style.Font.Bold = false;
  11798. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11799. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11801. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11802. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11803. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11804. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11805. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11806. builder.Write($"{item.GuestName}");
  11807. builder.InsertCell();
  11808. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11809. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11810. builder.InsertCell();
  11811. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11812. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11813. builder.EndRow();
  11814. #endregion
  11815. #region 第八行
  11816. builder.InsertCell();
  11817. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11818. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11819. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11820. builder.ParagraphFormat.Style.Font.Bold = false;
  11821. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11822. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11823. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11824. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11825. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11826. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11827. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11828. builder.Write($"ROOM TYPE:");
  11829. builder.InsertCell();
  11830. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11831. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11832. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11833. builder.ParagraphFormat.Style.Font.Bold = false;
  11834. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11835. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11836. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11837. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11838. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11839. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11840. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11841. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11842. builder.Write($"{item.RoomExplanation}");
  11843. builder.InsertCell();
  11844. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11845. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11846. builder.InsertCell();
  11847. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11848. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11849. builder.EndRow();
  11850. #endregion
  11851. #region 第九行
  11852. builder.InsertCell();
  11853. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11854. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11855. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11856. builder.ParagraphFormat.Style.Font.Bold = false;
  11857. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11858. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11859. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11860. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11861. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11862. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11863. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11864. builder.Write($"NOTE:");
  11865. builder.InsertCell();
  11866. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11867. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11868. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11869. builder.ParagraphFormat.Style.Font.Bold = false;
  11870. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11871. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11872. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11873. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11874. 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.");
  11875. builder.InsertCell();
  11876. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11877. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11878. builder.InsertCell();
  11879. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11880. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11881. builder.EndRow();
  11882. #endregion
  11883. builder.EndTable();
  11884. //换行
  11885. builder.Writeln("");
  11886. builder.Writeln("");
  11887. }
  11888. #region 获取文档中的所有表格 设置文字自适应
  11889. // 获取文档中的所有表格。
  11890. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11891. {
  11892. // 遍历表格中的所有行。
  11893. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11894. {
  11895. foreach (Cell cell in row.Cells)
  11896. {
  11897. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11898. cellFormat.Width = 0;
  11899. }
  11900. }
  11901. }
  11902. #endregion
  11903. #region 设置页眉
  11904. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11905. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11906. if (System.IO.File.Exists(voucherHeaderPath))
  11907. {
  11908. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11909. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11910. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11911. Shape shape = builder.InsertImage(imageBytes);
  11912. // 调整图片位置
  11913. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  11914. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  11915. shape.Top = 50; // 将图片距离页眉上边缘的距离
  11916. shape.Left = 0; // 将图片距离页面左边缘的距离
  11917. shape.Width = 81; // 设置图片宽度
  11918. shape.Height = 36; // 设置图片高度
  11919. }
  11920. //靠右
  11921. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  11922. //// 设置页脚上下边距
  11923. //builder.PageSetup.HeaderDistance = 42;
  11924. // 添加页眉线
  11925. Aspose.Words.Border borderHeader = null;
  11926. try
  11927. {
  11928. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  11929. }
  11930. catch (Exception e)
  11931. {
  11932. // TODO Auto-generated catch block
  11933. //e.printStackTrace();
  11934. }
  11935. borderHeader.Shadow = true;
  11936. borderHeader.DistanceFromText = 2;
  11937. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  11938. #endregion
  11939. }
  11940. catch (Exception ex)
  11941. {
  11942. }
  11943. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11944. doc.Save(fileDir);
  11945. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11946. return Ok(JsonView(true, "操作成功!", Url));
  11947. }
  11948. /// <summary>
  11949. /// 酒店预订
  11950. /// 生成 预定成本 Excel
  11951. /// </summary>
  11952. /// <param name="_dto"></param>
  11953. /// <returns></returns>
  11954. [HttpPost]
  11955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11956. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  11957. {
  11958. #region 参数验证
  11959. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  11960. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  11961. if (!vadalitorRes.IsValid)
  11962. {
  11963. var errors = new StringBuilder();
  11964. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  11965. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  11966. }
  11967. #region 团组操作权限验证 76 酒店预定模块
  11968. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11969. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11970. #endregion
  11971. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11972. #region 页面操作权限验证
  11973. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11974. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11975. #endregion
  11976. #endregion
  11977. decimal _rate = 1.00M;
  11978. string _currency = string.Empty;
  11979. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  11980. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11981. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  11982. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11983. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  11984. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  11985. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  11986. if (_GroupCostParameter == null)
  11987. {
  11988. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  11989. bool isIntType = int.TryParse(_currency, out int currId);
  11990. if (isIntType)
  11991. {
  11992. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11993. }
  11994. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11995. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11996. if (currInfo == null)
  11997. {
  11998. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11999. }
  12000. else _rate = currInfo.Rate;
  12001. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12002. {
  12003. _rate = _GroupCostParameter.Rate;
  12004. }
  12005. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12006. string strFileName = "HotelStatement/";
  12007. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12008. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12009. var rateDatas = new List<dynamic>();
  12010. #region 数据处理
  12011. foreach (var item in hrDtas)
  12012. {
  12013. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12014. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12015. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12016. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12017. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12018. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12019. {
  12020. continue;
  12021. }
  12022. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12023. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12024. string singleRoomFeeStr = string.Empty,
  12025. doubleRoomFeeStr = string.Empty,
  12026. suiteRoomFeeStr = string.Empty,
  12027. otherRoomFeeStr = string.Empty,
  12028. payMoneyStr = string.Empty,
  12029. cardPriceStr = string.Empty;
  12030. if (roomCurr.Equals("CNY"))
  12031. {
  12032. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12033. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12034. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12035. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12036. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12037. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12038. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12039. }
  12040. else
  12041. {
  12042. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12043. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12044. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12045. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12046. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12047. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12048. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12049. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12050. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12051. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12052. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12053. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12054. if (ccpPaymentCurrency.Equals("CNY"))
  12055. {
  12056. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12057. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12058. }
  12059. else
  12060. {
  12061. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12062. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12063. }
  12064. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12065. if (hotelcardPriceCurrency.Equals("CNY"))
  12066. {
  12067. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12068. }
  12069. else
  12070. {
  12071. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12072. }
  12073. }
  12074. string breakfastPriceStr = string.Empty,
  12075. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12076. governmentRentStr = string.Empty,
  12077. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12078. cityTaxStr = string.Empty,
  12079. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12080. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12081. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12082. {
  12083. if (breakfastCurrency1.Equals("CNY"))
  12084. {
  12085. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12086. }
  12087. else
  12088. {
  12089. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12090. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12091. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12092. }
  12093. }
  12094. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12095. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12096. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12097. {
  12098. if (governmentRentCurrency.Equals("CNY"))
  12099. {
  12100. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12101. }
  12102. else
  12103. {
  12104. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12105. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12106. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12107. }
  12108. }
  12109. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12110. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12111. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12112. {
  12113. if (cityTaxStrCurrency1.Equals("CNY"))
  12114. {
  12115. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12116. }
  12117. else
  12118. {
  12119. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12120. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12121. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12122. }
  12123. }
  12124. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12125. int payDId = roomInfo?.PayDId ?? 0;
  12126. pcfds.Add(new HotelReservations_PCFD_View()
  12127. {
  12128. City = item.City,
  12129. HotelName = item.HotelName,
  12130. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12131. // SingleRoomCount = item.SingleRoomCount,
  12132. SingleRoomPrice = singleRoomFeeStr,
  12133. // DoubleRoomCount = item.DoubleRoomCount,
  12134. DoubleRoomPrice = doubleRoomFeeStr,
  12135. //SuiteRoomCount = item.SuiteRoomCount,
  12136. SuiteRoomPrice = suiteRoomFeeStr,
  12137. OtherRoomPrice = otherRoomFeeStr,
  12138. //OtherRoomCount = item.OtherRoomCount,
  12139. BreakfastPrice = breakfastPriceStr,
  12140. GovernmentRent = governmentRentStr,
  12141. CityTax = cityTaxStr,
  12142. RoomExplanation = item.RoomExplanation,
  12143. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12144. PayTime = roomInfo?.ConsumptionDate,
  12145. BankNo = roomInfo?.BankNo,
  12146. PayMoney = payMoneyStr,
  12147. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12148. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12149. CardPrice = cardPriceStr,
  12150. Remark = ccpInfo.Remark
  12151. });
  12152. }
  12153. #endregion
  12154. //载入模板
  12155. WorkbookDesigner designer = new WorkbookDesigner();
  12156. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12157. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12158. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12159. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12160. var rateDatas1 = rateDatas.Distinct();
  12161. var rateStr = string.Empty;
  12162. foreach (var item in rateDatas1)
  12163. {
  12164. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12165. }
  12166. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12167. designer.SetDataSource("Opertor", userInfo.CnName);
  12168. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12169. dt.TableName = "ViewMyHotelReservations";
  12170. designer.SetDataSource(dt);
  12171. designer.Process();
  12172. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12173. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12174. designer.Workbook.Save(serverPath);
  12175. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12176. #region 删除指定行
  12177. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12178. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12179. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12180. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12181. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12182. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12183. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12184. cssIndex = dt.Columns["CityTax"].Ordinal,
  12185. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12186. remarkIndex = dt.Columns["Remark"].Ordinal;
  12187. //删除指定列
  12188. foreach (DataRow item in dt.Rows)
  12189. {
  12190. string singleStr = item["SingleRoomPrice"].ToString();
  12191. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12192. if (containsDigitButNotZero1) singleDel = false;
  12193. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12194. string doubleStr = item["DoubleRoomPrice"].ToString();
  12195. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12196. if (containsDigitButNotZero2) doubleDel = false;
  12197. string suiteStr = item["SuiteRoomPrice"].ToString();
  12198. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12199. if (containsDigitButNotZero3) suiteDel = false;
  12200. string otherStr = item["OtherRoomPrice"].ToString();
  12201. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12202. if (containsDigitButNotZero4) otherDel = false;
  12203. string zcStr = item["BreakfastPrice"].ToString();
  12204. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12205. if (containsDigitButNotZero5) zcDel = false;
  12206. string dsStr = item["GovernmentRent"].ToString();
  12207. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12208. if (containsDigitButNotZero6) dsDel = false;
  12209. string cssStr = item["CityTax"].ToString();
  12210. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12211. if (containsDigitButNotZero7) cssDel = false;
  12212. string cpStr = item["ConsumptionPatterns"].ToString();
  12213. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12214. string remarkStr = item["Remark"].ToString();
  12215. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12216. }
  12217. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12218. DeleteColumn(serverPath, cpIndex, cpDel);
  12219. DeleteColumn(serverPath, dsIndex, dsDel);
  12220. DeleteColumn(serverPath, cssIndex, cssDel);
  12221. DeleteColumn(serverPath, zcIndex, zcDel);
  12222. DeleteColumn(serverPath, otherIndex, otherDel);
  12223. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12224. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12225. DeleteColumn(serverPath, singleIndex, singleDel);
  12226. #endregion
  12227. //只保留第一个表格
  12228. DeleteSheet(serverPath);
  12229. return Ok(JsonView(true, "操作成功", url = rst));
  12230. }
  12231. else
  12232. {
  12233. _currency = _GroupCostParameter.Currency;
  12234. bool isIntType = int.TryParse(_currency, out int currId);
  12235. if (isIntType)
  12236. {
  12237. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12238. }
  12239. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12240. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12241. if (currInfo == null)
  12242. {
  12243. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12244. }
  12245. if (!_currency.ToUpper().Equals("CNY"))
  12246. {
  12247. _rate = _GroupCostParameter.Rate;
  12248. }
  12249. _rate = currInfo.Rate;
  12250. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12251. string strFileName = "HotelStatement/";
  12252. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12253. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12254. #region 数据处理
  12255. foreach (var item in hrDtas)
  12256. {
  12257. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12258. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12259. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12260. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12261. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12262. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12263. string singleRoomFeeStr = string.Empty,
  12264. doubleRoomFeeStr = string.Empty,
  12265. suiteRoomFeeStr = string.Empty,
  12266. otherRoomFeeStr = string.Empty,
  12267. payMoneyStr = string.Empty,
  12268. cardPriceStr = string.Empty;
  12269. if (roomCurr.Equals(_currency))
  12270. {
  12271. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12272. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12273. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12274. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12275. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12276. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12277. }
  12278. else
  12279. {
  12280. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12281. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12282. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12283. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12284. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12285. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12286. }
  12287. string breakfastPriceStr = string.Empty,
  12288. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12289. governmentRentStr = string.Empty,
  12290. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12291. cityTaxStrStr = string.Empty,
  12292. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12293. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12294. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12295. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12296. int payDId = roomInfo?.PayDId ?? 0;
  12297. pcfds.Add(new HotelReservations_PCFD_View()
  12298. {
  12299. City = item.City,
  12300. HotelName = item.HotelName,
  12301. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12302. // SingleRoomCount = item.SingleRoomCount,
  12303. SingleRoomPrice = singleRoomFeeStr,
  12304. // DoubleRoomCount = item.DoubleRoomCount,
  12305. DoubleRoomPrice = doubleRoomFeeStr,
  12306. //SuiteRoomCount = item.SuiteRoomCount,
  12307. SuiteRoomPrice = suiteRoomFeeStr,
  12308. OtherRoomPrice = otherRoomFeeStr,
  12309. //OtherRoomCount = item.OtherRoomCount,
  12310. BreakfastPrice = breakfastPriceStr,
  12311. GovernmentRent = governmentRentStr,
  12312. CityTax = cityTaxStrStr,
  12313. RoomExplanation = item.RoomExplanation,
  12314. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12315. PayTime = roomInfo?.ConsumptionDate,
  12316. BankNo = roomInfo?.BankNo,
  12317. PayMoney = payMoneyStr,
  12318. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12319. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12320. CardPrice = cardPriceStr,
  12321. Remark = ccpInfo.Remark
  12322. });
  12323. }
  12324. #endregion
  12325. //载入模板
  12326. WorkbookDesigner designer = new WorkbookDesigner();
  12327. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12328. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12329. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12330. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12331. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12332. designer.SetDataSource("Opertor", userInfo.CnName);
  12333. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12334. dt.TableName = "ViewMyHotelReservations";
  12335. designer.SetDataSource(dt);
  12336. designer.Process();
  12337. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12338. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12339. designer.Workbook.Save(serverPath);
  12340. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12341. #region 删除指定行
  12342. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12343. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12344. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12345. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12346. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12347. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12348. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12349. cssIndex = dt.Columns["CityTax"].Ordinal,
  12350. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12351. remarkIndex = dt.Columns["Remark"].Ordinal;
  12352. //删除指定列
  12353. foreach (DataRow item in dt.Rows)
  12354. {
  12355. string singleStr = item["SingleRoomPrice"].ToString();
  12356. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12357. if (containsDigitButNotZero1) singleDel = false;
  12358. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12359. string doubleStr = item["DoubleRoomPrice"].ToString();
  12360. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12361. if (containsDigitButNotZero2) doubleDel = false;
  12362. string suiteStr = item["SuiteRoomPrice"].ToString();
  12363. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12364. if (containsDigitButNotZero3) suiteDel = false;
  12365. string otherStr = item["OtherRoomPrice"].ToString();
  12366. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12367. if (containsDigitButNotZero4) otherDel = false;
  12368. string zcStr = item["BreakfastPrice"].ToString();
  12369. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12370. if (containsDigitButNotZero5) zcDel = false;
  12371. string dsStr = item["GovernmentRent"].ToString();
  12372. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12373. if (containsDigitButNotZero6) dsDel = false;
  12374. string cssStr = item["CityTax"].ToString();
  12375. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12376. if (containsDigitButNotZero7) cssDel = false;
  12377. string cpStr = item["ConsumptionPatterns"].ToString();
  12378. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12379. string remarkStr = item["Remark"].ToString();
  12380. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12381. }
  12382. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12383. DeleteColumn(serverPath, cpIndex, cpDel);
  12384. DeleteColumn(serverPath, dsIndex, dsDel);
  12385. DeleteColumn(serverPath, cssIndex, cssDel);
  12386. DeleteColumn(serverPath, zcIndex, zcDel);
  12387. DeleteColumn(serverPath, otherIndex, otherDel);
  12388. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12389. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12390. DeleteColumn(serverPath, singleIndex, singleDel);
  12391. #endregion
  12392. //只保留第一个表格
  12393. DeleteSheet(serverPath);
  12394. return Ok(JsonView(true, "操作成功", url = rst));
  12395. }
  12396. return Ok(JsonView(false));
  12397. }
  12398. /// <summary>
  12399. /// 删除指定列
  12400. /// </summary>
  12401. /// <param name="file"></param>
  12402. /// <param name="columnIndex"></param>
  12403. /// <param name="isDel"></param>
  12404. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12405. {
  12406. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12407. //wb.Save(file);
  12408. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12409. if (sheet1 != null)
  12410. {
  12411. if (isDel)
  12412. {
  12413. Cells cells = sheet1.Cells;
  12414. cells.DeleteColumn(columnIndex);
  12415. }
  12416. }
  12417. wb.Save(file);
  12418. }
  12419. /// <summary>
  12420. /// 删除sheet
  12421. /// </summary>
  12422. /// <param name="file"></param>
  12423. /// <param name="sheetName"></param>
  12424. private void DeleteSheet(string file, string sheetName = "")
  12425. {
  12426. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12427. //wb.Save(file);
  12428. List<string> sheets = new List<string>();
  12429. foreach (var item in wb.Worksheets)
  12430. {
  12431. sheets.Add(item.Name);
  12432. }
  12433. if (sheets.Count > 0)
  12434. {
  12435. sheets.RemoveAt(0);//不删除第一个sheet
  12436. foreach (var item in sheets)
  12437. {
  12438. wb.Worksheets.RemoveAt(item);
  12439. }
  12440. }
  12441. wb.Save(file);
  12442. }
  12443. /// <summary>
  12444. /// 酒店预订
  12445. /// 确认单
  12446. /// </summary>
  12447. /// <param name="_dto"></param>
  12448. /// <returns></returns>
  12449. [HttpPost]
  12450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12451. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12452. {
  12453. try
  12454. {
  12455. #region 参数验证
  12456. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12457. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12458. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12459. #region 团组操作权限验证 76 酒店预定模块
  12460. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12461. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12462. #endregion
  12463. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12464. #region 页面操作权限验证
  12465. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12466. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12467. #endregion
  12468. #endregion
  12469. //团组信息
  12470. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12471. //酒店数据
  12472. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12473. if (listhoteldata.Count < 0)
  12474. {
  12475. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12476. }
  12477. //利datatable存储
  12478. DataTable dt = new DataTable();
  12479. dt.Columns.Add("CheckInDate", typeof(string));
  12480. dt.Columns.Add("City", typeof(string));
  12481. dt.Columns.Add("Hotel", typeof(string));
  12482. dt.Columns.Add("Room", typeof(string));
  12483. for (int i = 0; i < listhoteldata.Count; i++)
  12484. {
  12485. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12486. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12487. while (dayStart < dayEnd)
  12488. {
  12489. string temp = "";
  12490. DataRow row = dt.NewRow();
  12491. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12492. row["City"] = listhoteldata[i].City;
  12493. row["Hotel"] = listhoteldata[i].HotelName;
  12494. if (listhoteldata[i].SingleRoomCount > 0)
  12495. {
  12496. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12497. }
  12498. if (listhoteldata[i].DoubleRoomCount > 0)
  12499. {
  12500. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12501. }
  12502. if (listhoteldata[i].SuiteRoomCount > 0)
  12503. {
  12504. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12505. }
  12506. if (listhoteldata[i].OtherRoomCount > 0)
  12507. {
  12508. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12509. }
  12510. row["Room"] = temp;
  12511. dt.Rows.Add(row);
  12512. dayStart = dayStart.AddDays(1);
  12513. }
  12514. }
  12515. Dictionary<string, string> dic = new Dictionary<string, string>();
  12516. dic.Add("Dele", di.TeamName);
  12517. dic.Add("City", di.VisitCountry);
  12518. //模板路径
  12519. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12520. //载入模板
  12521. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12522. DocumentBuilder builder = new DocumentBuilder(doc);
  12523. foreach (var key in dic.Keys)
  12524. {
  12525. builder.MoveToBookmark(key);
  12526. builder.Write(dic[key]);
  12527. }
  12528. //获取word里所有表格
  12529. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12530. //获取所填表格的序数
  12531. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12532. var rowStart = tableOne.Rows[0]; //获取第1行
  12533. //循环赋值
  12534. for (int i = 0; i < dt.Rows.Count; i++)
  12535. {
  12536. builder.MoveToCell(0, i + 1, 0, 0);
  12537. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12538. builder.MoveToCell(0, i + 1, 1, 0);
  12539. builder.Write(dt.Rows[i]["City"].ToString());
  12540. builder.MoveToCell(0, i + 1, 2, 0);
  12541. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12542. builder.MoveToCell(0, i + 1, 3, 0);
  12543. builder.Write(dt.Rows[i]["Room"].ToString());
  12544. }
  12545. //删除多余行
  12546. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12547. {
  12548. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12549. }
  12550. string strFileName = di.TeamName + "酒店确认单.doc";
  12551. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12552. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12553. return Ok(JsonView(true, "成功", url));
  12554. }
  12555. catch (Exception ex)
  12556. {
  12557. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12558. }
  12559. }
  12560. #endregion
  12561. #region 团组状态
  12562. /// <summary>
  12563. /// 团组状态列表 Page
  12564. /// </summary>
  12565. /// <param name="dto">团组列表请求dto</param>
  12566. /// <returns></returns>
  12567. [HttpPost]
  12568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12569. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12570. {
  12571. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12572. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12573. {
  12574. string sqlWhere = string.Empty;
  12575. if (dto.IsSure == 0) //未完成
  12576. {
  12577. sqlWhere += string.Format(@" And IsSure = 0");
  12578. }
  12579. else if (dto.IsSure == 1) //已完成
  12580. {
  12581. sqlWhere += string.Format(@" And IsSure = 1");
  12582. }
  12583. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12584. {
  12585. string tj = dto.SearchCriteria;
  12586. 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}%')",
  12587. tj, tj, tj, tj, tj);
  12588. }
  12589. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12590. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12591. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12592. From (
  12593. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12594. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12595. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12596. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12597. From Grp_DelegationInfo gdi
  12598. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12599. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12600. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12601. Where gdi.IsDel = 0 {0}
  12602. ) temp ", sqlWhere);
  12603. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12604. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12605. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12606. }
  12607. else
  12608. {
  12609. return Ok(JsonView(false, "查询失败"));
  12610. }
  12611. }
  12612. /// <summary>
  12613. /// 团组状态
  12614. /// 设置操作完成
  12615. /// </summary>
  12616. /// <param name="dto">团组列表请求dto</param>
  12617. /// <returns></returns>
  12618. [HttpPost]
  12619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12620. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12621. {
  12622. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12623. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12624. {
  12625. Id = dto.Id,
  12626. IsSure = 1
  12627. };
  12628. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12629. .UpdateColumns(it => new { it.IsSure })
  12630. .WhereColumns(it => new { it.Id })
  12631. .ExecuteCommandAsync();
  12632. if (result > 0)
  12633. {
  12634. return Ok(JsonView(true, "操作完成!"));
  12635. }
  12636. return Ok(JsonView(false, "操作失败!"));
  12637. }
  12638. #endregion
  12639. #region 保险费用录入
  12640. /// <summary>
  12641. /// 根据团组Id查询保险费用列表
  12642. /// </summary>
  12643. /// <param name="dto"></param>
  12644. /// <returns></returns>
  12645. [HttpPost]
  12646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12647. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12648. {
  12649. Result groupData = await _customersRep.CustomersByDiId(dto);
  12650. if (groupData.Code != 0)
  12651. {
  12652. return Ok(JsonView(false, groupData.Msg));
  12653. }
  12654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12655. }
  12656. /// <summary>
  12657. /// 根据保险费用Id查询保险费用详细
  12658. /// </summary>
  12659. /// <param name="dto"></param>
  12660. /// <returns></returns>
  12661. [HttpPost]
  12662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12663. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12664. {
  12665. try
  12666. {
  12667. Result groupData = await _customersRep.CustomersById(dto);
  12668. if (groupData.Code != 0)
  12669. {
  12670. return Ok(JsonView(false, groupData.Msg));
  12671. }
  12672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12673. }
  12674. catch (Exception ex)
  12675. {
  12676. return Ok(JsonView(false, ex.Message));
  12677. }
  12678. }
  12679. /// <summary>
  12680. /// 保险费用录入页面初始化绑定
  12681. /// </summary>
  12682. /// <param name="dto"></param>
  12683. /// <returns></returns>
  12684. [HttpPost]
  12685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12686. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12687. {
  12688. try
  12689. {
  12690. Result groupData = await _customersRep.CustomersInitialize(dto);
  12691. if (groupData.Code != 0)
  12692. {
  12693. return Ok(JsonView(false, groupData.Msg));
  12694. }
  12695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12696. }
  12697. catch (Exception ex)
  12698. {
  12699. return Ok(JsonView(false, ex.Message));
  12700. }
  12701. }
  12702. /// <summary>
  12703. /// 保险费用操作(Status:1.新增,2.修改)
  12704. /// </summary>
  12705. /// <param name="dto"></param>
  12706. /// <returns></returns>
  12707. [HttpPost]
  12708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12709. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12710. {
  12711. Result groupData = await _customersRep.OpCustomers(dto);
  12712. if (groupData.Code != 0)
  12713. {
  12714. return Ok(JsonView(false, groupData.Msg));
  12715. }
  12716. #region 应用推送
  12717. try
  12718. {
  12719. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12720. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12721. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12722. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12723. //自动审核
  12724. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12725. //2024-10-21 新增LZ UID
  12726. var userIds = new List<int>() { 21 };
  12727. string title = $"系统通知";
  12728. var diId = dto.DiId;
  12729. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12730. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12731. string content = "";
  12732. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12733. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12734. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12735. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12736. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12737. }
  12738. catch (Exception ex)
  12739. {
  12740. }
  12741. #endregion
  12742. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12743. }
  12744. /// <summary>
  12745. /// 保险文件上传
  12746. /// </summary>
  12747. /// <param name="file"></param>
  12748. /// <returns></returns>
  12749. [HttpPost]
  12750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12751. public async Task<IActionResult> UploadCus(IFormFile file)
  12752. {
  12753. try
  12754. {
  12755. if (file != null)
  12756. {
  12757. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12758. //文件名称
  12759. string projectFileName = file.FileName;
  12760. //上传的文件的路径
  12761. string filePath = "";
  12762. if (!Directory.Exists(fileDir))
  12763. {
  12764. Directory.CreateDirectory(fileDir);
  12765. }
  12766. //上传的文件的路径
  12767. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12768. using (FileStream fs = System.IO.File.Create(filePath))
  12769. {
  12770. file.CopyTo(fs);
  12771. fs.Flush();
  12772. }
  12773. return Ok(JsonView(true, "上传成功!", projectFileName));
  12774. }
  12775. else
  12776. {
  12777. return Ok(JsonView(false, "上传失败!"));
  12778. }
  12779. }
  12780. catch (Exception ex)
  12781. {
  12782. return Ok(JsonView(false, "程序错误!"));
  12783. throw;
  12784. }
  12785. }
  12786. /// <summary>
  12787. /// 保险删除指定文件
  12788. /// </summary>
  12789. /// <param name="dto"></param>
  12790. /// <returns></returns>
  12791. [HttpPost]
  12792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12793. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12794. {
  12795. try
  12796. {
  12797. string filePath = "";
  12798. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12799. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12800. //int id = 0;
  12801. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12802. // 删除该文件
  12803. try
  12804. {
  12805. System.IO.File.Delete(filePath);
  12806. 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()
  12807. {
  12808. Attachment = "",
  12809. }).ExecuteCommandAsync();
  12810. if (result != 0)
  12811. {
  12812. return Ok(JsonView(true, "成功!"));
  12813. }
  12814. else
  12815. {
  12816. return Ok(JsonView(false, "失败!"));
  12817. }
  12818. }
  12819. catch (Exception)
  12820. {
  12821. 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()
  12822. {
  12823. Attachment = "",
  12824. }).ExecuteCommandAsync();
  12825. if (result != 0)
  12826. {
  12827. return Ok(JsonView(true, "成功!"));
  12828. }
  12829. else
  12830. {
  12831. return Ok(JsonView(false, "失败!"));
  12832. }
  12833. }
  12834. }
  12835. catch (Exception ex)
  12836. {
  12837. return Ok(JsonView(false, "程序错误!"));
  12838. throw;
  12839. }
  12840. }
  12841. /// <summary>
  12842. /// 保险费用操作(删除)
  12843. /// </summary>
  12844. /// <param name="dto"></param>
  12845. /// <returns></returns>
  12846. [HttpPost]
  12847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12848. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12849. {
  12850. try
  12851. {
  12852. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12853. if (!res)
  12854. {
  12855. return Ok(JsonView(false, "删除失败"));
  12856. }
  12857. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12858. {
  12859. IsDel = 1,
  12860. DeleteUserId = dto.DeleteUserId,
  12861. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12862. }).ExecuteCommandAsync();
  12863. return Ok(JsonView(true, "删除成功!"));
  12864. }
  12865. catch (Exception ex)
  12866. {
  12867. return Ok(JsonView(false, "程序错误!"));
  12868. throw;
  12869. }
  12870. }
  12871. #endregion
  12872. #region 接团客户名单 PageId 104
  12873. /// <summary>
  12874. /// 接团客户名单
  12875. /// 迁移数据(慎用!)
  12876. /// </summary>
  12877. /// <param name="dto"></param>
  12878. /// <returns></returns>
  12879. [HttpPost]
  12880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12881. public async Task<IActionResult> PostTourClientListChange()
  12882. {
  12883. try
  12884. {
  12885. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12886. //var groupClinetData1
  12887. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12888. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12889. int updateCount = 0;
  12890. if (oldOAClientList.Count > 0)
  12891. {
  12892. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12893. _sqlSugar.BeginTran();
  12894. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12895. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12896. foreach (var item in oldOAClientList)
  12897. {
  12898. int comId = 0;
  12899. string format = "yyyy-MM-dd HH:mm:ss";
  12900. string data11 = "1990-01-01 00:00";
  12901. var data1 = IsValidDate(item.OPdate, format);
  12902. if (data1) data11 = item.OPdate;
  12903. //客户公司验证
  12904. if (!string.IsNullOrEmpty(item.Company))
  12905. {
  12906. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12907. if (clientComInfo == null) // add
  12908. {
  12909. var addInfo = new Crm_CustomerCompany()
  12910. {
  12911. CompanyAbbreviation = "",
  12912. CompanyFullName = item.Company,
  12913. Address = "",
  12914. PostCodes = "",
  12915. LastedOpUserId = item.OPer,
  12916. LastedOpDt = Convert.ToDateTime(data11),
  12917. CreateUserId = item.OPer,
  12918. CreateTime = Convert.ToDateTime(data11),
  12919. IsDel = 0
  12920. };
  12921. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  12922. if (comId1 > 0) comId = comId1;
  12923. }
  12924. else comId = clientComInfo.Id;
  12925. }
  12926. //客户人员验证
  12927. int clientId = 0;
  12928. string name = item.LastName + item.Name;
  12929. if (!string.IsNullOrEmpty(name))
  12930. {
  12931. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  12932. if (clientInfo == null)
  12933. {
  12934. DateTime? dateTime = null;
  12935. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  12936. if (isDt) dateTime = birthDayDt;
  12937. var addInfo1 = new Crm_DeleClient()
  12938. {
  12939. CrmCompanyId = comId,
  12940. DiId = -1,
  12941. LastName = item.LastName,
  12942. FirstName = item.Name,
  12943. OldName = "",
  12944. Pinyin = item.Pinyin,
  12945. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  12946. Marriage = 0,
  12947. Phone = item.Phone,
  12948. Job = item.Job,
  12949. BirthDay = dateTime
  12950. };
  12951. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  12952. if (clientId1 > 0) clientId = clientId1;
  12953. }
  12954. else clientId = clientInfo.Id;
  12955. }
  12956. if (clientId < 1)
  12957. {
  12958. continue;
  12959. }
  12960. int airType = 0;
  12961. if (item.AirType == "超经舱") airType = 459;
  12962. else if (item.AirType == "公务舱") airType = 458;
  12963. else if (item.AirType == "经济舱") airType = 460;
  12964. else if (item.AirType == "其他") airType = 565;
  12965. else if (item.AirType == "头等舱") airType = 457;
  12966. var _TourClientListEntity = new Grp_TourClientList()
  12967. {
  12968. DiId = item.Diid,
  12969. ClientId = clientId,
  12970. CreateUserId = item.OPer,
  12971. CreateTime = Convert.ToDateTime(data11),
  12972. Remark = item.Remark,
  12973. IsDel = item.Isdel,
  12974. ShippingSpaceTypeId = airType,
  12975. ShippingSpaceSpecialNeeds = item.AirRemark,
  12976. HotelSpecialNeeds = item.RoomType
  12977. };
  12978. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  12979. if (_TourClientList > 0)
  12980. {
  12981. updateCount++;
  12982. }
  12983. }
  12984. _sqlSugar.CommitTran();
  12985. }
  12986. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  12987. }
  12988. catch (Exception ex)
  12989. {
  12990. _sqlSugar.RollbackTran();
  12991. return Ok(JsonView(false, ex.Message));
  12992. }
  12993. return Ok(JsonView(true));
  12994. }
  12995. private bool IsValidDate(string dateString, string format)
  12996. {
  12997. DateTime dateValue;
  12998. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  12999. return valid;
  13000. }
  13001. /// <summary>
  13002. /// 接团客户名单
  13003. /// 根据团组Id查询List
  13004. /// </summary>
  13005. /// <param name="dto"></param>
  13006. /// <returns></returns>
  13007. [HttpPost]
  13008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13009. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13010. {
  13011. #region 参数验证
  13012. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13013. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13014. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13015. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13016. #region 页面操作权限验证
  13017. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13018. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13019. #endregion
  13020. #endregion
  13021. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13022. if (viewData.Code != 0)
  13023. {
  13024. return Ok(JsonView(false, viewData.Msg));
  13025. }
  13026. return Ok(JsonView(viewData.Data));
  13027. }
  13028. /// <summary>
  13029. /// 接团客户名单
  13030. /// 基础数据 Init
  13031. /// </summary>
  13032. /// <param name="_dto"></param>
  13033. /// <returns></returns>
  13034. [HttpPost]
  13035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13036. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13037. {
  13038. #region 参数验证
  13039. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13040. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13041. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13042. #region 页面操作权限验证
  13043. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13044. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13045. #endregion
  13046. #endregion
  13047. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13048. }
  13049. /// <summary>
  13050. /// 接团客户名单
  13051. /// 根据 Id查询 Details
  13052. /// </summary>
  13053. /// <param name="_dto"></param>
  13054. /// <returns></returns>
  13055. [HttpPost]
  13056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13057. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13058. {
  13059. #region 参数验证
  13060. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13061. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13062. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13063. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13064. #region 页面操作权限验证
  13065. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13066. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13067. #endregion
  13068. #endregion
  13069. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13070. if (viewData.Code != 0)
  13071. {
  13072. return Ok(JsonView(false, viewData.Msg));
  13073. }
  13074. return Ok(JsonView(viewData.Data));
  13075. }
  13076. /// <summary>
  13077. /// 接团客户名单
  13078. /// Add Or Edit
  13079. /// </summary>
  13080. /// <param name="_dto"></param>
  13081. /// <returns></returns>
  13082. [HttpPost]
  13083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13084. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13085. {
  13086. #region 参数验证
  13087. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13088. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13089. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13090. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13091. #region 页面操作权限验证
  13092. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13093. if (_dto.Id == 0) //添加
  13094. {
  13095. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13096. }
  13097. else if (_dto.Id >= 0) //修改
  13098. {
  13099. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13100. }
  13101. #endregion
  13102. #endregion
  13103. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13104. if (viewData.Code != 0)
  13105. {
  13106. return Ok(JsonView(false, viewData.Msg));
  13107. }
  13108. return Ok(JsonView(true));
  13109. }
  13110. /// <summary>
  13111. /// 接团客户名单
  13112. /// AddMultiple(添加多个)
  13113. /// </summary>
  13114. /// <param name="_dto"></param>
  13115. /// <returns></returns>
  13116. [HttpPost]
  13117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13118. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13119. {
  13120. #region 参数验证
  13121. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13122. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13123. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13124. #region 页面操作权限验证
  13125. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13126. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13127. #endregion
  13128. #endregion
  13129. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13130. if (viewData.Code != 0)
  13131. {
  13132. return Ok(JsonView(false, viewData.Msg));
  13133. }
  13134. return Ok(JsonView(true));
  13135. }
  13136. /// <summary>
  13137. /// 接团客户名单
  13138. /// Del
  13139. /// </summary>
  13140. /// <param name="_dto"></param>
  13141. /// <returns></returns>
  13142. [HttpPost]
  13143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13144. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13145. {
  13146. #region 参数验证
  13147. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13148. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13149. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13150. #region 页面操作权限验证
  13151. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13152. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13153. #endregion
  13154. #endregion
  13155. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13156. if (viewData.Code != 0)
  13157. {
  13158. return Ok(JsonView(false, viewData.Msg));
  13159. }
  13160. return Ok(JsonView(true));
  13161. }
  13162. /// <summary>
  13163. /// 接团客户名单
  13164. /// 文件下载 客户名单
  13165. /// </summary>
  13166. /// <param name="_dto"></param>
  13167. /// <returns></returns>
  13168. [HttpPost]
  13169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13170. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13171. {
  13172. #region 参数验证
  13173. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13174. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13175. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13177. #region 页面操作权限验证
  13178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13179. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13180. #endregion
  13181. #endregion
  13182. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13183. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13184. From Grp_TourClientList tcl
  13185. Left Join
  13186. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13187. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13188. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13189. From Crm_DeleClient dc
  13190. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13191. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13192. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13193. Where dc.IsDel = 0) temp
  13194. On temp.DcId =tcl.ClientId
  13195. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13196. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13197. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13198. //载入模板
  13199. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13200. if (_dto.Language == 1)
  13201. {
  13202. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13203. }
  13204. //载入模板
  13205. var doc = new Document(tempPath);
  13206. DocumentBuilder builder = new DocumentBuilder(doc);
  13207. //获取word里所有表格
  13208. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13209. //获取所填表格的序数
  13210. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13211. var rowStart = tableOne.Rows[0]; //获取第1行
  13212. if (_dto.Language == 0)
  13213. {
  13214. //循环赋值
  13215. for (int i = 0; i < DcList.Count; i++)
  13216. {
  13217. EncryptionProcessor.DecryptProperties(DcList[i]);
  13218. builder.MoveToCell(0, i + 1, 0, 0);
  13219. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13220. builder.MoveToCell(0, i + 1, 1, 0);
  13221. int sex = DcList[i].Sex;
  13222. string sexStr = string.Empty;
  13223. if (sex == 0) sexStr = "男";
  13224. else if (sex == 1) sexStr = "女";
  13225. else sexStr = "未设置";
  13226. builder.Write(sexStr);
  13227. builder.MoveToCell(0, i + 1, 2, 0);
  13228. string birthDay = DcList[i].BirthDay;
  13229. string birthDayStr = string.Empty;
  13230. if (!string.IsNullOrEmpty(birthDay))
  13231. {
  13232. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13233. }
  13234. builder.Write(birthDayStr);
  13235. builder.MoveToCell(0, i + 1, 3, 0);
  13236. string company = "";
  13237. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13238. {
  13239. company = DcList[i].CompanyFullName.ToString();
  13240. }
  13241. builder.Write(company);
  13242. builder.MoveToCell(0, i + 1, 4, 0);
  13243. builder.Write(DcList[i].Job);
  13244. }
  13245. }
  13246. else if (_dto.Language == 1)
  13247. {
  13248. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13249. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13250. List<string> transArrayStr = new List<string>();
  13251. string transStrRes1 = "";
  13252. for (int i = 0; i < DcList.Count; i++)
  13253. {
  13254. var dc = DcList[i];
  13255. EncryptionProcessor.DecryptProperties(dc);
  13256. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13257. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13258. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13259. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13260. else transStrRes1 += $"{str1}|";
  13261. }
  13262. //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";
  13263. string transStrRes = "";
  13264. if (transStrRes1.Length > 0)
  13265. {
  13266. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13267. }
  13268. //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
  13269. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13270. //List<string> transArray = new List<string> { };
  13271. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13272. if (transStrRes.Contains("|"))
  13273. {
  13274. string[] transArray1 = transStrRes.Split('|');
  13275. if (transArray1.Length > 0)
  13276. {
  13277. foreach (var item in transArray1)
  13278. {
  13279. if (item.Contains("&"))
  13280. {
  13281. string[] transArray2 = item.Split('&');
  13282. int index = 0;
  13283. string companyName = "", job = "";
  13284. if (transArray2.Length > 0)
  13285. {
  13286. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13287. if (1 < transArray2.Length) companyName = transArray2[1];
  13288. if (2 < transArray2.Length) job = transArray2[2];
  13289. }
  13290. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13291. }
  13292. }
  13293. }
  13294. }
  13295. //循环赋值
  13296. for (int i = 0; i < DcList.Count; i++)
  13297. {
  13298. string PYName = "";
  13299. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13300. {
  13301. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13302. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13303. PYName = PY_First + " " + PY_Last;
  13304. }
  13305. else
  13306. {
  13307. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13308. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13309. PYName = PY_First + " " + PY_Last;
  13310. }
  13311. builder.MoveToCell(0, i + 1, 0, 0);
  13312. builder.Write(PYName);
  13313. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13314. builder.MoveToCell(0, i + 1, 1, 0);
  13315. builder.Write(sex);
  13316. DateTime birthDt;
  13317. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13318. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13319. builder.MoveToCell(0, i + 1, 2, 0);
  13320. builder.Write(birthday);
  13321. string company = string.Empty, job = string.Empty;
  13322. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13323. if (dcTransInfo != null)
  13324. {
  13325. company = dcTransInfo.CompanyName;
  13326. job = dcTransInfo.Job;
  13327. }
  13328. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13329. {
  13330. //查询对照表
  13331. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13332. if (tempCec != null)
  13333. {
  13334. company = tempCec.enName;
  13335. }
  13336. //翻译
  13337. else
  13338. {
  13339. }
  13340. }
  13341. builder.MoveToCell(0, i + 1, 3, 0);
  13342. builder.Write(company);
  13343. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13344. {
  13345. //查询对照表
  13346. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13347. if (tempPec != null)
  13348. {
  13349. job = tempPec.enName;
  13350. }
  13351. //翻译
  13352. else
  13353. {
  13354. }
  13355. }
  13356. builder.MoveToCell(0, i + 1, 4, 0);
  13357. builder.Write(job);
  13358. }
  13359. }
  13360. //删除多余行
  13361. while (tableOne.Rows.Count > DcList.Count + 1)
  13362. {
  13363. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13364. }
  13365. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13366. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13367. doc.Save(fileDir);
  13368. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13369. return Ok(JsonView(true, "操作成功!", Url));
  13370. }
  13371. private class TranslateInfo
  13372. {
  13373. public int Index { get; set; }
  13374. public string CompanyName { get; set; }
  13375. public string Job { get; set; }
  13376. }
  13377. #endregion
  13378. #region 团组倒推表
  13379. /// <summary>
  13380. /// 倒推表基础数据
  13381. /// Init
  13382. /// </summary>
  13383. /// <param name="dto"></param>
  13384. /// <returns></returns>
  13385. [HttpPost]
  13386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13387. public async Task<IActionResult> PostInvertedListInit()
  13388. {
  13389. var viewData = await _invertedListRep._Init();
  13390. if (viewData.Code != 0)
  13391. {
  13392. return Ok(JsonView(false, viewData.Msg));
  13393. }
  13394. return Ok(JsonView(viewData.Data));
  13395. }
  13396. /// <summary>
  13397. /// 倒推表
  13398. /// Info
  13399. /// </summary>
  13400. /// <param name="dto"></param>
  13401. /// <returns></returns>
  13402. [HttpPost]
  13403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13404. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13405. {
  13406. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13407. if (viewData.Code != 0)
  13408. {
  13409. return Ok(JsonView(false, viewData.Msg));
  13410. }
  13411. return Ok(JsonView(viewData.Data));
  13412. }
  13413. /// <summary>
  13414. /// 倒推表
  13415. /// Create
  13416. /// </summary>
  13417. /// <param name="dto"></param>
  13418. /// <returns></returns>
  13419. [HttpPost]
  13420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13421. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13422. {
  13423. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13424. if (viewData.Code != 0)
  13425. {
  13426. return Ok(JsonView(false, viewData.Msg));
  13427. }
  13428. return Ok(JsonView(viewData.Data));
  13429. }
  13430. /// <summary>
  13431. /// 倒推表
  13432. /// Update
  13433. /// </summary>
  13434. /// <param name="dto"></param>
  13435. /// <returns></returns>
  13436. [HttpPost]
  13437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13438. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13439. {
  13440. var viewData = await _invertedListRep._Update(dto);
  13441. if (viewData.Code != 0)
  13442. {
  13443. return Ok(JsonView(false, viewData.Msg));
  13444. }
  13445. return Ok(JsonView(viewData.Data));
  13446. }
  13447. /// <summary>
  13448. /// 倒推表
  13449. /// File Download
  13450. /// </summary>
  13451. /// <param name="dto"></param>
  13452. /// <returns></returns>
  13453. [HttpPost]
  13454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13455. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13456. {
  13457. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13458. if (info2.Code != 0)
  13459. {
  13460. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13461. }
  13462. var info1 = info2.Data as InvertedListInfoView;
  13463. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13464. string teamName = "";
  13465. if (info != null) teamName = info.TeamName;
  13466. //载入模板
  13467. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13468. DocumentBuilder builder = new DocumentBuilder(doc);
  13469. //利用键值对存放数据
  13470. Dictionary<string, string> dic = new Dictionary<string, string>();
  13471. dic.Add("TeamName", teamName);
  13472. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13473. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13474. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13475. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13476. dic.Add("SQRemark", info1.ApprovalRemark);
  13477. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13478. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13479. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13480. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13481. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13482. dic.Add("QZRemark", info1.VisaInformationRemark);
  13483. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13484. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13485. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13486. dic.Add("CQRemark", info1.IssueVisaRemark);
  13487. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13488. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13489. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13490. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13491. #region 填充word模板书签内容
  13492. foreach (var key in dic.Keys)
  13493. {
  13494. builder.MoveToBookmark(key);
  13495. builder.Write(dic[key]);
  13496. }
  13497. #endregion
  13498. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13499. string fileName = $"{teamName}团出行准备流程表.doc";
  13500. string filePath = fileDir + $@"InvertedList/{fileName}";
  13501. doc.Save(filePath);
  13502. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13503. return Ok(JsonView(true, "操作成功!", Url));
  13504. }
  13505. #endregion
  13506. #region 三公签证费用(签证费、代办费)
  13507. /// <summary>
  13508. /// 三公签证费用(签证费、代办费)
  13509. /// List
  13510. /// </summary>
  13511. /// <returns></returns>
  13512. [HttpPost]
  13513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13514. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13515. {
  13516. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13517. if (_view.Code != 0)
  13518. {
  13519. return Ok(JsonView(false, _view.Msg));
  13520. }
  13521. return Ok(JsonView(true, "操作成功!", _view.Data));
  13522. }
  13523. /// <summary>
  13524. /// 三公签证费用(签证费、代办费)
  13525. /// Add Or Update
  13526. /// </summary>
  13527. /// <returns></returns>
  13528. [HttpPost]
  13529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13530. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13531. {
  13532. var _view = await _visaFeeInfoRep._Update(_dto);
  13533. if (_view.Code != 0)
  13534. {
  13535. return Ok(JsonView(false, _view.Msg));
  13536. }
  13537. return Ok(JsonView(true, _view.Msg));
  13538. }
  13539. #endregion
  13540. #region 酒店询价
  13541. /// <summary>
  13542. /// 酒店询价
  13543. /// Init
  13544. /// </summary>
  13545. /// <param name="dto"></param>
  13546. /// <returns></returns>
  13547. [HttpPost]
  13548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13549. public async Task<IActionResult> PostHotelInquiryInit()
  13550. {
  13551. var res = await _hotelInquiryRep._Init();
  13552. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13553. return Ok(JsonView(true, res.Msg, res.Data));
  13554. }
  13555. /// <summary>
  13556. /// 酒店询价
  13557. /// page Item
  13558. /// </summary>
  13559. /// <param name="_dto"></param>
  13560. /// <returns></returns>
  13561. [HttpPost]
  13562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13563. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13564. {
  13565. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13566. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13567. var view = res.Data as PageDataViewBase;
  13568. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13569. }
  13570. /// <summary>
  13571. /// 酒店询价
  13572. /// info
  13573. /// </summary>
  13574. /// <param name="_dto"></param>
  13575. /// <returns></returns>
  13576. [HttpPost]
  13577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13578. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13579. {
  13580. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13581. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13582. return Ok(JsonView(true, res.Msg, res.Data));
  13583. }
  13584. /// <summary>
  13585. /// 酒店询价
  13586. /// Add Or Edit
  13587. /// </summary>
  13588. /// <param name="_dto"></param>
  13589. /// <returns></returns>
  13590. [HttpPost]
  13591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13592. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13593. {
  13594. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13595. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13596. return Ok(JsonView(true, res.Msg, res.Data));
  13597. }
  13598. /// <summary>
  13599. /// 酒店询价
  13600. /// Del
  13601. /// </summary>
  13602. /// <param name="_dto"></param>
  13603. /// <returns></returns>
  13604. [HttpPost]
  13605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13606. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13607. {
  13608. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13609. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13610. return Ok(JsonView(true, res.Msg, res.Data));
  13611. }
  13612. #endregion
  13613. #region 下载匹配op行程单
  13614. /// <summary>
  13615. /// 匹配op行程单
  13616. /// Init
  13617. /// </summary>
  13618. /// <param name="dto">团组列表请求dto</param>
  13619. /// <returns></returns>
  13620. [HttpPost]
  13621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13622. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13623. {
  13624. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13625. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13626. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13627. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13628. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13629. .Where(it => it.IsDel == 0)
  13630. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13631. .OrderByDescending(it => it.CreateUserId)
  13632. .ToList();
  13633. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13634. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13635. var diids = groupInfos.Select(it => it.Id).ToList();
  13636. List<string> countrys = new List<string>();
  13637. foreach (var item in country)
  13638. {
  13639. var data = _groupRepository.FormartTeamName(item);
  13640. var dataArray = _groupRepository.GroupSplitCountry(data);
  13641. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13642. }
  13643. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13644. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13645. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13646. foreach (var item in areaItem)
  13647. {
  13648. string areaStr = item.Value;
  13649. if (!string.IsNullOrEmpty(areaStr))
  13650. {
  13651. string[] str1 = areaStr.Split("-");
  13652. if (str1.Length > 0)
  13653. {
  13654. areaArray.AddRange(str1);
  13655. }
  13656. }
  13657. }
  13658. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13659. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13660. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13661. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13662. .ToList();
  13663. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13664. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13665. .Where(it => countriesIds.Contains(it.Id))
  13666. .Select(it => new { it.Id, Name = it.Name_CN })
  13667. .ToList();
  13668. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13669. .Select(it => it.TeamName).ToList();
  13670. stopwatch.Stop();
  13671. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13672. }
  13673. ///// <summary>
  13674. ///// 匹配op行程单
  13675. ///// Init 查询区域数据
  13676. ///// </summary>
  13677. ///// <param name="dto">团组列表请求dto</param>
  13678. ///// <returns></returns>
  13679. //[HttpPost]
  13680. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13681. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13682. //{
  13683. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13684. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13685. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13686. // if (string.IsNullOrEmpty(countriesDataStr))
  13687. // {
  13688. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13689. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13690. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13691. // }
  13692. // else
  13693. // {
  13694. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13695. // }
  13696. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13697. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13698. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13699. // List<dynamic> childList = new List<dynamic>();
  13700. // int parentId = dto.CountriesId;
  13701. // if (provinceData.Count > 1)
  13702. // {
  13703. // foreach (var item1 in provinceData)
  13704. // {
  13705. // List<dynamic> childList1 = new List<dynamic>();
  13706. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13707. // foreach (var item2 in citiesData1)
  13708. // {
  13709. // List<dynamic> childList2 = new List<dynamic>();
  13710. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13711. // foreach (var item3 in countiesData1)
  13712. // {
  13713. // childList2.Add(new
  13714. // {
  13715. // id = item3.Id,
  13716. // parentId = item2.Id,
  13717. // level = "district",
  13718. // name = item3.Name_CN,
  13719. // });
  13720. // }
  13721. // childList1.Add(new
  13722. // {
  13723. // id = item2.Id,
  13724. // parentId = item1.Id,
  13725. // level = "city",
  13726. // name = item2.Name_CN,
  13727. // childList = childList2
  13728. // });
  13729. // }
  13730. // childList.Add(new
  13731. // {
  13732. // id = item1.Id,
  13733. // parentId = parentId,
  13734. // level = "province",
  13735. // name = item1.Name_CN,
  13736. // childList = childList1
  13737. // });
  13738. // }
  13739. // //城市
  13740. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13741. // foreach (var item2 in citiesData2)
  13742. // {
  13743. // List<dynamic> childList22 = new List<dynamic>();
  13744. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13745. // foreach (var item3 in countiesData1)
  13746. // {
  13747. // childList22.Add(new
  13748. // {
  13749. // id = item3.Id,
  13750. // parentId = item2.Id,
  13751. // level = "district",
  13752. // name = item3.Name_CN,
  13753. // });
  13754. // }
  13755. // childList.Add(new
  13756. // {
  13757. // id = item2.Id,
  13758. // parentId = parentId,
  13759. // level = "city",
  13760. // name = item2.Name_CN,
  13761. // childList = childList22
  13762. // });
  13763. // }
  13764. // }
  13765. // else
  13766. // {
  13767. // foreach (var item2 in citiesData)
  13768. // {
  13769. // string cname = item2.Name_CN;
  13770. // List<dynamic> childList1 = new List<dynamic>();
  13771. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13772. // foreach (var item3 in countiesData1)
  13773. // {
  13774. // childList1.Add(new
  13775. // {
  13776. // Id = item3.Id,
  13777. // parentId = item2.Id,
  13778. // level = "district",
  13779. // name = item3.Name_CN
  13780. // });
  13781. // }
  13782. // childList.Add(new
  13783. // {
  13784. // id = item2.Id,
  13785. // parentId = parentId,
  13786. // level = "city",
  13787. // name = item2.Name_CN,
  13788. // childList = childList1
  13789. // });
  13790. // }
  13791. // }
  13792. // stopwatch.Stop();
  13793. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13794. //}
  13795. /// <summary>
  13796. /// 匹配op行程单
  13797. /// 接团信息列表 Page
  13798. /// </summary>
  13799. /// <param name="dto">团组列表请求dto</param>
  13800. /// <returns></returns>
  13801. [HttpPost]
  13802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13803. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13804. {
  13805. var swatch = new Stopwatch();
  13806. swatch.Start();
  13807. #region 参数验证
  13808. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13809. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13811. #region 页面操作权限验证
  13812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13813. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13814. #endregion
  13815. #endregion
  13816. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13817. {
  13818. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13819. string sqlWhere = "";
  13820. if (!string.IsNullOrEmpty(dto.Country))
  13821. {
  13822. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13823. }
  13824. if (!string.IsNullOrEmpty(dto.Area))
  13825. {
  13826. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13827. }
  13828. if (!string.IsNullOrEmpty(dto.TeamName))
  13829. {
  13830. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13831. }
  13832. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13833. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13834. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13835. swatch.Stop();
  13836. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13837. }
  13838. else
  13839. {
  13840. return Ok(JsonView(false, "查询失败"));
  13841. }
  13842. }
  13843. /// <summary>
  13844. /// 匹配op行程单
  13845. /// 行程单下载
  13846. /// </summary>
  13847. /// <param name="dto">团组列表请求dto</param>
  13848. /// <returns></returns>
  13849. [HttpPost]
  13850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13851. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13852. {
  13853. #region 参数验证
  13854. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13855. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13856. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13857. #region 页面操作权限验证
  13858. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13859. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13860. #endregion
  13861. #endregion
  13862. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13863. {
  13864. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13865. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13866. }
  13867. else
  13868. {
  13869. return Ok(JsonView(false, "下载失败!"));
  13870. }
  13871. }
  13872. #endregion
  13873. #region 国家信息 数据 注释
  13874. //[HttpPost]
  13875. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13876. //{
  13877. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13878. // foreach (var item in dto)
  13879. // {
  13880. // infos.Add(new Grp_GroupsTaskAssignment()
  13881. // {
  13882. // DIId = item,
  13883. // CTId = 82,
  13884. // UId = 248,
  13885. // IsEnable = 1,
  13886. // CreateUserId = 233,
  13887. // CreateTime = DateTime.Now,
  13888. // IsDel = 0
  13889. // });
  13890. // infos.Add(new Grp_GroupsTaskAssignment()
  13891. // {
  13892. // DIId = item,
  13893. // CTId = 82,
  13894. // UId = 286,
  13895. // IsEnable = 1,
  13896. // CreateUserId = 233,
  13897. // CreateTime = DateTime.Now,
  13898. // IsDel = 0
  13899. // });
  13900. // }
  13901. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13902. // return Ok("操作成功");
  13903. //}
  13904. //public class paramJsonDto
  13905. //{
  13906. // public List<CountriesInfo> str { get; set; }
  13907. //}
  13908. //[HttpPost]
  13909. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13910. //{
  13911. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13912. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  13913. // List<Sys_Cities> cities = new List<Sys_Cities>();
  13914. // List<Sys_Cities> districts = new List<Sys_Cities>();
  13915. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13916. // _sqlSugar.BeginTran();
  13917. // int countitiesIndex = 0;
  13918. // foreach (var item in dto.str)
  13919. // {
  13920. // dynamic data = item.c;
  13921. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  13922. // if (data != null)
  13923. // {
  13924. // countitiesIndex++;
  13925. // foreach (var item1 in data)
  13926. // {
  13927. // string cnname = item1.cn;
  13928. // string enname = item1.en;
  13929. // Sys_Cities provinceInfo = new Sys_Cities()
  13930. // {
  13931. // CountriesId = countriesId,
  13932. // Name_CN = cnname,
  13933. // Name_EN = enname,
  13934. // ParentId = 0,
  13935. // IsCapital = 1,
  13936. // CreateUserId = 208,
  13937. // CreateTime = DateTime.Now,
  13938. // IsDel = 0
  13939. // };
  13940. // if (item1.lv == "province") //省份
  13941. // {
  13942. // provinceInfo.Level = 1;
  13943. // int provinceId = 0;
  13944. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  13945. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  13946. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13947. // var data1 = item1.c;
  13948. // foreach (var item2 in data1)
  13949. // {
  13950. // if (item2.lv == "city")
  13951. // {
  13952. // string citycnname = item2.cn;
  13953. // string cityenname = item2.en;
  13954. // Sys_Cities cityInfo = new Sys_Cities()
  13955. // {
  13956. // CountriesId = countriesId,
  13957. // ParentId = provinceId,
  13958. // Level = 2,
  13959. // Name_CN = citycnname,
  13960. // Name_EN = cityenname,
  13961. // IsCapital = 1,
  13962. // CreateUserId = 208,
  13963. // CreateTime = DateTime.Now,
  13964. // IsDel = 0
  13965. // };
  13966. // if (item2.c != null)
  13967. // {
  13968. // int cityId = 0;
  13969. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  13970. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13971. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  13972. // foreach (var item3 in item2.c)
  13973. // {
  13974. // if (item3.lv == "district")
  13975. // {
  13976. // var districtInfo = new Sys_Cities()
  13977. // {
  13978. // CountriesId = countriesId,
  13979. // Name_CN = item3.cn,
  13980. // Name_EN = item3.en,
  13981. // Level = 3,
  13982. // ParentId = cityId,
  13983. // IsCapital = 1,
  13984. // CreateUserId = 208,
  13985. // CreateTime = DateTime.Now,
  13986. // IsDel = 0
  13987. // };
  13988. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13989. // //{
  13990. // districts.Add(districtInfo);
  13991. // //}
  13992. // }
  13993. // }
  13994. // }
  13995. // else
  13996. // {
  13997. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  13998. // //{
  13999. // cities.Add(cityInfo);
  14000. // //}
  14001. // }
  14002. // }
  14003. // }
  14004. // }
  14005. // else if (item1.lv == "city")//城市
  14006. // {
  14007. // provinceInfo.Level = 2;
  14008. // if (item1.c != null)
  14009. // {
  14010. // int cityId = 0;
  14011. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14012. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14013. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14014. // foreach (var item3 in item1.c)
  14015. // {
  14016. // if (item3.lv == "district")
  14017. // {
  14018. // var districtInfo = new Sys_Cities()
  14019. // {
  14020. // CountriesId = countriesId,
  14021. // Name_CN = item3.cn,
  14022. // Name_EN = item3.en,
  14023. // Level = 3,
  14024. // ParentId = cityId,
  14025. // IsCapital = 1,
  14026. // CreateUserId = 208,
  14027. // CreateTime = DateTime.Now,
  14028. // IsDel = 0
  14029. // };
  14030. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14031. // //{
  14032. // districts.Add(districtInfo);
  14033. // //}
  14034. // }
  14035. // }
  14036. // }
  14037. // else
  14038. // {
  14039. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14040. // //{
  14041. // cities.Add(provinceInfo);
  14042. // //}
  14043. // }
  14044. // }
  14045. // }
  14046. // }
  14047. // }
  14048. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14049. // cities = cities.Distinct().ToList();
  14050. // districts = districts.Distinct().ToList();
  14051. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14052. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14053. // cities.AddRange(districts);
  14054. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14055. // //_sqlSugar.RollbackTran();
  14056. // _sqlSugar.CommitTran();
  14057. // return Ok(JsonView(false, "操作成功!"));
  14058. //}
  14059. //[HttpPost]
  14060. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14061. //{
  14062. // List<CountitiesInfo> infos = dto.MyProperty;
  14063. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14064. // _sqlSugar.BeginTran();
  14065. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14066. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14067. // foreach (var item in infos)
  14068. // {
  14069. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14070. // if (countryInfo != null)
  14071. // {
  14072. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14073. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14074. // if (cityInfo1 != null)
  14075. // {
  14076. // cityInfo1.IsCapital = 0;
  14077. // cityInfos.Add(cityInfo1);
  14078. // }
  14079. // }
  14080. // }
  14081. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14082. // .UpdateColumns(it => it.IsCapital)
  14083. // .WhereColumns(it => it.Id)
  14084. // .ExecuteCommand();
  14085. // //_sqlSugar.RollbackTran();
  14086. // _sqlSugar.CommitTran();
  14087. // return Ok(JsonView(false, "操作成功!"));
  14088. //}
  14089. //public class CounrtiesDto
  14090. //{
  14091. // public List<CountitiesInfo> MyProperty { get; set; }
  14092. //}
  14093. //public class CountitiesInfo
  14094. //{
  14095. // /// <summary>
  14096. // /// 圣约翰
  14097. // /// </summary>
  14098. // public string capital_name_chinese { get; set; }
  14099. // /// <summary>
  14100. // ///
  14101. // /// </summary>
  14102. // public string capital_name { get; set; }
  14103. // /// <summary>
  14104. // ///
  14105. // /// </summary>
  14106. // public string country_type { get; set; }
  14107. // /// <summary>
  14108. // /// 安提瓜和巴布达
  14109. // /// </summary>
  14110. // public string country_name_chinese { get; set; }
  14111. // /// <summary>
  14112. // /// 安提瓜和巴布达
  14113. // /// </summary>
  14114. // public string country_name_chinese_short { get; set; }
  14115. // /// <summary>
  14116. // /// 安提瓜和巴布达
  14117. // /// </summary>
  14118. // public string country_name_chinese_UN { get; set; }
  14119. // /// <summary>
  14120. // ///
  14121. // /// </summary>
  14122. // public string country_name_english_abbreviation { get; set; }
  14123. // /// <summary>
  14124. // ///
  14125. // /// </summary>
  14126. // public string country_name_english_formal { get; set; }
  14127. // /// <summary>
  14128. // ///
  14129. // /// </summary>
  14130. // public string country_name_english_UN { get; set; }
  14131. // /// <summary>
  14132. // ///
  14133. // /// </summary>
  14134. // public string continent_name { get; set; }
  14135. // /// <summary>
  14136. // ///
  14137. // /// </summary>
  14138. // public string subregion_name { get; set; }
  14139. // /// <summary>
  14140. // ///
  14141. // /// </summary>
  14142. // public string country_code2 { get; set; }
  14143. // /// <summary>
  14144. // ///
  14145. // /// </summary>
  14146. // public string country_code3 { get; set; }
  14147. // /// <summary>
  14148. // ///
  14149. // /// </summary>
  14150. // public string phone_code { get; set; }
  14151. //}
  14152. //public class CountriesInfo : BasicInfo
  14153. //{
  14154. // public List<CitiesInfo> c { get; set; }
  14155. //}
  14156. //public class CitiesInfo : BasicInfo
  14157. //{
  14158. // public List<AreaInfo> c { get; set; }
  14159. //}
  14160. //public class AreaInfo : BasicInfo
  14161. //{
  14162. // public List<AreaInfo> c { get; set; }
  14163. //}
  14164. //public class BasicInfo
  14165. //{
  14166. // public string code { get; set; }
  14167. // public string cn { get; set; }
  14168. // public string lv { get; set; }
  14169. // public string en { get; set; }
  14170. //}
  14171. #endregion
  14172. #region 查看邀请方
  14173. /// <summary>
  14174. /// 查看邀请方
  14175. /// 邀请方信息 Init
  14176. /// </summary>
  14177. /// <param name="dto"></param>
  14178. /// <returns></returns>
  14179. [HttpPost]
  14180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14181. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14182. {
  14183. string sqlWhere = string.Empty;
  14184. if (!string.IsNullOrEmpty(dto.Search))
  14185. {
  14186. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14187. }
  14188. string sql = string.Format($@"Select
  14189. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14190. Id,
  14191. UnitName
  14192. From Res_InvitationOfficialActivityData
  14193. Where IsDel = 0
  14194. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14195. RefAsync<int> total = 0;
  14196. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14197. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14198. }
  14199. /// <summary>
  14200. /// 查看邀请方
  14201. /// 国家信息 Init
  14202. /// </summary>
  14203. /// <param name="dto"></param>
  14204. /// <returns></returns>
  14205. [HttpPost]
  14206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14207. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14208. {
  14209. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14210. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14211. var diids = groupInfos.Select(it => it.Id).ToList();
  14212. List<string> countrys = new List<string>();
  14213. foreach (var item in country)
  14214. {
  14215. var data = _groupRepository.FormartTeamName(item);
  14216. var dataArray = _groupRepository.GroupSplitCountry(data);
  14217. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14218. }
  14219. countrys = countrys.Distinct().ToList();
  14220. for (int i = 0; i < countrys.Count; i++)
  14221. {
  14222. string item = countrys[i];
  14223. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14224. {
  14225. countrys.Remove(item);
  14226. i--;
  14227. }
  14228. }
  14229. RefAsync<int> total = 0;
  14230. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14231. .Where(it => countrys.Contains(it.Name_CN))
  14232. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14233. .Select(it => new { id = it.Id, name = it.Name_CN })
  14234. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14235. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14236. }
  14237. /// <summary>
  14238. /// 查看邀请方
  14239. /// 城市信息 Init
  14240. /// </summary>
  14241. /// <param name="dto"></param>
  14242. /// <returns></returns>
  14243. [HttpPost]
  14244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14245. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14246. {
  14247. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14248. RefAsync<int> total = 0;
  14249. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14250. .Where(it => it.CountriesId == dto.CountiesId)
  14251. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14252. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14253. .Select(it => new { id = it.Id, name = it.Name_CN })
  14254. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14255. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14256. }
  14257. /// <summary>
  14258. /// 查看邀请方
  14259. /// 团组名称 Init
  14260. /// </summary>
  14261. /// <param name="dto"></param>
  14262. /// <returns></returns>
  14263. [HttpPost]
  14264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14265. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14266. {
  14267. var watch = new Stopwatch();
  14268. watch.Start();
  14269. RefAsync<int> total = 0;
  14270. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14271. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14272. .Where((oa, di) => oa.IsDel == 0)
  14273. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14274. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14275. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14276. .Distinct()
  14277. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14278. watch.Stop();
  14279. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14280. }
  14281. /// <summary>
  14282. /// 查看邀请方
  14283. /// 团组 & 邀请方信息
  14284. /// </summary>
  14285. /// <param name="dto"></param>
  14286. /// <returns></returns>
  14287. [HttpPost]
  14288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14289. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14290. {
  14291. var watch = new Stopwatch();
  14292. watch.Start();
  14293. RefAsync<int> total = 0;
  14294. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14295. .AS("Grp_DelegationInfo")
  14296. .Includes(x => x.InvitingInfos)
  14297. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14298. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14299. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14300. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14301. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14302. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14303. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14304. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14305. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14306. infos.ForEach(x =>
  14307. {
  14308. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14309. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14310. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14311. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14312. });
  14313. watch.Stop();
  14314. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14315. }
  14316. #endregion
  14317. #region 报批行程
  14318. /// <summary>
  14319. /// 报批行程初始化
  14320. /// </summary>
  14321. /// <param name="dto"></param>
  14322. /// <returns></returns>
  14323. [HttpPost]
  14324. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14325. {
  14326. const int chiNumber = 5;
  14327. var jw = JsonView(false);
  14328. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14329. var group = groupList.First();
  14330. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14331. group = groupList.First(x => x.Id == diid);
  14332. if (group == null)
  14333. {
  14334. jw.Msg = "暂无团组!";
  14335. return Ok(jw);
  14336. }
  14337. var data = new
  14338. {
  14339. groupList = groupList.Select(x => new
  14340. {
  14341. x.TeamName,
  14342. x.Id
  14343. }),
  14344. content = new ArrayList(),
  14345. groupInfo = new
  14346. {
  14347. group.VisitDays,
  14348. group.TourCode,
  14349. group.VisitPNumber,
  14350. group.TeamName,
  14351. group.Id,
  14352. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14353. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14354. },
  14355. };
  14356. var resultArr = new ArrayList();
  14357. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14358. if (content.Count == 0)
  14359. {
  14360. var stay = "-";
  14361. var cityPath = "-";
  14362. //添加城市路径以及住宿地
  14363. //黑屏代码数据
  14364. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14365. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14366. {
  14367. jw = JsonView(true, "黑屏代码有误!", data);
  14368. return Ok(jw);
  14369. }
  14370. foreach (DataRow row in dtBlack.Rows)
  14371. {
  14372. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14373. {
  14374. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14375. return Ok(jw);
  14376. }
  14377. }
  14378. //黑屏代码获取时间区间
  14379. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14380. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14381. _sqlSugar.BeginTran();
  14382. for (int i = 0; i < timeArr.Count; i++)
  14383. {
  14384. stay = "-";
  14385. cityPath = "-";
  14386. DateTime NewData = DateTime.Parse(timeArr[i]);
  14387. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14388. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14389. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14390. if (tbSelect.Length > 0)
  14391. {
  14392. List<string> threeCodeStr = new List<string>();
  14393. foreach (var item in tbSelect)
  14394. {
  14395. var threeCode = item["Three"].ToString() ?? "";
  14396. if (threeCode.Length == 6)
  14397. {
  14398. var start = threeCode.Substring(0, 3);
  14399. var end = threeCode.Substring(3, 3);
  14400. if (threeCodeStr.Count == 0)
  14401. {
  14402. threeCodeStr.Add(start);
  14403. threeCodeStr.Add(end);
  14404. }
  14405. else
  14406. {
  14407. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14408. {
  14409. threeCodeStr.Add(end);
  14410. }
  14411. else
  14412. {
  14413. threeCodeStr.Add(start);
  14414. threeCodeStr.Add(end);
  14415. }
  14416. }
  14417. }
  14418. }
  14419. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14420. var last = threeCodeStr.Last();
  14421. foreach (var item in threeCodeStr)
  14422. {
  14423. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14424. if (item.Equals(last))
  14425. {
  14426. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14427. }
  14428. }
  14429. cityPath = cityPath.Trim('-');
  14430. }
  14431. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14432. appro.Diid = diid ?? -1;
  14433. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14434. appro.Id = thisId;
  14435. appro.CreateUserId = dto.UserId;
  14436. appro.CreateTime = DateTime.Now;
  14437. content.Add(appro);
  14438. }
  14439. _sqlSugar.CommitTran();
  14440. }
  14441. foreach (var x in content)
  14442. {
  14443. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14444. if (chiList.Count < chiNumber)
  14445. {
  14446. for (int i = chiList.Count; i < chiNumber; i++)
  14447. {
  14448. chiList.Add(new Grp_ApprovalTravelDetails());
  14449. }
  14450. }
  14451. resultArr.Add(new
  14452. {
  14453. x.Id,
  14454. x.Date,
  14455. x.Diid,
  14456. chiList = chiList.Select(x1 => new
  14457. {
  14458. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14459. x1.Details,
  14460. x1.ParentId,
  14461. x1.Id
  14462. })
  14463. });
  14464. }
  14465. data = data with
  14466. {
  14467. content = resultArr,
  14468. };
  14469. jw = JsonView(true, "获取成功!", data);
  14470. return Ok(jw);
  14471. }
  14472. /// <summary>
  14473. /// 报批行程删除
  14474. /// </summary>
  14475. /// <param name="dto"></param>
  14476. /// <returns></returns>
  14477. [HttpPost]
  14478. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14479. {
  14480. var jw = JsonView(false);
  14481. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14482. if (group == null)
  14483. {
  14484. jw.Msg = "团组参数有误!";
  14485. return Ok(jw);
  14486. }
  14487. try
  14488. {
  14489. _sqlSugar.BeginTran();
  14490. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14491. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14492. {
  14493. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14494. DeleteUserId = dto.uesrId,
  14495. IsDel = 1
  14496. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14497. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14498. {
  14499. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14500. DeleteUserId = dto.uesrId,
  14501. IsDel = 1
  14502. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14503. _sqlSugar.CommitTran();
  14504. jw = JsonView(true, "删除成功");
  14505. }
  14506. catch (Exception ex)
  14507. {
  14508. jw = JsonView(false, ex.Message);
  14509. }
  14510. return Ok(jw);
  14511. }
  14512. /// <summary>
  14513. /// 报批行程保存
  14514. /// </summary>
  14515. /// <param name="dto"></param>
  14516. /// <returns></returns>
  14517. [HttpPost]
  14518. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14519. {
  14520. var jw = JsonView(false);
  14521. var Find = dto.Arr.Find(x => x.id == 0);
  14522. if (Find != null)
  14523. {
  14524. jw.Msg = "生成的ID为0!";
  14525. return Ok(jw);
  14526. }
  14527. foreach (var item in dto.Arr)
  14528. {
  14529. foreach (var chi in item.chiList)
  14530. {
  14531. if (chi.parentId == 0)
  14532. {
  14533. chi.parentId = item.id;
  14534. }
  14535. }
  14536. }
  14537. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14538. _sqlSugar.BeginTran();
  14539. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14540. {
  14541. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14542. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14543. {
  14544. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14545. DeleteUserId = dto.UserId,
  14546. IsDel = 1
  14547. }).ExecuteCommand();
  14548. }
  14549. try
  14550. {
  14551. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14552. {
  14553. CreateTime = DateTime.Now,
  14554. CreateUserId = dto.UserId,
  14555. Details = x.details,
  14556. ParentId = x.parentId,
  14557. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14558. Remark = "",
  14559. IsDel = 0
  14560. }).ToList()).ExecuteCommand();
  14561. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14562. {
  14563. Id = x.id,
  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. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14568. {
  14569. Details = x.Details,
  14570. ParentId = x.ParentId,
  14571. Time = x.Time
  14572. }).ExecuteCommand();
  14573. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14574. {
  14575. Id = x.id,
  14576. Date = x.date,
  14577. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14578. {
  14579. Date = x.Date
  14580. }).ExecuteCommand();
  14581. _sqlSugar.CommitTran();
  14582. jw = JsonView(true, "保存成功!");
  14583. }
  14584. catch (Exception ex)
  14585. {
  14586. _sqlSugar.RollbackTran();
  14587. jw = JsonView(false, "保存失败!" + ex.Message);
  14588. }
  14589. return Ok(jw);
  14590. }
  14591. /// <summary>
  14592. /// 报批行程生成
  14593. /// </summary>
  14594. /// <param name="dto"></param>
  14595. /// <returns></returns>
  14596. [HttpPost]
  14597. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14598. {
  14599. var jw = JsonView(false);
  14600. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14601. if (group == null)
  14602. {
  14603. jw.Msg = "暂无该团组!";
  14604. return Ok(jw);
  14605. }
  14606. //黑屏代码数据
  14607. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14608. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14609. {
  14610. jw.Msg = "黑屏代码有误!";
  14611. return Ok(jw);
  14612. }
  14613. foreach (DataRow row in dtBlack.Rows)
  14614. {
  14615. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14616. {
  14617. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14618. return Ok(jw);
  14619. }
  14620. }
  14621. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14622. var resultArr = new ArrayList();
  14623. if (officialActivitiesArr.Count == 0)
  14624. {
  14625. jw.Msg = "暂无公务出访信息!";
  14626. return Ok(jw);
  14627. }
  14628. try
  14629. {
  14630. _sqlSugar.BeginTran();
  14631. DeleteApprovalJourney(new
  14632. Domain.Dtos.Groups.DeleteApprovalJourney
  14633. {
  14634. Diid = dto.Diid,
  14635. uesrId = dto.Userid
  14636. });
  14637. var stay = "-";
  14638. var cityPath = "-";
  14639. //添加城市路径以及住宿地
  14640. //黑屏代码获取时间区间
  14641. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14642. var empty = "【未收入该三字码!请机票同事录入】";
  14643. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14644. for (int i = 0; i < timeArr.Count; i++)
  14645. {
  14646. stay = "-";
  14647. cityPath = "-";
  14648. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14649. DateTime NewData = DateTime.Parse(timeArr[i]);
  14650. 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();
  14651. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14652. if (tbSelect.Length > 0)
  14653. {
  14654. List<string> threeCodeStr = new List<string>();
  14655. bool isTrade = false;
  14656. string trip = string.Empty;
  14657. var rowLast = tbSelect.Last();
  14658. var rowFirst = tbSelect.First();
  14659. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14660. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14661. var takeOffTime = DateTime.Parse(timeArr[i]);
  14662. var fallToTime = DateTime.Parse(timeArr[i]);
  14663. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14664. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14665. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14666. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14667. foreach (var item in tbSelect)
  14668. {
  14669. var start = string.Empty;
  14670. var end = string.Empty;
  14671. var threeCode = item["Three"].ToString() ?? "";
  14672. if (threeCode.Length == 6)
  14673. {
  14674. start = threeCode.Substring(0, 3);
  14675. end = threeCode.Substring(3, 3);
  14676. if (threeCodeStr.Count == 0)
  14677. {
  14678. threeCodeStr.Add(start);
  14679. threeCodeStr.Add(end);
  14680. }
  14681. else
  14682. {
  14683. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14684. {
  14685. threeCodeStr.Add(end);
  14686. }
  14687. else
  14688. {
  14689. threeCodeStr.Add(start);
  14690. threeCodeStr.Add(end);
  14691. }
  14692. }
  14693. }
  14694. //处理机票信息
  14695. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14696. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14697. if (start_Object == null)
  14698. {
  14699. start_Object = new Res_ThreeCode()
  14700. {
  14701. AirPort = empty,
  14702. AirPort_En = empty,
  14703. City = empty,
  14704. Country = empty,
  14705. Four = empty,
  14706. Three = empty,
  14707. };
  14708. }
  14709. if (end_Object == null)
  14710. {
  14711. end_Object = new Res_ThreeCode()
  14712. {
  14713. AirPort = empty,
  14714. AirPort_En = empty,
  14715. City = empty,
  14716. Country = empty,
  14717. Four = empty,
  14718. Three = empty,
  14719. };
  14720. }
  14721. //机型判断
  14722. string airModel = item["AirModel"].ToString();
  14723. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14724. string flightTime = item["FlightTime"].ToString();
  14725. if (flightTime!.Contains(":"))
  14726. {
  14727. flightTime = flightTime.Replace(":", "小时");
  14728. flightTime += "分钟";
  14729. }
  14730. if (flightTime.Contains("H"))
  14731. {
  14732. flightTime = flightTime.Replace("H", "小时");
  14733. }
  14734. if (flightTime.Contains("M"))
  14735. {
  14736. flightTime = flightTime.Replace("M", "分钟");
  14737. }
  14738. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14739. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14740. {
  14741. flightTime = flightDataTime.Hour > 0
  14742. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14743. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14744. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14745. }
  14746. //航班号
  14747. string flightcode = item["Fliagtcode"].ToString();
  14748. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14749. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14750. if (aircompany == null)
  14751. {
  14752. aircompany = new Res_AirCompany
  14753. {
  14754. CnName = hsEmpty,
  14755. EnName = hsEmpty,
  14756. ShortCode = hsEmpty,
  14757. };
  14758. }
  14759. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14760. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14761. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14762. if (isTrade)
  14763. {
  14764. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14765. }
  14766. else
  14767. {
  14768. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14769. }
  14770. }
  14771. chiarr.Add(new Grp_ApprovalTravelDetails
  14772. {
  14773. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14774. CreateTime = DateTime.Now,
  14775. CreateUserId = dto.Userid,
  14776. ParentId = 0,
  14777. Details = trip
  14778. });
  14779. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14780. var last = threeCodeStr.Last();
  14781. foreach (var item in threeCodeStr)
  14782. {
  14783. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14784. if (item.Equals(last))
  14785. {
  14786. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14787. }
  14788. }
  14789. cityPath = cityPath.Trim('-');
  14790. }
  14791. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14792. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14793. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14794. appro.Diid = dto.Diid;
  14795. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14796. appro.Id = thisId;
  14797. appro.CreateUserId = dto.Userid;
  14798. appro.CreateTime = DateTime.Now;
  14799. foreach (var item in gwinfo)
  14800. {
  14801. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14802. chi.Details = "拜访" + item.Client;
  14803. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14804. {
  14805. chi.Details += "," + item.ReqSample;
  14806. }
  14807. chi.ParentId = thisId;
  14808. chi.Time = item.Time;
  14809. chiarr.Add(chi);
  14810. }
  14811. if (chiarr.Count < 5)
  14812. {
  14813. for (int j = chiarr.Count; j < 5; j++)
  14814. {
  14815. chiarr.Add(new
  14816. Grp_ApprovalTravelDetails());
  14817. }
  14818. }
  14819. resultArr.Add(new
  14820. {
  14821. appro.Id,
  14822. appro.Date,
  14823. appro.Diid,
  14824. chiList = chiarr.Select(x1 => new
  14825. {
  14826. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14827. x1.Details,
  14828. x1.ParentId,
  14829. x1.Id
  14830. })
  14831. });
  14832. }
  14833. _sqlSugar.CommitTran();
  14834. jw = JsonView(true, "生成成功!", resultArr);
  14835. }
  14836. catch (Exception ex)
  14837. {
  14838. jw.Code = 400;
  14839. jw.Msg = "生成失败!" + ex.Message;
  14840. }
  14841. return Ok(jw);
  14842. }
  14843. /// <summary>
  14844. /// 报批行程word导出
  14845. /// </summary>
  14846. /// <param name="dto"></param>
  14847. /// <returns></returns>
  14848. [HttpPost]
  14849. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14850. {
  14851. var jw = JsonView(false);
  14852. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14853. if (group == null)
  14854. {
  14855. jw.Msg = "暂无该团组!";
  14856. return Ok(jw);
  14857. }
  14858. //模板路径
  14859. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14860. //载入模板
  14861. Document doc = new Document(tempPath);
  14862. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14863. //获取所填表格的序数
  14864. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14865. Aspose.Words.Tables.Row titleRowClone = null;
  14866. Aspose.Words.Tables.Row CenterRowClone = null;
  14867. int index = 0;
  14868. int indexChi = 0;
  14869. int SetIndex = 0;
  14870. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14871. //获取数据,放到datatable
  14872. foreach (var item in ApprovalTravelArr)
  14873. {
  14874. if (index > 0)
  14875. {
  14876. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14877. tableOne.AppendChild(titleRowClone);
  14878. }
  14879. var textTime = item.Date;
  14880. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14881. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14882. SetIndex++;
  14883. if (ChiRep.Count > 0)
  14884. {
  14885. foreach (var itemChi in ChiRep)
  14886. {
  14887. var txtTime = itemChi.Time;
  14888. var txtDetail = itemChi.Details;
  14889. if (indexChi > 0)
  14890. {
  14891. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14892. tableOne.AppendChild(CenterRowClone);
  14893. }
  14894. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14895. {
  14896. SetCells(tableOne, doc, SetIndex, 0, "");
  14897. SetCells(tableOne, doc, SetIndex, 1, "");
  14898. indexChi++;
  14899. SetIndex++;
  14900. break;
  14901. }
  14902. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14903. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14904. indexChi++;
  14905. SetIndex++;
  14906. }
  14907. }
  14908. else
  14909. {
  14910. if (indexChi > 0)
  14911. {
  14912. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14913. tableOne.AppendChild(CenterRowClone);
  14914. }
  14915. SetCells(tableOne, doc, SetIndex, 0, "");
  14916. SetCells(tableOne, doc, SetIndex, 1, "");
  14917. indexChi++;
  14918. SetIndex++;
  14919. }
  14920. index++;
  14921. }
  14922. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  14923. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14924. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14925. jw.Code = 200;
  14926. jw.Msg = "";
  14927. return Ok(jw);
  14928. }
  14929. private string intToString(int numberVal)
  14930. {
  14931. string numberval = numberVal.ToString();
  14932. Dictionary<char, string> Number = new Dictionary<char, string>();
  14933. Number.Add('1', "一");
  14934. Number.Add('2', "二");
  14935. Number.Add('3', "三");
  14936. Number.Add('4', "四");
  14937. Number.Add('5', "五");
  14938. Number.Add('6', "六");
  14939. Number.Add('7', "七");
  14940. Number.Add('8', "八");
  14941. Number.Add('9', "九");
  14942. string stringNumberVal = string.Empty;
  14943. for (int i = 0; i < numberval.Length; i++)
  14944. {
  14945. if (i == 0)
  14946. {
  14947. stringNumberVal += Number[numberval[i]];
  14948. }
  14949. else if (i >= 1)
  14950. {
  14951. if (numberval[i] == '0')
  14952. {
  14953. stringNumberVal = "十";
  14954. }
  14955. else
  14956. {
  14957. stringNumberVal += "十" + Number[numberval[i]];
  14958. }
  14959. }
  14960. }
  14961. return stringNumberVal;
  14962. }
  14963. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  14964. {
  14965. //获取table中的某个单元格,从0开始
  14966. Cell lshCell = table.Rows[rows].Cells[cells];
  14967. //将单元格中段落移除
  14968. foreach (Node item in lshCell.Paragraphs)
  14969. {
  14970. lshCell.Paragraphs.Remove(item);
  14971. }
  14972. if (val.Contains("\r\n"))
  14973. {
  14974. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  14975. foreach (var item in spArr)
  14976. {
  14977. //新建一个段落
  14978. Paragraph p = new Paragraph(doc);
  14979. var r = new Run(doc, item);
  14980. //把设置的值赋给之前新建的段落
  14981. p.AppendChild(r);
  14982. //将此段落加到单元格内
  14983. lshCell.AppendChild(p);
  14984. }
  14985. }
  14986. else
  14987. {
  14988. //新建一个段落
  14989. Paragraph p = new Paragraph(doc);
  14990. var r = new Run(doc, val);
  14991. //把设置的值赋给之前新建的段落
  14992. p.AppendChild(r);
  14993. //将此段落加到单元格内
  14994. lshCell.AppendChild(p);
  14995. }
  14996. }
  14997. [HttpPost]
  14998. public async Task<IActionResult> ServerHttp(string paramStr)
  14999. {
  15000. paramStr = paramStr.TrimEnd('\'');
  15001. paramStr = paramStr.TrimStart('\'');
  15002. JsonView jw = JsonView(false);
  15003. JObject param = JObject.Parse(paramStr);
  15004. if (!param.ContainsKey("url"))
  15005. {
  15006. jw.Msg = "url null";
  15007. return Ok(jw);
  15008. }
  15009. string url = param["url"]!.ToString();
  15010. var methon = "get";
  15011. Dictionary<string, string> headValues = null;
  15012. string bodyStr = string.Empty;
  15013. if (param.ContainsKey("methon"))
  15014. {
  15015. methon = param["methon"]!.ToString().ToLower();
  15016. }
  15017. if (param.ContainsKey("header"))
  15018. {
  15019. var header = param["header"]!.ToString();
  15020. JObject headerJobject = JObject.Parse(header);
  15021. headValues = new Dictionary<string, string>();
  15022. foreach (JProperty item in headerJobject.Properties())
  15023. {
  15024. var value = item.Value.ToString();
  15025. var head = item.Path;
  15026. headValues.Add(head, value);
  15027. }
  15028. }
  15029. HttpClient client = new HttpClient();
  15030. string responseString = string.Empty;
  15031. StringContent content = null;
  15032. if (headValues != null)
  15033. {
  15034. foreach (var item in headValues.Keys)
  15035. {
  15036. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15037. {
  15038. if (param.ContainsKey("body"))
  15039. {
  15040. bodyStr = param["body"]!.ToString();
  15041. }
  15042. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15043. }
  15044. else
  15045. {
  15046. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15047. }
  15048. }
  15049. }
  15050. try
  15051. {
  15052. if (methon == "get")
  15053. {
  15054. responseString = await client.GetStringAsync(url);
  15055. }
  15056. else if (methon == "post")
  15057. {
  15058. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15059. {
  15060. Content = content
  15061. };
  15062. var response = await client.SendAsync(request);
  15063. try
  15064. {
  15065. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15066. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15067. {
  15068. using (StreamReader reader = new StreamReader(gzipStream))
  15069. {
  15070. responseString = await reader.ReadToEndAsync();
  15071. }
  15072. }
  15073. }
  15074. catch (Exception)
  15075. {
  15076. responseString = await response.Content.ReadAsStringAsync();
  15077. }
  15078. }
  15079. else
  15080. {
  15081. responseString = "methon error";
  15082. }
  15083. jw = JsonView(true, "success", responseString);
  15084. }
  15085. catch (Exception ex)
  15086. {
  15087. jw.Msg = "error " + ex.Message;
  15088. jw.Data = ex.StackTrace;
  15089. }
  15090. finally
  15091. {
  15092. client.Dispose();
  15093. }
  15094. return Ok(jw);
  15095. }
  15096. #endregion
  15097. #region 团组接待意见调查
  15098. /// <summary>
  15099. /// 团组接待意见调查 - 信息管理
  15100. /// 基础数据(团组)
  15101. /// </summary>
  15102. /// <param name="dto"></param>
  15103. /// <returns></returns>
  15104. [HttpGet]
  15105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15106. public async Task<IActionResult> OpinionaireInit()
  15107. {
  15108. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15109. .Select(x => new
  15110. {
  15111. x.Id,
  15112. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15113. })
  15114. .OrderByDescending(x => x.Id)
  15115. .ToListAsync();
  15116. return Ok(JsonView(groupData, groupData.Count));
  15117. }
  15118. /// <summary>
  15119. /// 团组接待意见调查 - 信息管理
  15120. /// 列表
  15121. /// </summary>
  15122. /// <param name="groupId"></param>
  15123. /// <returns></returns>
  15124. [HttpGet("{groupId}")]
  15125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15126. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15127. {
  15128. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15129. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15130. .Select(x => new
  15131. {
  15132. x.Id,
  15133. x.TourGuideName,
  15134. x.CityName,
  15135. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15136. x.CreateTime
  15137. })
  15138. .OrderBy(x => x.Id)
  15139. .ToListAsync();
  15140. return Ok(JsonView(data));
  15141. }
  15142. /// <summary>
  15143. /// 团组接待意见调查 - 信息管理
  15144. /// 保存
  15145. /// </summary>
  15146. /// <param name="dto"></param>
  15147. /// <returns></returns>
  15148. [HttpPost]
  15149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15150. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15151. {
  15152. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15153. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15154. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15155. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15156. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15157. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15158. _opinionaireRep.BeginTran();
  15159. if (addData != null && addData.Count > 0)
  15160. {
  15161. foreach (var item in addData)
  15162. {
  15163. item.CreateUserId = currUserInfo.UserId;
  15164. item.DiId = dto.DiId;
  15165. }
  15166. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15167. }
  15168. if (updData != null && updData.Count > 0)
  15169. {
  15170. var upd = await _opinionaireRep._sqlSugar
  15171. .Updateable(updData)
  15172. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15173. .WhereColumns(x => new { x.Id })
  15174. .ExecuteCommandAsync();
  15175. }
  15176. _opinionaireRep.CommitTran();
  15177. return Ok(JsonView("操作成功!"));
  15178. }
  15179. /// <summary>
  15180. /// 团组接待意见调查 - 信息管理
  15181. /// 删除
  15182. /// </summary>
  15183. /// <param name="id"></param>
  15184. /// <returns></returns>
  15185. [HttpDelete("{id}")]
  15186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15187. public async Task<IActionResult> OpinionaireManageDel(int id)
  15188. {
  15189. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15190. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15191. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15192. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15193. if (!del) return Ok(JsonView("操作失败!"));
  15194. return Ok(JsonView("操作成功!"));
  15195. }
  15196. /// <summary>
  15197. /// 团组接待意见调查 - 用户
  15198. /// 列表
  15199. /// </summary>
  15200. /// <param name="id"></param>
  15201. /// <returns></returns>
  15202. [HttpGet("{diId}")]
  15203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15204. public async Task<IActionResult> OpinionaireUserList(int diId)
  15205. {
  15206. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15207. var sql = string.Format(@"
  15208. SELECT
  15209. o.Id,
  15210. o.DiId,
  15211. di.TeamName AS 'GroupName',
  15212. di.VisitPNumber AS 'PeopleNumber',
  15213. di.ClientName AS 'LeadGroup',
  15214. di.VisitCountry AS 'Travel',
  15215. di.VisitDays AS 'Days',
  15216. o.CityName,
  15217. o.TourGuideName,
  15218. o.Catering,
  15219. o.CateringReason,
  15220. o.Stay,
  15221. o.StayReason,
  15222. o.[Route],
  15223. o.RouteReason,
  15224. o.OfficialActivity,
  15225. o.OfficialActivityReason,
  15226. o.TourGuide,
  15227. o.TourGuideReason,
  15228. o.[Translate],
  15229. o.TranslateReason,
  15230. o.Trip,
  15231. o.TripReason,
  15232. o.ESFileName,
  15233. o.SignatureDate,
  15234. o.Remark
  15235. FROM
  15236. Grp_Opinionaire o
  15237. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15238. WHERE
  15239. o.IsDel = 0
  15240. AND o.DiId = {0}
  15241. ORDER BY
  15242. o.Id ASC", diId);
  15243. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15244. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15245. return Ok(JsonView(data));
  15246. }
  15247. /// <summary>
  15248. /// 团组接待意见调查 - 用户
  15249. /// 保存
  15250. /// </summary>
  15251. /// <param name="id"></param>
  15252. /// <returns></returns>
  15253. [HttpPost]
  15254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15255. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15256. {
  15257. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15258. foreach (var item in dto)
  15259. {
  15260. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15261. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15262. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15263. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15264. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15265. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15266. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15267. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15268. }
  15269. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15270. if (!Directory.Exists(filePathBase))
  15271. {
  15272. Directory.CreateDirectory(filePathBase);
  15273. }
  15274. #region 上传文件
  15275. var filePaths = new List<string>();
  15276. foreach (var item in dto)
  15277. {
  15278. var file = item.File;
  15279. // 将文件保存到指定位置
  15280. var filePath = Path.Combine(filePathBase, file.FileName);
  15281. using (var stream = new FileStream(filePath, FileMode.Create))
  15282. {
  15283. await file.CopyToAsync(stream);
  15284. }
  15285. //验证文件是否上传成功
  15286. if (!System.IO.File.Exists(filePath))
  15287. {
  15288. foreach (var filePathStr in filePaths)
  15289. {
  15290. System.IO.File.Delete(filePathStr);
  15291. }
  15292. return Ok(JsonView(false, "文件上传失败!"));
  15293. }
  15294. item.ESFileName = file.FileName;
  15295. }
  15296. #endregion
  15297. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15298. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15299. .UpdateColumns(x => new
  15300. {
  15301. x.Catering,
  15302. x.CateringReason,
  15303. x.Stay,
  15304. x.StayReason,
  15305. x.Route,
  15306. x.RouteReason,
  15307. x.OfficialActivity,
  15308. x.OfficialActivityReason,
  15309. x.TourGuide,
  15310. x.TourGuideReason,
  15311. x.Translate,
  15312. x.TranslateReason,
  15313. x.Trip,
  15314. x.TripReason,
  15315. x.ESFileName,
  15316. x.SignatureDate,
  15317. x.Remark
  15318. })
  15319. .WhereColumns(x => new { x.Id })
  15320. .ExecuteCommandAsync();
  15321. if (upd < 1)
  15322. {
  15323. foreach (var filePathStr in filePaths)
  15324. {
  15325. System.IO.File.Delete(filePathStr);
  15326. }
  15327. return Ok(JsonView(false));
  15328. }
  15329. return Ok(JsonView(true));
  15330. }
  15331. #endregion
  15332. // /// <summary>
  15333. // ///
  15334. // /// </summary>
  15335. // /// <param name="_dto"></param>
  15336. // /// <returns></returns>
  15337. // [HttpPost]
  15338. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15339. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15340. // {
  15341. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15342. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15343. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15344. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15345. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15346. // dic_psg.Add("客人", 974);
  15347. // dic_psg.Add("司机", 975);
  15348. // dic_psg.Add("导游", 976);
  15349. // dic_psg.Add("公司内部人员", 977);
  15350. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15351. // foreach (var item in list_visa)
  15352. // {
  15353. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15354. // temp.Id = item.Id;
  15355. // temp.DIId = item.DIId;
  15356. // temp.VisaClient = item.VisaClient;
  15357. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15358. // temp.VisaCurrency = item.VisaCurrency;
  15359. // temp.IsThird = item.IsThird;
  15360. // if (dic_psg.ContainsKey(item.PassengerType))
  15361. // {
  15362. // temp.PassengerType = dic_psg[item.PassengerType];
  15363. // }
  15364. // else {
  15365. // temp.PassengerType = -1;
  15366. // }
  15367. // temp.VisaNumber = item.VisaNumber;
  15368. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15369. // temp.CreateUserId = item.Operators;
  15370. // DateTime dt_ct;
  15371. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15372. // if (b_ct)
  15373. // {
  15374. // temp.CreateTime = dt_ct;
  15375. // }
  15376. // else
  15377. // {
  15378. // temp.CreateTime = DateTime.Now;
  15379. // }
  15380. // temp.DeleteTime = "";
  15381. // temp.DeleteUserId = 0;
  15382. // temp.Remark = item.Remark;
  15383. // if (string.IsNullOrEmpty(temp.Remark)) {
  15384. // temp.Remark = "";
  15385. // }
  15386. // temp.IsDel = item.IsDel;
  15387. // temp.VisaDescription = item.VisaAttachment;
  15388. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15389. //([Id]
  15390. // ,[DIId]
  15391. // ,[VisaClient]
  15392. // ,[VisaPrice]
  15393. // ,[VisaCurrency]
  15394. // ,[IsThird]
  15395. // ,[PassengerType]
  15396. // ,[VisaNumber]
  15397. // ,[VisaFreeNumber]
  15398. // ,[CreateUserId]
  15399. // ,[CreateTime]
  15400. // ,[DeleteTime]
  15401. // ,[DeleteUserId]
  15402. // ,[Remark]
  15403. // ,[IsDel]
  15404. // ,[visaDescription])
  15405. // VALUES
  15406. // ({0},{1},'{2}',{3},{4}
  15407. //,{5},{6},{7},{8},{9}
  15408. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15409. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15410. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15411. //);
  15412. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15413. // }
  15414. // return Ok(JsonView(true, "操作成功!"));
  15415. // }
  15416. /// <summary>
  15417. /// 123132123
  15418. /// </summary>
  15419. /// <param name="_dto"></param>
  15420. /// <returns></returns>
  15421. [HttpPost]
  15422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15423. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15424. {
  15425. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15426. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15427. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15428. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15429. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15430. dicDetail.Add(789, 1034);
  15431. dicDetail.Add(790, 1035);
  15432. dicDetail.Add(791, 1036);
  15433. dicDetail.Add(792, 1037);
  15434. dicDetail.Add(793, 1038);
  15435. dicDetail.Add(794, 1039);
  15436. dicDetail.Add(795, 1040);
  15437. dicDetail.Add(796, 1041);
  15438. dicDetail.Add(797, 1042);
  15439. dicDetail.Add(798, 1043);
  15440. dicDetail.Add(801, 1044);
  15441. dicDetail.Add(802, 1045);
  15442. dicDetail.Add(803, 1046);
  15443. Dictionary<int, int> dic = new Dictionary<int, int>();
  15444. dic.Add(806, 1027);
  15445. dic.Add(807, 1028);
  15446. dic.Add(808, 1029);
  15447. dic.Add(809, 1030);
  15448. dic.Add(810, 1031);
  15449. dic.Add(811, 1032);
  15450. dic.Add(812, 1033);
  15451. foreach (var item in list_visa)
  15452. {
  15453. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15454. temp.Coefficient = item.coefficient;
  15455. DateTime dtCrt;
  15456. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15457. if (b1)
  15458. {
  15459. temp.CreateTime = dtCrt;
  15460. }
  15461. else
  15462. {
  15463. temp.CreateTime = DateTime.Now;
  15464. }
  15465. temp.CreateUserId = item.Operators;
  15466. temp.DeleteTime = "";
  15467. temp.DeleteUserId = 0;
  15468. temp.DiId = int.Parse(item.DIID);
  15469. temp.FilePath = item.FilePath;
  15470. temp.IsDel = item.IsDel;
  15471. temp.Price = item.Price;
  15472. temp.PriceCount = 1;
  15473. temp.PriceCurrency = item.Currency;
  15474. int detailId = 0;
  15475. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15476. {
  15477. detailId = dicDetail[item.PriceTypeDetail];
  15478. }
  15479. temp.PriceDetailType = detailId;
  15480. temp.PriceDt = DateTime.Now;
  15481. temp.PriceName = item.PriceName;
  15482. temp.PriceSum = item.Price;
  15483. int tid = 0;
  15484. if (dic.ContainsKey(item.PriceType))
  15485. {
  15486. tid = dic[item.PriceType];
  15487. }
  15488. temp.PriceType = tid;
  15489. temp.Remark = item.Remark;
  15490. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15491. }
  15492. return Ok(JsonView(true, "操作成功!"));
  15493. }
  15494. [HttpPost]
  15495. public IActionResult TimeTest()
  15496. {
  15497. var jw = JsonView(false, "error");
  15498. _sqlSugar.BeginTran();
  15499. try
  15500. {
  15501. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  15502. .Select(x => new Crm_NewClientData
  15503. {
  15504. Id = x.Id,
  15505. Client = x.Client,
  15506. Contact = x.Contact,
  15507. Location = x.Location,
  15508. })
  15509. .ToList();
  15510. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  15511. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  15512. Stopwatch stopwatch = new Stopwatch();
  15513. // 开始计时
  15514. stopwatch.Start();
  15515. foreach (var item in clientList)
  15516. {
  15517. EncryptionProcessor.DecryptProperties(item);
  15518. }
  15519. stopwatch.Stop();
  15520. jw.Code = 200;
  15521. jw.Data = stopwatch.ElapsedMilliseconds;
  15522. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  15523. }
  15524. catch (Exception ex)
  15525. {
  15526. jw.Code = 400;
  15527. jw.Msg = ex.Message;
  15528. }
  15529. return Ok(jw);
  15530. }
  15531. }
  15532. }