GroupsController.cs 830 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935
  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.Dtos.CRM;
  27. using OASystem.Domain.Dtos.FileDto;
  28. using OASystem.Domain.Dtos.Financial;
  29. using OASystem.Domain.Dtos.Groups;
  30. using OASystem.Domain.Entities.Customer;
  31. using OASystem.Domain.Entities.Financial;
  32. using OASystem.Domain.Entities.Groups;
  33. using OASystem.Domain.ViewModels;
  34. using OASystem.Domain.ViewModels.Financial;
  35. using OASystem.Domain.ViewModels.Groups;
  36. using OASystem.Domain.ViewModels.Statistics;
  37. using OASystem.Infrastructure.Repositories.CRM;
  38. using OASystem.Infrastructure.Repositories.Financial;
  39. using OASystem.Infrastructure.Repositories.Groups;
  40. using OfficeOpenXml;
  41. using Org.BouncyCastle.Asn1.Ocsp;
  42. using Quartz.Util;
  43. using SqlSugar;
  44. using SqlSugar.Extensions;
  45. using System.Collections;
  46. using System.Data;
  47. using System.Data.OleDb;
  48. using System.Diagnostics;
  49. using System.Globalization;
  50. using System.IO;
  51. using System.IO.Compression;
  52. using System.Net.Http;
  53. using System.Reflection.PortableExecutable;
  54. using System.Security.Cryptography;
  55. using Ubiety.Dns.Core;
  56. using static NPOI.POIFS.Crypt.CryptoFunctions;
  57. using static OASystem.API.OAMethodLib.JWTHelper;
  58. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  59. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  60. using Bookmark = Aspose.Words.Bookmark;
  61. using Cell = Aspose.Words.Tables.Cell;
  62. using Table = Aspose.Words.Tables.Table;
  63. namespace OASystem.API.Controllers
  64. {
  65. /// <summary>
  66. /// 团组相关
  67. /// </summary>
  68. //[Authorize]
  69. [Route("api/[controller]/[action]")]
  70. public class GroupsController : ControllerBase
  71. {
  72. private readonly ILogger<GroupsController> _logger;
  73. private readonly GrpScheduleRepository _grpScheduleRep;
  74. private readonly IMapper _mapper;
  75. private readonly DelegationInfoRepository _groupRepository;
  76. private readonly TaskAssignmentRepository _taskAssignmentRep;
  77. private readonly AirTicketResRepository _airTicketResRep;
  78. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  79. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  80. private readonly DelegationEnDataRepository _delegationEnDataRep;
  81. private readonly DelegationVisaRepository _delegationVisaRep;
  82. private readonly VisaPriceRepository _visaPriceRep;
  83. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  84. private readonly HotelPriceRepository _hotelPriceRep;
  85. private readonly CustomersRepository _customersRep;
  86. private readonly MessageRepository _message;
  87. private readonly SqlSugarClient _sqlSugar;
  88. private readonly TourClientListRepository _tourClientListRep;
  89. private readonly TeamRateRepository _teamRateRep;
  90. #region 成本相关
  91. private readonly CheckBoxsRepository _checkBoxs;
  92. private readonly GroupCostRepository _GroupCostRepository;
  93. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  94. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  95. #endregion
  96. private readonly SetDataRepository _setDataRep;
  97. private string url;
  98. private string path;
  99. private readonly EnterExitCostRepository _enterExitCostRep;
  100. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  101. private readonly UsersRepository _usersRep;
  102. private readonly IJuHeApiService _juHeApi;
  103. private readonly InvertedListRepository _invertedListRep;
  104. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  105. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  106. private readonly ThreeCodeRepository _threeCodeRepository;
  107. private readonly HotelInquiryRepository _hotelInquiryRep;
  108. private readonly FeeAuditRepository _feeAuditRep;
  109. private readonly VisaCommissionRepository _visaCommissionRep;
  110. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  111. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  112. private readonly List<CurrencyInfo> _currencyInit;
  113. private readonly List<int> _portTypeData;
  114. private readonly TableOperationRecordRepository _tableorRep;
  115. public GroupsController(
  116. ILogger<GroupsController> logger,
  117. IMapper mapper,
  118. IHubContext<ChatHub, IChatClient> hubContext,
  119. SqlSugarClient sqlSugar,
  120. GrpScheduleRepository grpScheduleRep,
  121. DelegationInfoRepository groupRepository,
  122. TaskAssignmentRepository taskAssignmentRep,
  123. AirTicketResRepository airTicketResRep,
  124. DecreasePaymentsRepository decreasePaymentsRep,
  125. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  126. DelegationEnDataRepository delegationEnDataRep,
  127. EnterExitCostRepository enterExitCostRep,
  128. DelegationVisaRepository delegationVisaRep,
  129. MessageRepository message,
  130. VisaPriceRepository visaPriceRep,
  131. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  132. CheckBoxsRepository checkBoxs,
  133. GroupCostRepository GroupCostRepository,
  134. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  135. GroupCostParameterRepository GroupCostParameterRepository,
  136. HotelPriceRepository hotelPriceRep,
  137. CustomersRepository customersRep,
  138. SetDataRepository setDataRep,
  139. TourClientListRepository tourClientListRep,
  140. TeamRateRepository teamRateRep,
  141. UsersRepository usersRep, IJuHeApiService juHeApi,
  142. InvertedListRepository invertedListRep,
  143. VisaFeeInfoRepository visaFeeInfoRep,
  144. TicketBlackCodeRepository ticketBlackCodeRep,
  145. HotelInquiryRepository hotelInquiryRep,
  146. ThreeCodeRepository threeCodeRepository,
  147. FeeAuditRepository feeAuditRep,
  148. VisaCommissionRepository visaCommissionRep,
  149. ForeignReceivablesRepository ffrRep,
  150. OpinionaireRepository opinionaireRep,
  151. TableOperationRecordRepository tableorRep
  152. )
  153. {
  154. _logger = logger;
  155. _mapper = mapper;
  156. _grpScheduleRep = grpScheduleRep;
  157. _groupRepository = groupRepository;
  158. _taskAssignmentRep = taskAssignmentRep;
  159. _airTicketResRep = airTicketResRep;
  160. _sqlSugar = sqlSugar;
  161. url = AppSettingsHelper.Get("ExcelBaseUrl");
  162. path = AppSettingsHelper.Get("ExcelBasePath");
  163. if (!System.IO.Directory.Exists(path))
  164. {
  165. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  166. }
  167. _decreasePaymentsRep = decreasePaymentsRep;
  168. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  169. _delegationEnDataRep = delegationEnDataRep;
  170. _enterExitCostRep = enterExitCostRep;
  171. _delegationVisaRep = delegationVisaRep;
  172. _message = message;
  173. _visaPriceRep = visaPriceRep;
  174. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  175. _checkBoxs = checkBoxs;
  176. _GroupCostRepository = GroupCostRepository;
  177. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  178. _GroupCostParameterRepository = GroupCostParameterRepository;
  179. _hotelPriceRep = hotelPriceRep;
  180. _customersRep = customersRep;
  181. _setDataRep = setDataRep;
  182. _tourClientListRep = tourClientListRep;
  183. _teamRateRep = teamRateRep;
  184. _hubContext = hubContext;
  185. _usersRep = usersRep;
  186. _juHeApi = juHeApi;
  187. _invertedListRep = invertedListRep;
  188. _visaFeeInfoRep = visaFeeInfoRep;
  189. _ticketBlackCodeRep = ticketBlackCodeRep;
  190. _hotelInquiryRep = hotelInquiryRep;
  191. _threeCodeRepository = threeCodeRepository;
  192. _feeAuditRep = feeAuditRep;
  193. _visaCommissionRep = visaCommissionRep;
  194. _ffrRep = ffrRep;
  195. _opinionaireRep = opinionaireRep;
  196. _currencyInit = new List<CurrencyInfo>()
  197. {
  198. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  199. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  200. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  201. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  202. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  203. };
  204. _portTypeData = new List<int>() { 2, 3 };
  205. _tableorRep = tableorRep;
  206. }
  207. #region 流程管控
  208. /// <summary>
  209. /// 获取团组流程管控信息
  210. /// </summary>
  211. /// <param name="paras">参数Json字符串</param>
  212. /// <returns></returns>
  213. [HttpPost]
  214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  215. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  216. {
  217. if (string.IsNullOrEmpty(_jsonDto.Paras))
  218. {
  219. return Ok(JsonView(false, "参数为空"));
  220. }
  221. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  222. if (_ScheduleDto != null)
  223. {
  224. if (_ScheduleDto.SearchType == 2)//获取列表
  225. {
  226. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  227. return Ok(JsonView(_grpScheduleViewList));
  228. }
  229. else//获取对象
  230. {
  231. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  232. if (_grpScheduleView != null)
  233. {
  234. return Ok(JsonView(_grpScheduleView));
  235. }
  236. }
  237. }
  238. else
  239. {
  240. return Ok(JsonView(false, "参数反序列化失败"));
  241. }
  242. return Ok(JsonView(false, "暂无数据!"));
  243. }
  244. /// <summary>
  245. /// 修改团组流程管控详细表数据
  246. /// </summary>
  247. /// <param name="paras"></param>
  248. /// <returns></returns>
  249. [HttpPost]
  250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  251. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  252. {
  253. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  254. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  255. .SetColumns(it => it.Duty == _detail.Duty)
  256. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  257. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  258. .SetColumns(it => it.JobContent == _detail.JobContent)
  259. .SetColumns(it => it.Remark == _detail.Remark)
  260. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  261. .Where(s => s.Id == dto.Id)
  262. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  263. .ExecuteCommandAsync();
  264. if (result > 0)
  265. {
  266. return Ok(JsonView(true, "保存成功!"));
  267. }
  268. return Ok(JsonView(false, "保存失败!"));
  269. }
  270. /// <summary>
  271. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  272. /// </summary>
  273. /// <param name="dto"></param>
  274. /// <returns></returns>
  275. [HttpPost]
  276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  277. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  278. {
  279. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  280. _detail.IsDel = 1;
  281. _detail.DeleteUserId = dto.Duty;
  282. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  283. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  284. .SetColumns(it => it.IsDel == _detail.IsDel)
  285. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  286. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  287. .Where(it => it.Id == dto.Id)
  288. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  289. //.WhereColumns(s => s.Id == dto.Id)
  290. .ExecuteCommandAsync();
  291. if (result > 0)
  292. {
  293. return Ok(JsonView(true, "删除成功!"));
  294. }
  295. return Ok(JsonView(false, "删除失败!"));
  296. }
  297. /// <summary>
  298. /// 增加团组流程管控详细表数据
  299. /// </summary>
  300. /// <param name="dto"></param>
  301. /// <returns></returns>
  302. [HttpPost]
  303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  304. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  305. {
  306. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  307. if (DateTime.Now < _detail.ExpectBeginDt)
  308. {
  309. _detail.StepStatus = 0;
  310. }
  311. else
  312. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  313. _detail.StepStatus = 1;
  314. }
  315. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  316. if (result > 0)
  317. {
  318. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  319. return Ok(JsonView(true, "添加成功!", _result));
  320. }
  321. return Ok(JsonView(false, "添加失败!"));
  322. }
  323. #endregion
  324. #region 团组基本信息
  325. /// <summary>
  326. /// 接团信息列表
  327. /// </summary>
  328. /// <param name="dto">团组列表请求dto</param>
  329. /// <returns></returns>
  330. [HttpPost]
  331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  332. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  333. {
  334. var groupData = await _groupRepository.GetGroupList(dto);
  335. if (groupData.Code != 0)
  336. {
  337. return Ok(JsonView(false, groupData.Msg));
  338. }
  339. return Ok(JsonView(groupData.Data));
  340. }
  341. /// <summary>
  342. /// 分页查询团组列表
  343. /// </summary>
  344. /// <param name="dto"></param>
  345. /// <returns></returns>
  346. [HttpPost]
  347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  348. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  349. {
  350. var watch = new Stopwatch();
  351. watch.Start();
  352. RefAsync<int> total = 0;
  353. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  354. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  355. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  356. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  357. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  358. .Distinct()
  359. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  360. watch.Stop();
  361. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  362. }
  363. /// <summary>
  364. /// 接团信息列表 Page
  365. /// </summary>
  366. /// <param name="dto">团组列表请求dto</param>
  367. /// <returns></returns>
  368. [HttpPost]
  369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  370. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  371. {
  372. #region 参数验证
  373. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  374. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  375. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  376. #region 页面操作权限验证
  377. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  378. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  379. #endregion
  380. #endregion
  381. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  382. {
  383. string sqlWhere = string.Empty;
  384. if (dto.IsSure == 0) //未完成
  385. {
  386. sqlWhere += string.Format(@" And IsSure = 0");
  387. }
  388. else if (dto.IsSure == 1) //已完成
  389. {
  390. sqlWhere += string.Format(@" And IsSure = 1");
  391. }
  392. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  393. {
  394. string tj = dto.SearchCriteria;
  395. 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}%')",
  396. tj, tj, tj, tj, tj);
  397. }
  398. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  399. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  400. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  401. JietuanOperator,IsSure,CreateTime,IsBid
  402. From (
  403. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  404. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  405. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  406. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  407. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  408. From Grp_DelegationInfo gdi
  409. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  410. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  411. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  412. Where gdi.IsDel = 0 {0}
  413. ) temp", sqlWhere);
  414. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  415. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  416. #region 处理所属部门
  417. /*
  418. * 1.sq 和 gyy 等显示 市场部
  419. * 2.王鸽和主管及张总还有管理员号统一国交部
  420. * 2-1. 4 管理员 ,21 张海麟
  421. */
  422. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  423. List<int> userIds1 = new List<int>() { 4, 21 };
  424. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  425. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  426. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  427. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  428. .ToList();
  429. foreach (var item in _DelegationList)
  430. {
  431. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  432. }
  433. #endregion
  434. var _view = new
  435. {
  436. PageFuncAuth = pageFunAuthView,
  437. Data = _DelegationList
  438. };
  439. return Ok(JsonView(true, "查询成功!", _view, total));
  440. }
  441. else
  442. {
  443. return Ok(JsonView(false, "查询失败"));
  444. }
  445. }
  446. /// <summary>
  447. /// 团组列表
  448. /// </summary>
  449. /// <returns></returns>
  450. [HttpPost]
  451. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  452. {
  453. #region 参数验证
  454. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  455. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  456. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  457. #region 页面操作权限验证
  458. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  459. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  460. #endregion
  461. #endregion
  462. if (dto.PortType != 1 && dto.PortType != 2)
  463. {
  464. return Ok(JsonView(false, "查询失败!"));
  465. }
  466. string orderbyStr = "order by gdi.CreateTime Desc";
  467. string sqlWhere = string.Empty;
  468. if (dto.IsSure == 0) //未完成
  469. {
  470. sqlWhere += string.Format(@" And IsSure = 0");
  471. }
  472. else if (dto.IsSure == 1) //已完成
  473. {
  474. sqlWhere += string.Format(@" And IsSure = 1");
  475. }
  476. //团组类型
  477. if (dto.TeamDid > 0)
  478. {
  479. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  480. }
  481. //团组名称
  482. if (!string.IsNullOrEmpty(dto.TeamName))
  483. {
  484. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  485. }
  486. //客户名称
  487. if (!string.IsNullOrEmpty(dto.ClientName))
  488. {
  489. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  490. }
  491. //客户单位
  492. if (!string.IsNullOrEmpty(dto.ClientUnit))
  493. {
  494. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  495. }
  496. //出访时间
  497. if (!string.IsNullOrEmpty(dto.visitDataTime))
  498. {
  499. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  500. orderbyStr = "order by gdi.VisitDate";
  501. }
  502. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  503. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  504. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  505. JietuanOperator,IsSure,CreateTime
  506. From (
  507. Select row_number() over({0}) as Row_Number,
  508. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  509. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  510. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  511. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  512. From Grp_DelegationInfo gdi
  513. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  514. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  515. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  516. Where gdi.IsDel = 0 {1}
  517. ) temp ", orderbyStr, sqlWhere);
  518. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  519. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  520. #region 处理所属部门
  521. /*
  522. * 1.sq 和 gyy 等显示 市场部
  523. * 2.王鸽和主管及张总还有管理员号统一国交部
  524. * 2-1. 4 管理员 ,21 张海麟
  525. */
  526. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  527. List<int> userIds1 = new List<int>() { 4, 21 };
  528. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  529. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  530. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  531. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  532. .ToList();
  533. foreach (var item in _DelegationList)
  534. {
  535. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  536. }
  537. #endregion
  538. var _view = new
  539. {
  540. PageFuncAuth = pageFunAuthView,
  541. Data = _DelegationList
  542. };
  543. return Ok(JsonView(true, "查询成功!", _view, total));
  544. }
  545. /// <summary>
  546. /// 接团信息详情
  547. /// </summary>
  548. /// <param name="dto">团组info请求dto</param>
  549. /// <returns></returns>
  550. [HttpPost]
  551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  552. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  553. {
  554. var groupData = await _groupRepository.GetGroupInfo(dto);
  555. if (groupData.Code != 0)
  556. {
  557. return Ok(JsonView(false, groupData.Msg));
  558. }
  559. return Ok(JsonView(groupData.Data));
  560. }
  561. /// <summary>
  562. /// 接团信息 编辑添加
  563. /// 基础信息数据源
  564. /// </summary>
  565. /// <param name="dto"></param>
  566. /// <returns></returns>
  567. [HttpPost]
  568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  569. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  570. {
  571. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  572. if (groupData.Code != 0)
  573. {
  574. return Ok(JsonView(false, groupData.Msg));
  575. }
  576. return Ok(JsonView(groupData.Data));
  577. }
  578. /// <summary>
  579. /// 接团信息 操作(增改)
  580. /// </summary>
  581. /// <param name="dto"></param>
  582. /// <returns></returns>
  583. [HttpPost]
  584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  585. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  586. {
  587. try
  588. {
  589. decimal ffrPrice = 0.00M;
  590. DateTime? visitDt = null;
  591. if (dto.Status == 2)
  592. {
  593. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  594. if (groupInfo != null)
  595. {
  596. ffrPrice = groupInfo.PaymentMoney;
  597. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  598. }
  599. }
  600. var groupData = await _groupRepository.GroupOperation(dto);
  601. if (groupData.Code != 0)
  602. {
  603. return Ok(JsonView(false, groupData.Msg));
  604. }
  605. int diId = 0;
  606. //添加时 默认加入团组汇率
  607. if (dto.Status == 1) //添加
  608. {
  609. diId = groupData.Data;
  610. //添加默认币种
  611. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  612. //默认分配权限
  613. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  614. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  615. var _managerIds = new List<int>() { 22, 32, 21 };
  616. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  617. if (userIds.Count > 0)
  618. {
  619. userIds.Add(208);
  620. //创建团组管控
  621. GroupStepForDelegation.CreateWorkStep(diId);
  622. //发送消息
  623. string groupName = dto.TeamName;
  624. string createGroupUser = string.Empty;
  625. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  626. if (userInfo != null) createGroupUser = userInfo.CnName;
  627. string title = $"系统通知";
  628. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  629. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  630. }
  631. //默认创建倒推表
  632. await _invertedListRep._Create(dto.UserId, diId);
  633. }
  634. else if (dto.Status == 2)
  635. {
  636. diId = dto.Id;
  637. }
  638. #region 签证人员团组时间通知
  639. #region 计算出访起止时间
  640. var startTime = new DateTime();
  641. var endTime = new DateTime();
  642. if (DateTime.TryParse(dto.VisitDate, out startTime))
  643. {
  644. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  645. }
  646. #endregion
  647. if (diId > 0)
  648. {
  649. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  650. }
  651. #endregion
  652. #region 团组操作默认添加/修改收款账单
  653. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  654. {
  655. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  656. .Where(x => x.IsDel == 0 &&
  657. x.Diid == diId &&
  658. x.Remark.Equals("预付款")
  659. )
  660. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  661. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  662. .FirstAsync();
  663. ffrInfo = new Fin_ForeignReceivables()
  664. {
  665. Diid = diId,
  666. PriceName = dto.ClientUnit,
  667. Price = dto.PaymentMoney,
  668. Count = 1,
  669. Unit = $"元",
  670. ItemSumPrice = dto.PaymentMoney,
  671. Rate = 1.0000M,
  672. Currency = 836,
  673. AddingWay = 0,
  674. CreateUserId = dto.UserId,
  675. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  676. Remark = $"预付款"
  677. };
  678. if (ffrInfo == null) //Add
  679. {
  680. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  681. }
  682. else //修改
  683. {
  684. await _sqlSugar.Updateable(ffrInfo)
  685. .UpdateColumns(x => new
  686. {
  687. x.PriceName,
  688. x.Price,
  689. x.ItemSumPrice,
  690. x.CreateTime,
  691. x.CreateUserId
  692. })
  693. .WhereColumns(x => x.Id)
  694. .ExecuteCommandAsync();
  695. }
  696. }
  697. #endregion
  698. return Ok(JsonView(true, "操作成功!", diId));
  699. }
  700. catch (Exception ex)
  701. {
  702. Logs("[response]" + JsonConvert.SerializeObject(dto));
  703. Logs(ex.Message);
  704. return Ok(JsonView(false, ex.Message));
  705. }
  706. }
  707. /// <summary>
  708. /// 接团流程操作(增改)
  709. /// 安卓端使用 建团时添加客户名单
  710. /// </summary>
  711. /// <param name="dto"></param>
  712. /// <returns></returns>
  713. [HttpPost]
  714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  715. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  716. {
  717. try
  718. {
  719. #region 参数验证
  720. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  721. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  722. #region 页面操作权限验证
  723. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  724. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  725. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  726. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  727. #endregion
  728. #endregion
  729. _sqlSugar.BeginTran();
  730. decimal ffrPrice = 0.00M;
  731. DateTime? visitDt = null;
  732. if (dto.Status == 2)
  733. {
  734. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  735. if (groupInfo != null)
  736. {
  737. ffrPrice = groupInfo.PaymentMoney;
  738. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  739. }
  740. }
  741. var _dto = new GroupOperationDto();
  742. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  743. var groupData = await _groupRepository.GroupOperation(_dto);
  744. if (groupData.Code != 0)
  745. {
  746. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  747. }
  748. int diId = 0;
  749. //添加时 默认加入团组汇率
  750. if (dto.Status == 1) //添加
  751. {
  752. diId = groupData.Data;
  753. //添加默认币种
  754. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  755. //默认分配权限
  756. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  757. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  758. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  759. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  760. if (userIds.Count > 0)
  761. {
  762. userIds.Add(208);
  763. //创建团组管控
  764. GroupStepForDelegation.CreateWorkStep(diId);
  765. //发送消息
  766. string groupName = dto.TeamName;
  767. string createGroupUser = string.Empty;
  768. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  769. if (userInfo != null) createGroupUser = userInfo.CnName;
  770. string title = $"系统通知";
  771. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  772. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  773. }
  774. #region 应用推送
  775. try
  776. {
  777. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  778. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  779. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  780. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  781. {
  782. List<string> userList = new List<string>() { users.QiyeChatUserId };
  783. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  784. }
  785. }
  786. catch (Exception ex)
  787. {
  788. }
  789. #endregion
  790. //默认创建倒推表
  791. await _invertedListRep._Create(dto.UserId, diId);
  792. }
  793. if (dto.Status == 2)
  794. {
  795. diId = dto.Id;
  796. if (diId == 0)
  797. {
  798. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  799. }
  800. }
  801. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  802. if (viewData.Code != 0)
  803. {
  804. _sqlSugar.RollbackTran();
  805. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  806. }
  807. #region 团组操作默认添加/修改收款账单
  808. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  809. {
  810. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  811. .Where(x => x.IsDel == 0 &&
  812. x.Diid == diId &&
  813. x.Remark.Equals("预付款")
  814. )
  815. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  816. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  817. .FirstAsync();
  818. ffrInfo = new Fin_ForeignReceivables()
  819. {
  820. Diid = diId,
  821. PriceName = dto.ClientUnit,
  822. Price = dto.PaymentMoney,
  823. Count = 1,
  824. Unit = $"元",
  825. ItemSumPrice = dto.PaymentMoney,
  826. Rate = 1.0000M,
  827. Currency = 836,
  828. AddingWay = 0,
  829. CreateUserId = dto.UserId,
  830. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  831. Remark = $"预付款"
  832. };
  833. if (ffrInfo == null) //Add
  834. {
  835. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  836. }
  837. else //修改
  838. {
  839. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  840. .UpdateColumns(x => new
  841. {
  842. x.PriceName,
  843. x.Price,
  844. x.ItemSumPrice,
  845. x.CreateTime,
  846. x.CreateUserId
  847. })
  848. .WhereColumns(x => x.Id)
  849. .ExecuteCommandAsync();
  850. }
  851. }
  852. #endregion
  853. #region 签证人员团组时间通知
  854. #region 计算出访起止时间
  855. var startTime = new DateTime();
  856. var endTime = new DateTime();
  857. if (DateTime.TryParse(dto.VisitDate, out startTime))
  858. {
  859. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  860. }
  861. #endregion
  862. if (diId > 0)
  863. {
  864. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  865. }
  866. #endregion
  867. _sqlSugar.CommitTran();
  868. return Ok(JsonView(true, "添加成功"));
  869. }
  870. catch (Exception ex)
  871. {
  872. _sqlSugar.RollbackTran();
  873. return Ok(JsonView(false, ex.Message));
  874. }
  875. }
  876. /// <summary>
  877. /// 接团信息 操作(删除)
  878. /// </summary>
  879. /// <param name="dto"></param>
  880. /// <returns></returns>
  881. [HttpPost]
  882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  883. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  884. {
  885. var diId = dto.Id;
  886. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  887. #region 删除 验证 (费用录入、出入境费用、收款账单)
  888. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  889. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  890. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  891. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  892. #endregion
  893. var groupData = await _groupRepository.GroupDel(dto);
  894. if (groupData.Code != 0)
  895. {
  896. return Ok(JsonView(false, groupData.Msg));
  897. }
  898. return Ok(JsonView(true));
  899. }
  900. /// <summary>
  901. /// 获取团组销售报价号
  902. /// 团组添加时 使用
  903. /// </summary>
  904. /// <returns></returns>
  905. [HttpPost]
  906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  907. public async Task<IActionResult> GetGroupSalesQuoteNo()
  908. {
  909. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  910. if (groupData.Code != 0)
  911. {
  912. return Ok(JsonView(false, groupData.Msg));
  913. }
  914. object salesQuoteNo = new
  915. {
  916. SalesQuoteNo = groupData.Data
  917. };
  918. return Ok(JsonView(salesQuoteNo));
  919. }
  920. /// <summary>
  921. /// 设置确认出团
  922. /// </summary>
  923. /// <param name="dto"></param>
  924. /// <returns></returns>
  925. [HttpPost]
  926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  927. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  928. {
  929. var groupData = await _groupRepository.ConfirmationGroup(dto);
  930. if (groupData.Code != 0)
  931. {
  932. return Ok(JsonView(false, groupData.Msg));
  933. }
  934. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  935. #region OA消息推送
  936. try
  937. {
  938. string groupName = groupInfo.TeamName;
  939. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  940. List<int> userIds = new List<int>();
  941. listUser.ForEach(s => userIds.Add(s.Id));
  942. string title = $"系统通知";
  943. string content = $"团组[{groupName}]已确认出团!";
  944. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  945. }
  946. catch (Exception ex)
  947. {
  948. }
  949. #endregion
  950. #region 应用推送
  951. try
  952. {
  953. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  954. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  955. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  956. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  957. {
  958. List<string> userList = new List<string>() { users.QiyeChatUserId };
  959. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  960. }
  961. }
  962. catch (Exception ex)
  963. {
  964. }
  965. #endregion
  966. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  967. return Ok(JsonView(true, "操作成功!", groupData.Data));
  968. }
  969. /// <summary>
  970. /// 获取团组名称data And 签证国别Data
  971. /// </summary>
  972. /// <param name="dto"></param>
  973. /// <returns></returns>
  974. [HttpPost]
  975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  976. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  977. {
  978. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  979. if (groupData.Code != 0)
  980. {
  981. return Ok(JsonView(false, groupData.Msg));
  982. }
  983. return Ok(JsonView(groupData.Data));
  984. }
  985. /// <summary>
  986. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  987. /// </summary>
  988. /// <returns></returns>
  989. [HttpPost]
  990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  991. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  992. {
  993. try
  994. {
  995. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  996. if (groupData.Code != 0)
  997. {
  998. return Ok(JsonView(false, groupData.Msg));
  999. }
  1000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1001. }
  1002. catch (Exception ex)
  1003. {
  1004. return Ok(JsonView(false, "程序错误!"));
  1005. throw;
  1006. }
  1007. }
  1008. /// <summary>
  1009. /// 团组清单 Excel
  1010. /// </summary>
  1011. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1012. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1013. /// <returns></returns>
  1014. [HttpGet]
  1015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1016. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1017. {
  1018. DateTime _beginDt, _endDt;
  1019. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1020. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1021. if (!beginBool && !endBool)
  1022. {
  1023. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1024. }
  1025. string sql = string.Format(@"
  1026. SELECT
  1027. ROW_NUMBER,
  1028. Id,
  1029. SalesQuoteNo,
  1030. TourCode,
  1031. TeamTypeId,
  1032. TeamType,
  1033. TeamLevId,
  1034. TeamLev,
  1035. TeamName,
  1036. ClientName,
  1037. ClientUnit,
  1038. VisitDate,
  1039. VisitDays,
  1040. VisitPNumber,
  1041. JietuanOperatorId,
  1042. JietuanOperator,
  1043. IsSure,
  1044. CreateTime,
  1045. IsBid
  1046. FROM
  1047. (
  1048. SELECT
  1049. ROW_NUMBER() OVER(
  1050. ORDER BY
  1051. gdi.CreateTime Desc
  1052. ) AS ROW_NUMBER,
  1053. gdi.Id,
  1054. SalesQuoteNo,
  1055. TourCode,
  1056. ssd.Id TeamTypeId,
  1057. ssd.Name TeamType,
  1058. ssd1.Id TeamLevId,
  1059. ssd1.Name TeamLev,
  1060. TeamName,
  1061. ClientName,
  1062. ClientUnit,
  1063. VisitDate,
  1064. VisitDays,
  1065. VisitPNumber,
  1066. JietuanOperator JietuanOperatorId,
  1067. su.CnName JietuanOperator,
  1068. IsSure,
  1069. gdi.CreateTime,
  1070. gdi.IsBid
  1071. FROM
  1072. Grp_DelegationInfo gdi
  1073. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1074. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1075. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1076. WHERE
  1077. gdi.IsDel = 0
  1078. AND gdi.IsBid = 0
  1079. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1080. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1081. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1082. #region 处理所属部门
  1083. /*
  1084. * 1.sq 和 gyy 等显示 市场部
  1085. * 2.王鸽和主管及张总还有管理员号统一国交部
  1086. * 2-1. 4 管理员 ,21 张海麟
  1087. */
  1088. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1089. List<int> userIds1 = new List<int>() { 4, 21 };
  1090. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1091. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1092. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1093. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1094. .ToListAsync();
  1095. foreach (var item in groupList)
  1096. {
  1097. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1098. }
  1099. #endregion
  1100. #region Excel
  1101. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1102. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1103. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1104. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1105. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1106. //载入模板
  1107. WorkbookDesigner designer = new WorkbookDesigner();
  1108. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1109. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1110. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1111. dt.TableName = "GroupList";
  1112. designer.SetDataSource(dt);
  1113. designer.Process();
  1114. if (!Directory.Exists(savePath))
  1115. {
  1116. Directory.CreateDirectory(savePath);
  1117. }
  1118. string serverPath = $"{savePath}{fileName}";
  1119. designer.Workbook.Save(serverPath);
  1120. string rst = $"{servicePath}{ftpPath}{fileName}";
  1121. #endregion
  1122. return Ok(JsonView(true, "操作成功!", rst));
  1123. }
  1124. #endregion
  1125. #region 团组&签证
  1126. /// <summary>
  1127. /// 根据团组Id获取签证客户信息List
  1128. /// </summary>
  1129. /// <param name="dto">请求dto</param>
  1130. /// <returns></returns>
  1131. [HttpPost]
  1132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1133. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1134. {
  1135. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1136. if (groupData.Code != 0)
  1137. {
  1138. return Ok(JsonView(false, groupData.Msg));
  1139. }
  1140. return Ok(JsonView(groupData.Data));
  1141. }
  1142. /// <summary>
  1143. /// IOS获取团组签证拍照上传进度01(团组列表)
  1144. /// </summary>
  1145. /// <param name="dto">请求dto</param>
  1146. /// <returns></returns>
  1147. [HttpPost]
  1148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1149. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1150. {
  1151. if (dto == null)
  1152. {
  1153. return Ok(JsonView(false, "参数为空"));
  1154. }
  1155. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1156. return Ok(JsonView(visaList));
  1157. }
  1158. /// <summary>
  1159. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1160. /// </summary>
  1161. /// <returns></returns>
  1162. [HttpPost]
  1163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1164. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1165. {
  1166. if (dto == null)
  1167. {
  1168. return Ok(JsonView(false, "请求错误:"));
  1169. }
  1170. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1171. return Ok(JsonView(list));
  1172. }
  1173. /// <summary>
  1174. /// IOS获取团组签证拍照上传进度03(相册)
  1175. /// </summary>
  1176. /// <returns></returns>
  1177. [HttpPost]
  1178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1179. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1180. {
  1181. if (dto == null)
  1182. {
  1183. return Ok(JsonView(false, "请求错误:"));
  1184. }
  1185. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1186. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1187. list.ForEach(s => s.url = url);
  1188. return Ok(JsonView(list));
  1189. }
  1190. /// <summary>
  1191. /// IOS获取团组签证拍照上传进度04(图片上传)
  1192. /// </summary>
  1193. /// <param name="dto"></param>
  1194. /// <returns></returns>
  1195. [HttpPost]
  1196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1197. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1198. {
  1199. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1200. //if (!string.IsNullOrEmpty(result))
  1201. //{
  1202. //}
  1203. //else {
  1204. // return Ok(JsonView(false, "上传失败"));
  1205. //}
  1206. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1207. int sucNum = 0;
  1208. try
  1209. {
  1210. foreach (var item in dto.base64DataList)
  1211. {
  1212. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1213. string result = decodeBase64ToImage(item, imageName);
  1214. if (!string.IsNullOrEmpty(result))
  1215. {
  1216. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1217. pic.CreateUserId = dto.CreateUserId;
  1218. pic.PicName = imageName;
  1219. pic.PicPath = result;
  1220. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1221. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1222. if (insertResult > 0)
  1223. {
  1224. sucNum++;
  1225. }
  1226. }
  1227. }
  1228. }
  1229. catch (Exception ex)
  1230. {
  1231. return Ok(JsonView(false, ex.Message));
  1232. }
  1233. string msg = string.Format(@"成功上传{0}张", sucNum);
  1234. return Ok(JsonView(true, msg));
  1235. }
  1236. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1237. {
  1238. string filename = "";//声明一个string类型的相对路径
  1239. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1240. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1241. try//会有异常抛出,try,catch一下
  1242. {
  1243. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1244. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1245. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1246. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1247. //文件名称
  1248. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1249. //上传的文件的路径
  1250. string filePath = "";
  1251. if (!Directory.Exists(fileDir))
  1252. {
  1253. Directory.CreateDirectory(fileDir);
  1254. }
  1255. //上传的文件的路径
  1256. filePath = fileDir + filename;
  1257. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1258. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1259. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1260. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1261. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1262. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1263. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1264. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1265. bitmap.Dispose();
  1266. }
  1267. catch (Exception e)
  1268. {
  1269. string massage = e.Message;
  1270. Logs("IOS图片上传Error:" + massage);
  1271. //filename = e.Message;
  1272. }
  1273. return filename;//返回相对路径
  1274. }
  1275. /// <summary>
  1276. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1277. /// </summary>
  1278. /// <param name="dto"></param>
  1279. /// <returns></returns>
  1280. [HttpPost]
  1281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1282. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1283. {
  1284. if (dto == null)
  1285. {
  1286. return Ok(JsonView(false, "请求错误:"));
  1287. }
  1288. string msg = "参数错误";
  1289. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1290. {
  1291. try
  1292. {
  1293. //_delegationVisaRep.BeginTran();
  1294. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1295. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1296. .Where(s => s.Id == dto.visaProgressCustomerId)
  1297. .ExecuteCommandAsync();
  1298. if (updCount > 0 && dto.publishCode == 1)
  1299. {
  1300. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1301. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1302. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1303. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1304. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1305. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1306. if (groupData == null)
  1307. {
  1308. _delegationVisaRep.RollbackTran();
  1309. }
  1310. string title = string.Format(@"[签证进度更新]");
  1311. string content = string.Format(@"测试文本");
  1312. bool rst = await _message.AddMsg(new MessageDto()
  1313. {
  1314. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1315. IssuerId = dto.publisher,
  1316. Title = title,
  1317. Content = content,
  1318. ReleaseTime = DateTime.Now,
  1319. UIdList = new List<int> {
  1320. 234
  1321. }
  1322. });
  1323. if (rst)
  1324. {
  1325. return Ok(JsonView(true, "发送通知成功"));
  1326. }
  1327. }
  1328. //_delegationVisaRep.CommitTran();
  1329. }
  1330. catch (Exception)
  1331. {
  1332. //_delegationVisaRep.RollbackTran();
  1333. }
  1334. }
  1335. return Ok(JsonView(true, msg));
  1336. }
  1337. #endregion
  1338. #region 团组任务分配
  1339. /// <summary>
  1340. /// 团组任务分配初始化
  1341. /// </summary>
  1342. /// <param name="dto"></param>
  1343. /// <returns></returns>
  1344. [HttpPost]
  1345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1346. public async Task<IActionResult> GetTaskAssignmen()
  1347. {
  1348. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1349. if (groupData.Code != 0)
  1350. {
  1351. return Ok(JsonView(false, groupData.Msg));
  1352. }
  1353. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1354. }
  1355. /// <summary>
  1356. /// 团组任务分配查询
  1357. /// </summary>
  1358. /// <param name="dto"></param>
  1359. /// <returns></returns>
  1360. [HttpPost]
  1361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1362. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1363. {
  1364. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1365. if (groupData.Code != 0)
  1366. {
  1367. return Ok(JsonView(false, groupData.Msg));
  1368. }
  1369. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1370. }
  1371. /// <summary>
  1372. /// 团组任务分配操作
  1373. /// </summary>
  1374. /// <param name="dto"></param>
  1375. /// <returns></returns>
  1376. [HttpPost]
  1377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1378. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1379. {
  1380. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1381. if (groupData.Code != 0)
  1382. {
  1383. return Ok(JsonView(false, groupData.Msg));
  1384. }
  1385. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1386. }
  1387. /// <summary>
  1388. /// 团组任务分配
  1389. /// 批量分配
  1390. /// 查询团组
  1391. /// </summary>
  1392. /// <param name="dto"></param>
  1393. /// <returns></returns>
  1394. [HttpPost]
  1395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1396. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1397. {
  1398. //参数验证
  1399. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1400. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1401. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1402. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1403. }
  1404. /// <summary>
  1405. /// 团组任务分配
  1406. /// 批量分配
  1407. /// </summary>
  1408. /// <param name="dto"></param>
  1409. /// <returns></returns>
  1410. [HttpPost]
  1411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1412. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1413. {
  1414. //参数验证
  1415. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1416. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1417. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1418. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1419. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1420. }
  1421. #endregion
  1422. #region 团组费用审核
  1423. /// <summary>
  1424. /// 费用审核
  1425. /// 团组列表 Page
  1426. /// </summary>
  1427. /// <param name="_dto">团组列表请求dto</param>
  1428. /// <returns></returns>
  1429. [HttpPost]
  1430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1431. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1432. {
  1433. #region 参数验证
  1434. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1435. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1436. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1437. #region 页面操作权限验证
  1438. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1439. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1440. #endregion
  1441. #endregion
  1442. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1443. {
  1444. string sqlWhere = string.Empty;
  1445. if (_dto.IsSure == 0) //未完成
  1446. {
  1447. sqlWhere += string.Format(@" And IsSure = 0");
  1448. }
  1449. else if (_dto.IsSure == 1) //已完成
  1450. {
  1451. sqlWhere += string.Format(@" And IsSure = 1");
  1452. }
  1453. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1454. {
  1455. string tj = _dto.SearchCriteria;
  1456. 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}%')",
  1457. tj, tj, tj, tj, tj);
  1458. }
  1459. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1460. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1461. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1462. From (
  1463. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1464. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1465. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1466. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1467. From Grp_DelegationInfo gdi
  1468. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1469. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1470. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1471. Where gdi.IsDel = 0 {0}
  1472. ) temp ", sqlWhere);
  1473. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1474. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1475. var _view = new
  1476. {
  1477. PageFuncAuth = pageFunAuthView,
  1478. Data = _DelegationList
  1479. };
  1480. return Ok(JsonView(true, "查询成功!", _view, total));
  1481. }
  1482. else
  1483. {
  1484. return Ok(JsonView(false, "查询失败"));
  1485. }
  1486. }
  1487. /// <summary>
  1488. /// 获取团组费用审核
  1489. /// </summary>
  1490. /// <param name="paras">参数Json字符串</param>
  1491. /// <returns></returns>
  1492. [HttpPost]
  1493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1494. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1495. {
  1496. try
  1497. {
  1498. #region 参数验证
  1499. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1500. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1501. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1502. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1503. #region 页面操作权限验证
  1504. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1505. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1506. #endregion
  1507. #endregion
  1508. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1509. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1510. #region 费用清单
  1511. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1512. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1513. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1514. List<Grp_CreditCardPayment> entityList = _groupRepository
  1515. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1516. .Where(exp.ToExpression())
  1517. .ToList();
  1518. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1519. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1520. /*
  1521. * 76://酒店预订
  1522. */
  1523. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1524. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1525. .ToListAsync();
  1526. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1527. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1528. .ToListAsync();
  1529. /*
  1530. * 79://车/导游地接
  1531. */
  1532. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1533. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1534. .ToListAsync();
  1535. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1536. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1537. .ToListAsync();
  1538. /*
  1539. * 80: //签证
  1540. */
  1541. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1542. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1543. .ToListAsync();
  1544. /*
  1545. *81: //邀请/公务活动
  1546. */
  1547. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1548. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1549. .ToListAsync();
  1550. /*
  1551. * 82: //团组客户保险
  1552. */
  1553. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1554. /*
  1555. * Lable = 85 机票预订
  1556. */
  1557. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1558. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1559. .ToListAsync();
  1560. /*
  1561. * 85 机票预定
  1562. */
  1563. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1564. /*
  1565. * 98 其他款项
  1566. */
  1567. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1568. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1569. .ToListAsync();
  1570. /*
  1571. * 285:收款退还
  1572. */
  1573. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1574. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1575. .ToListAsync();
  1576. /*
  1577. * 1015: //超支费用
  1578. */
  1579. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1580. /*
  1581. * 币种信息
  1582. */
  1583. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1584. /*
  1585. * 车/导游地接 费用类型
  1586. */
  1587. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1588. /*
  1589. * 车/导游地接 费用类型
  1590. */
  1591. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1592. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1593. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1594. /*
  1595. * 用户信息
  1596. */
  1597. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1598. /*
  1599. * 费用模块
  1600. */
  1601. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1602. string priceModule = string.Empty;
  1603. if (sdPriceName != null)
  1604. {
  1605. priceModule = sdPriceName.Name;
  1606. }
  1607. /*
  1608. * 成本信息
  1609. */
  1610. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1611. decimal _groupRate = 0.0000M;
  1612. string _groupCurrencyCode = "-";
  1613. if (groupCost != null)
  1614. {
  1615. _groupRate = groupCost.Rate;
  1616. if (int.TryParse(groupCost.Currency, out int _currency))
  1617. {
  1618. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1619. }
  1620. else _groupCurrencyCode = groupCost.Currency;
  1621. }
  1622. string costContentSql = $"Select * From Grp_GroupCost";
  1623. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1624. //处理日期为空的天数
  1625. for (int i = 0; i < groupCostDetails.Count; i++)
  1626. if (i != 0)
  1627. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1628. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1629. /*
  1630. * 处理详情数据
  1631. */
  1632. foreach (var entity in entityList)
  1633. {
  1634. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1635. _detail.Id = entity.Id;
  1636. _detail.PriceName = priceModule;
  1637. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1638. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1639. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1640. //处理金额
  1641. if (entity.CTable == 1015)
  1642. {
  1643. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1644. if (czInfo != null)
  1645. {
  1646. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1647. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1648. }
  1649. }
  1650. /*
  1651. * 应付款金额
  1652. */
  1653. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1654. string PaymentCurrency_WaitPay = "Unknown";
  1655. string hotelCurrncyCode = "Unknown";
  1656. string hotelCurrncyName = "Unknown";
  1657. if (sdPaymentCurrency_WaitPay != null)
  1658. {
  1659. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1660. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1661. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1662. if (hotelCurrncyCode.Equals("CNY"))
  1663. {
  1664. entity.DayRate = 1.0000M;
  1665. }
  1666. }
  1667. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1668. /*
  1669. * 此次付款金额
  1670. */
  1671. decimal CurrPayStr = 0.00M,
  1672. OriginalCurrPay = 0.00M;
  1673. if (entity.PayPercentage == 0)
  1674. {
  1675. if (entity.PayThenMoney != 0)
  1676. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1677. }
  1678. else
  1679. {
  1680. if (entity.PayMoney != 0)
  1681. {
  1682. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1683. }
  1684. }
  1685. if (_dto.Label == 79)
  1686. {
  1687. string original = string.Empty;
  1688. if (hotelCurrncyCode.Equals("CNY"))
  1689. {
  1690. OriginalCurrPay = CurrPayStr;
  1691. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1692. }
  1693. else
  1694. {
  1695. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1696. //760 EUR(7600.00 CNY)
  1697. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1698. }
  1699. }
  1700. else
  1701. {
  1702. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1703. }
  1704. /*
  1705. * 剩余尾款
  1706. */
  1707. decimal BalanceStr = 0;
  1708. if (CurrPayStr != 0)
  1709. {
  1710. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1711. BalanceStr = 0;
  1712. else
  1713. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1714. }
  1715. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1716. /*
  1717. * Bus名称
  1718. */
  1719. _detail.BusName = "待增加";
  1720. /*
  1721. *费用所属
  1722. */
  1723. switch (entity.CTable)
  1724. {
  1725. case 76://酒店预订
  1726. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1727. if (hotelReservations != null)
  1728. {
  1729. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1730. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1731. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1732. string roomFeeStr = "", roomFeestr1 = "";
  1733. //是否比较房型价格
  1734. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1735. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1736. roomFeeStr += $"<br/>";
  1737. if (hotelReservations.SingleRoomPrice > 0)
  1738. {
  1739. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1740. __isSingle = true;
  1741. }
  1742. if (hotelReservations.DoubleRoomPrice > 0)
  1743. {
  1744. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1745. __isDouble = true;
  1746. }
  1747. if (hotelReservations.SuiteRoomPrice > 0)
  1748. {
  1749. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1750. __isSuite = true;
  1751. }
  1752. if (hotelReservations.OtherRoomPrice > 0)
  1753. {
  1754. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1755. __isOther = true;
  1756. }
  1757. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1758. else roomFeeStr += " 0.00 * 0";
  1759. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1760. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1761. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1762. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1763. /*
  1764. * 费用类型
  1765. * 1:房费
  1766. * 2:早餐
  1767. * 3:地税
  1768. * 4:城市税
  1769. * </summary>
  1770. */
  1771. //地税
  1772. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1773. if (governmentRentData != null)
  1774. {
  1775. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1776. governmentRentFee = governmentRentData.Price;
  1777. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1778. if (governmentRentCurrData != null)
  1779. {
  1780. governmentRentCode = governmentRentCurrData.Name;
  1781. governmentRentName = $"({governmentRentCurrData.Remark})";
  1782. }
  1783. }
  1784. //城市税
  1785. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1786. if (cityTaxData != null)
  1787. {
  1788. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1789. cityTaxFee = cityTaxData.Price;
  1790. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1791. if (cityTaxCurrData != null)
  1792. {
  1793. cityTaxCode = cityTaxCurrData.Name;
  1794. cityTaxName = $"({cityTaxCurrData.Remark})";
  1795. }
  1796. }
  1797. //酒店早餐
  1798. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1799. if (breakfastData != null)
  1800. {
  1801. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1802. breakfastFee = breakfastData.Price;
  1803. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1804. if (breakfastCurrData != null)
  1805. {
  1806. breakfastCode = breakfastCurrData.Name;
  1807. breakfastName = $"({breakfastCurrData.Remark})";
  1808. }
  1809. }
  1810. //房间费用
  1811. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1812. if (roomData != null)
  1813. {
  1814. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1815. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1816. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1817. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1818. roomFee = roomData.Price;
  1819. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1820. if (roomCurrData != null)
  1821. {
  1822. roomCode = roomCurrData.Name;
  1823. roomName = $"({roomCurrData.Remark})";
  1824. }
  1825. }
  1826. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1827. string hotelCostStr = "";
  1828. decimal hotelCsotTotal = 0.00M;
  1829. if (groupCost != null)
  1830. {
  1831. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1832. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1833. }
  1834. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1835. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1836. string hotelCost_day = "";
  1837. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1838. foreach (var item in hotelCostDetails1)
  1839. {
  1840. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1841. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1842. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1843. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1844. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1845. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1846. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1847. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1848. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1849. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1850. hotelCost_day += @$"<br/>";
  1851. }
  1852. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1853. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1854. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1855. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1856. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1857. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1858. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1859. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1860. $"房间说明: {hotelReservations.Remark} <br/>" +
  1861. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1862. $"{hotelBreakfastStr}" +
  1863. $"{hotelGovernmentRentStr}" +
  1864. $"{hotelCityTaxStr}";
  1865. _detail.PriceNameContent = hotelReservations.HotelName;
  1866. }
  1867. break;
  1868. case 79://车/导游地接
  1869. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1870. if (touristGuideGroundReservations != null)
  1871. {
  1872. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1873. {
  1874. _detail.BusName = touristGuideGroundReservations.BusName;
  1875. }
  1876. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1877. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1878. //if (isInt)
  1879. //{
  1880. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1881. // if (cityInfo != null)
  1882. // {
  1883. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1884. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1885. // if (carFeeItem != null)
  1886. // {
  1887. // nameContent += $@"({carFeeItem.Name})";
  1888. // }
  1889. // _detail.PriceNameContent = nameContent;
  1890. // }
  1891. //}
  1892. //else
  1893. //{
  1894. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1895. //}
  1896. var touristGuideGroundReservationsContents =
  1897. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1898. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1899. foreach (var item in touristGuideGroundReservationsContents)
  1900. {
  1901. string typeName = "Unknown";
  1902. string carCurrencyCode = "Unknown";
  1903. string carCurrencyName = "Unknown";
  1904. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1905. if (carTypeData != null) typeName = carTypeData.Name;
  1906. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1907. if (currencyData != null)
  1908. {
  1909. carCurrencyCode = currencyData.Name;
  1910. carCurrencyName = currencyData.Remark;
  1911. }
  1912. //op、成本 币种是否一致
  1913. bool IsCurrencyAgreement = false;
  1914. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1915. string opCostStr = string.Empty;
  1916. decimal opCostTypePrice = 0.00M;
  1917. #region 处理成本各项费用
  1918. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1919. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1920. if (opCost.Count > 0)
  1921. {
  1922. switch (item.SId)
  1923. {
  1924. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1925. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1926. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1927. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1928. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1929. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1930. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1931. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1932. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1933. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1934. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1935. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1936. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1937. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1938. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1939. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1940. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1941. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1942. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1943. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1944. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1945. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1946. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1947. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1948. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1949. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1950. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1951. }
  1952. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1953. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1954. }
  1955. #endregion
  1956. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1957. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1958. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1959. $"{opTypeStr} {opCostStr}<br/>" +
  1960. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1961. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1962. }
  1963. _detail.PriceMsgContent = priceMsg;
  1964. }
  1965. break;
  1966. case 80: //签证
  1967. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1968. if (visaInfo != null)
  1969. {
  1970. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1971. _detail.PriceNameContent = visaInfo.VisaDescription;
  1972. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1973. }
  1974. break;
  1975. case 81: //邀请/公务活动
  1976. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1977. if (_ioa != null)
  1978. {
  1979. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1980. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1981. sendCurrName = "Unknown", //快递费用币种 Name
  1982. sendCurrCode = "Unknown", //快递费用币种 Code
  1983. eventsCurrName = "Unknown", //公务活动费币种 Name
  1984. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1985. translateCurrName = "Unknown", //公务翻译费 Name
  1986. translateCurrCode = "Unknown"; //公务翻译费 Code
  1987. #region 处理费用币种
  1988. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1989. if (inviteCurrData != null)
  1990. {
  1991. inviteCurrName = inviteCurrData.Remark;
  1992. inviteCurrCode = inviteCurrData.Name;
  1993. }
  1994. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1995. if (sendCurrData != null)
  1996. {
  1997. sendCurrName = sendCurrData.Remark;
  1998. sendCurrCode = sendCurrData.Name;
  1999. }
  2000. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2001. if (eventsCurrData != null)
  2002. {
  2003. eventsCurrName = eventsCurrData.Remark;
  2004. eventsCurrCode = eventsCurrData.Name;
  2005. }
  2006. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2007. if (translateCurrData != null)
  2008. {
  2009. translateCurrName = translateCurrData.Remark;
  2010. translateCurrCode = translateCurrData.Name;
  2011. }
  2012. #endregion
  2013. _detail.PriceNameContent = _ioa.InviterArea;
  2014. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2015. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2016. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2017. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2018. $@"备注:" + _ioa.Remark + "<br/>";
  2019. }
  2020. break;
  2021. case 82: //团组客户保险
  2022. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2023. if (customers != null)
  2024. {
  2025. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2026. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2027. }
  2028. break;
  2029. case 85: //机票预订
  2030. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2031. if (jpRes != null)
  2032. {
  2033. string FlightsDescription = jpRes.FlightsDescription;
  2034. string PriceDescription = jpRes.PriceDescription;
  2035. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2036. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2037. }
  2038. break;
  2039. case 98://其他款项
  2040. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2041. if (gdpRes != null)
  2042. {
  2043. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2044. _detail.PriceNameContent = gdpRes.PriceName;
  2045. }
  2046. break;
  2047. case 285://收款退还
  2048. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2049. if (refundAndOtherMoney != null)
  2050. {
  2051. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2052. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2053. }
  2054. break;
  2055. case 751://酒店早餐
  2056. break;
  2057. case 1015://超支费用
  2058. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2059. if (groupExtraCost != null)
  2060. {
  2061. _detail.PriceNameContent = groupExtraCost.PriceName;
  2062. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2063. }
  2064. break;
  2065. default:
  2066. break;
  2067. }
  2068. /*
  2069. * 申请人
  2070. */
  2071. string operatorName = " - ";
  2072. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2073. if (_opUser != null)
  2074. {
  2075. operatorName = _opUser.CnName;
  2076. }
  2077. _detail.OperatorName = operatorName;
  2078. /*
  2079. * 审核人
  2080. */
  2081. string auditOperatorName = "Unknown";
  2082. if (entity.AuditGMOperate == 0)
  2083. auditOperatorName = " - ";
  2084. else if (entity.AuditGMOperate == 4)
  2085. auditOperatorName = "自动审核";
  2086. else
  2087. {
  2088. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2089. if (_adUser != null)
  2090. {
  2091. auditOperatorName = _adUser.CnName;
  2092. }
  2093. }
  2094. _detail.AuditOperatorName = auditOperatorName;
  2095. /*
  2096. * 超预算比例
  2097. */
  2098. string overBudgetStr = "";
  2099. if (entity.ExceedBudget == -1)
  2100. overBudgetStr = sdPriceName.Name + "尚无预算";
  2101. else if (entity.ExceedBudget == 0)
  2102. {
  2103. if (entity.CTable == 76 || entity.CTable == 79)
  2104. {
  2105. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2106. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2107. }
  2108. else
  2109. {
  2110. overBudgetStr = "未超预算";
  2111. }
  2112. }
  2113. else
  2114. overBudgetStr = entity.ExceedBudget.ToString("P");
  2115. _detail.OverBudget = overBudgetStr;
  2116. /*
  2117. * 已审核金额
  2118. */
  2119. decimal auditFee = 0.00M;
  2120. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2121. /*
  2122. * 费用总计
  2123. */
  2124. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2125. {
  2126. CurrencyId = entity.PaymentCurrency,
  2127. CurrencyName = PaymentCurrency_WaitPay,
  2128. AmountPayable = entity.PayMoney,
  2129. ThisPayment = OriginalCurrPay,
  2130. BalancePayment = BalanceStr,
  2131. AuditedFunds = auditFee
  2132. });
  2133. _detail.IsAuditGM = entity.IsAuditGM;
  2134. detailList.Add(_detail);
  2135. }
  2136. #endregion
  2137. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2138. /*
  2139. * 下方描述处理
  2140. */
  2141. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2142. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2143. if (ccpCurrencyPrice != null)
  2144. {
  2145. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2146. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2147. }
  2148. else
  2149. {
  2150. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2151. }
  2152. string amountPayableStr = string.Format(@"应付款总金额: ");
  2153. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2154. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2155. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2156. foreach (var item in nonDuplicat)
  2157. {
  2158. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2159. if (strs.Count > 0)
  2160. {
  2161. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2162. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2163. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2164. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2165. //单独处理此次付款金额
  2166. if (item.CurrencyId == 836) //人民币
  2167. {
  2168. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2169. }
  2170. else
  2171. {
  2172. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2173. }
  2174. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2175. //单独处理已审核费用
  2176. if (item.CurrencyId == 836) //人民币
  2177. {
  2178. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2179. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2180. }
  2181. else
  2182. {
  2183. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2184. }
  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);
  2191. var _view1 = new
  2192. {
  2193. PageFuncAuth = pageFunAuthView,
  2194. Data = _view
  2195. };
  2196. return Ok(JsonView(_view1));
  2197. }
  2198. catch (Exception ex)
  2199. {
  2200. return Ok(JsonView(false, ex.Message));
  2201. }
  2202. }
  2203. /// <summary>
  2204. /// 费用审核
  2205. /// 修改团组费用审核状态
  2206. /// </summary>
  2207. /// <param name="_dto">参数Json字符串</param>
  2208. /// <returns></returns>
  2209. [HttpPost]
  2210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2211. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2212. {
  2213. #region 参数验证
  2214. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2215. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2216. #endregion
  2217. #region 页面操作权限验证
  2218. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2219. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2220. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2221. #endregion
  2222. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2223. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2224. DateTime dtNow = DateTime.Now;
  2225. _groupRepository.BeginTran();
  2226. int rst = 0;
  2227. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2228. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2229. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2230. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2231. List<dynamic> msgDatas = new List<dynamic>();
  2232. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2233. foreach (var item in idList)
  2234. {
  2235. int CreditId = int.Parse(item);
  2236. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2237. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2238. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2239. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2240. .Where(s => s.Id == CreditId)
  2241. .ExecuteCommandAsync();
  2242. if (result < 1)
  2243. {
  2244. rst = -1;
  2245. _groupRepository.RollbackTran();
  2246. return Ok(JsonView(false, "操作失败并回滚!"));
  2247. }
  2248. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2249. if (creditData != null)
  2250. {
  2251. #region 应用通知配置
  2252. try
  2253. {
  2254. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2255. }
  2256. catch (Exception ex)
  2257. {
  2258. }
  2259. #endregion
  2260. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2261. string groupNameStr = string.Empty;
  2262. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2263. if (groupData != null) groupNameStr = groupData.TeamName;
  2264. string creditTypeStr = string.Empty;
  2265. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2266. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2267. string creditCurrency = string.Empty;
  2268. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2269. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2270. if (creditCurrency.Equals("CNY"))
  2271. {
  2272. creditData.DayRate = 1.0000M;
  2273. }
  2274. if (creditData.PayPercentage == 0.00M)
  2275. {
  2276. creditData.PayPercentage = 100M;
  2277. }
  2278. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2279. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2280. string msgContent = "";
  2281. if (creditCurrency.Equals("CNY"))
  2282. {
  2283. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2284. }
  2285. else
  2286. {
  2287. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2288. }
  2289. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2290. }
  2291. }
  2292. if (rst == 0)
  2293. {
  2294. _groupRepository.CommitTran();
  2295. foreach (var item in msgDatas)
  2296. {
  2297. //发送消息
  2298. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2299. }
  2300. #region 应用推送
  2301. try
  2302. {
  2303. foreach (var ccpId in dic_ccp_user.Keys)
  2304. {
  2305. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2306. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2307. }
  2308. }
  2309. catch (Exception)
  2310. {
  2311. }
  2312. #endregion
  2313. return Ok(JsonView(true, "操作成功!"));
  2314. }
  2315. return Ok(JsonView(false, "操作失败!"));
  2316. }
  2317. #endregion
  2318. #region 机票费用录入
  2319. /// <summary>
  2320. /// 机票录入当前登录人可操作团组
  2321. /// </summary>
  2322. /// <param name="dto"></param>
  2323. /// <returns></returns>
  2324. [HttpPost]
  2325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2326. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2327. {
  2328. try
  2329. {
  2330. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2331. if (groupData.Code != 0)
  2332. {
  2333. return Ok(JsonView(false, groupData.Msg));
  2334. }
  2335. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2336. }
  2337. catch (Exception ex)
  2338. {
  2339. return Ok(JsonView(false, "程序错误!"));
  2340. throw;
  2341. }
  2342. }
  2343. /// <summary>
  2344. /// 机票费用录入列表
  2345. /// </summary>
  2346. /// <param name="dto"></param>
  2347. /// <returns></returns>
  2348. [HttpPost]
  2349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2350. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2351. {
  2352. try
  2353. {
  2354. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2355. if (groupData.Code != 0)
  2356. {
  2357. return Ok(JsonView(false, groupData.Msg));
  2358. }
  2359. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2360. }
  2361. catch (Exception ex)
  2362. {
  2363. return Ok(JsonView(false, ex.Message));
  2364. throw;
  2365. }
  2366. }
  2367. /// <summary>
  2368. /// 根据id查询费用录入信息
  2369. /// </summary>
  2370. /// <param name="dto"></param>
  2371. /// <returns></returns>
  2372. [HttpPost]
  2373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2374. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2375. {
  2376. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2377. if (groupData.Code != 0)
  2378. {
  2379. return Ok(JsonView(false, groupData.Msg));
  2380. }
  2381. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2382. }
  2383. /// <summary>
  2384. /// 机票费用录入操作(Status:1.新增,2.修改)
  2385. /// </summary>
  2386. /// <param name="dto"></param>
  2387. /// <returns></returns>
  2388. [HttpPost]
  2389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2390. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2391. {
  2392. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2393. if (groupData.Code != 0)
  2394. {
  2395. return Ok(JsonView(false, groupData.Msg));
  2396. }
  2397. #region 应用推送
  2398. try
  2399. {
  2400. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2401. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2402. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2403. //2024-10-21 新增LZ UID
  2404. var userIds = new List<int>() { 21 };
  2405. string title = $"系统通知";
  2406. string content = "";
  2407. var diId = dto.AirTicketResOpData.DiId;
  2408. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2409. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2410. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2411. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2412. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2413. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2414. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2415. }
  2416. catch (Exception ex)
  2417. {
  2418. }
  2419. #endregion
  2420. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2421. }
  2422. /// <summary>
  2423. /// 根据舱位类型查询接团客户名单信息
  2424. /// </summary>
  2425. /// <param name="dto"></param>
  2426. /// <returns></returns>
  2427. [HttpPost]
  2428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2429. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2430. {
  2431. try
  2432. {
  2433. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2434. if (crm_Groups.Count != 0)
  2435. {
  2436. List<dynamic> Customer = new List<dynamic>();
  2437. foreach (var item in crm_Groups)
  2438. {
  2439. var data = new
  2440. {
  2441. Id = item.Id,
  2442. Pinyin = item.Pinyin,
  2443. Name = item.LastName + item.FirstName
  2444. };
  2445. Customer.Add(data);
  2446. }
  2447. return Ok(JsonView(true, "查询成功!", Customer));
  2448. }
  2449. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2450. }
  2451. catch (Exception ex)
  2452. {
  2453. return Ok(JsonView(false, "程序错误!"));
  2454. throw;
  2455. }
  2456. }
  2457. /// <summary>
  2458. /// 根据团号获取客户信息
  2459. /// </summary>
  2460. /// <param name="dto"></param>
  2461. /// <returns></returns>
  2462. [HttpPost]
  2463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2464. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2465. {
  2466. var jw = JsonView(false);
  2467. if (dto.DIID < 1)
  2468. {
  2469. jw.Msg += "请输入正确的diid";
  2470. return Ok(jw);
  2471. }
  2472. var arr = getSimplClientList(dto.DIID);
  2473. jw = JsonView(true, "获取成功!", arr);
  2474. return Ok(jw);
  2475. }
  2476. private List<SimplClientInfo> getSimplClientList(int diId)
  2477. {
  2478. 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);
  2479. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2480. return arr;
  2481. }
  2482. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2483. {
  2484. string result = origin;
  2485. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2486. {
  2487. string[] temparr = origin.Split(',');
  2488. string fistrStr = temparr[0];
  2489. int count = temparr.Count();
  2490. int tempId;
  2491. bool success = int.TryParse(fistrStr, out tempId);
  2492. if (success)
  2493. {
  2494. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2495. if (tempInfo != null)
  2496. {
  2497. if (count > 1)
  2498. {
  2499. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2500. }
  2501. else
  2502. {
  2503. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2504. }
  2505. }
  2506. }
  2507. }
  2508. return result;
  2509. }
  2510. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2511. {
  2512. string result = origin;
  2513. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2514. {
  2515. string[] temparr = origin.Split(',');
  2516. result = "";
  2517. foreach (var item in temparr)
  2518. {
  2519. int tempId;
  2520. bool success = int.TryParse(item, out tempId);
  2521. if (success)
  2522. {
  2523. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2524. if (tempInfo != null)
  2525. {
  2526. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2527. }
  2528. }
  2529. }
  2530. }
  2531. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2532. return result;
  2533. }
  2534. /// <summary>
  2535. /// 机票费用录入,删除
  2536. /// </summary>
  2537. /// <param name="dto"></param>
  2538. /// <returns></returns>
  2539. [HttpPost]
  2540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2541. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2542. {
  2543. try
  2544. {
  2545. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2546. if (res)
  2547. {
  2548. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2549. {
  2550. IsDel = 1,
  2551. DeleteUserId = dto.DeleteUserId,
  2552. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2553. }).ExecuteCommandAsync();
  2554. return Ok(JsonView(true, "删除成功!"));
  2555. }
  2556. return Ok(JsonView(false, "删除失败!"));
  2557. }
  2558. catch (Exception ex)
  2559. {
  2560. return Ok(JsonView(false, "程序错误!"));
  2561. throw;
  2562. }
  2563. }
  2564. /// <summary>
  2565. /// 导出机票录入报表
  2566. /// </summary>
  2567. /// <param name="dto"></param>
  2568. /// <returns></returns>
  2569. [HttpPost]
  2570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2571. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2572. {
  2573. try
  2574. {
  2575. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2576. if (groupData.Code != 0)
  2577. {
  2578. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2579. }
  2580. else
  2581. {
  2582. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2583. if (AirTicketReservations.Count != 0)
  2584. {
  2585. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2586. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2587. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2588. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2589. WorkbookDesigner designer = new WorkbookDesigner();
  2590. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2591. decimal countCost = 0;
  2592. foreach (var item in AirTicketReservations)
  2593. {
  2594. #region 处理客人姓名
  2595. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2596. item.ClientName = clientNames;
  2597. #endregion
  2598. if (item.BankType == "其他")
  2599. {
  2600. item.BankNo = "--";
  2601. }
  2602. else
  2603. {
  2604. if (!string.IsNullOrEmpty(item.BankType))
  2605. {
  2606. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2607. }
  2608. }
  2609. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2610. item.Price = System.Decimal.Round(item.Price, 2);
  2611. countCost += Convert.ToDecimal(item.Price);
  2612. }
  2613. designer.SetDataSource("Export", AirTicketReservations);
  2614. designer.SetDataSource("ExportDiCode", diCode);
  2615. designer.SetDataSource("ExportDiName", diName);
  2616. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2617. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2618. designer.Process();
  2619. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2620. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2621. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2622. return Ok(JsonView(true, "成功", url = rst));
  2623. }
  2624. else
  2625. {
  2626. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2627. }
  2628. }
  2629. }
  2630. catch (Exception ex)
  2631. {
  2632. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2633. throw;
  2634. }
  2635. }
  2636. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2637. /// <summary>
  2638. /// 行程单导出
  2639. /// </summary>
  2640. /// <param name="dto"></param>
  2641. /// <returns></returns>
  2642. [HttpPost]
  2643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2644. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2645. {
  2646. try
  2647. {
  2648. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2649. if (groupData.Code != 0)
  2650. {
  2651. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2652. }
  2653. else
  2654. {
  2655. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2656. if (dto.Language == "CN")
  2657. {
  2658. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2659. DocumentBuilder builder = new DocumentBuilder(doc);
  2660. int tableIndex = 0;//表格索引
  2661. //得到文档中的第一个表格
  2662. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2663. foreach (var item in _AirTicketReservations)
  2664. {
  2665. #region 处理固定数据
  2666. string[] FlightsCode = item.FlightsCode.Split('/');
  2667. if (FlightsCode.Length != 0)
  2668. {
  2669. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2670. if (_AirCompany != null)
  2671. {
  2672. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2673. }
  2674. else
  2675. {
  2676. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2677. }
  2678. }
  2679. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2680. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2681. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2682. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2683. string name = "";
  2684. foreach (string clientName in nameArray)
  2685. {
  2686. if (!name.Contains(clientName))
  2687. {
  2688. name += clientName + ",";
  2689. }
  2690. }
  2691. if (!string.IsNullOrWhiteSpace(name))
  2692. {
  2693. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2694. }
  2695. else
  2696. {
  2697. table.Range.Bookmarks["ClientName"].Text = "--";
  2698. }
  2699. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2700. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2701. table.Range.Bookmarks["JointTicket"].Text = "--";
  2702. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2703. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2704. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2705. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2706. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2707. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2708. #endregion
  2709. #region 循环数据处理
  2710. List<AirInfo> airs = new List<AirInfo>();
  2711. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2712. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2713. for (int i = 0; i < FlightsCode.Length; i++)
  2714. {
  2715. AirInfo air = new AirInfo();
  2716. string[] tempstr = DayArray[i]
  2717. .Replace("\r\n", string.Empty)
  2718. .Replace("\\r\\n", string.Empty)
  2719. .TrimStart().TrimEnd()
  2720. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2721. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2722. string starCity = "";
  2723. if (star_Three != null)
  2724. {
  2725. starCity = star_Three.AirPort;
  2726. }
  2727. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2728. string EndCity = "";
  2729. if (End_Three != null)
  2730. {
  2731. EndCity = End_Three.AirPort;
  2732. }
  2733. air.Destination = starCity + "/" + EndCity;
  2734. air.Flight = FlightsCode[i];
  2735. air.SeatingClass = item.CTypeName;
  2736. string dateTime = tempstr[2];
  2737. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2738. air.FlightDate = DateTemp;
  2739. air.DepartureTime = tempstr[5];
  2740. air.LandingTime = tempstr[6];
  2741. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2742. air.TicketStatus = "--";
  2743. air.Luggage = "--";
  2744. air.DepartureTerminal = "--";
  2745. air.LandingTerminal = "--";
  2746. airs.Add(air);
  2747. }
  2748. int row = 13;
  2749. for (int i = 0; i < airs.Count; i++)
  2750. {
  2751. if (airs.Count > 2)
  2752. {
  2753. for (int j = 0; j < airs.Count - 2; j++)
  2754. {
  2755. var CopyRow = table.Rows[12].Clone(true);
  2756. table.Rows.Add(CopyRow);
  2757. }
  2758. }
  2759. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2760. int index = 0;
  2761. foreach (PropertyInfo property in properties)
  2762. {
  2763. string value = property.GetValue(airs[i]).ToString();
  2764. Cell ishcel0 = table.Rows[row].Cells[index];
  2765. Paragraph p = new Paragraph(doc);
  2766. string s = value;
  2767. p.AppendChild(new Run(doc, s));
  2768. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2769. ishcel0.AppendChild(p);
  2770. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2771. index++;
  2772. }
  2773. row++;
  2774. }
  2775. #endregion
  2776. Paragraph lastParagraph = new Paragraph(doc);
  2777. //第一个表格末尾加段落
  2778. table.ParentNode.InsertAfter(lastParagraph, table);
  2779. //复制第一个表格
  2780. Table cloneTable = (Table)table.Clone(true);
  2781. //在文档末尾段落后面加入复制的表格
  2782. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2783. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2784. {
  2785. int rownewsIndex = 13;
  2786. for (int i = 0; i < 2; i++)
  2787. {
  2788. var CopyRow = table.Rows[12].Clone(true);
  2789. table.Rows.RemoveAt(13);
  2790. table.Rows.Add(CopyRow);
  2791. rownewsIndex++;
  2792. }
  2793. }
  2794. else
  2795. {
  2796. table.Rows.RemoveAt(12);
  2797. }
  2798. cloneTable.Rows.RemoveAt(12);
  2799. }
  2800. if (_AirTicketReservations.Count != 0)
  2801. {
  2802. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2803. if (FlightsCode.Length != 0)
  2804. {
  2805. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2806. if (_AirCompany != null)
  2807. {
  2808. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2809. }
  2810. else
  2811. {
  2812. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2813. }
  2814. }
  2815. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2816. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2817. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2818. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2819. string name = "";
  2820. foreach (string clientName in nameArray)
  2821. {
  2822. if (!name.Contains(clientName))
  2823. {
  2824. name += clientName + ",";
  2825. }
  2826. }
  2827. if (!string.IsNullOrWhiteSpace(name))
  2828. {
  2829. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2830. }
  2831. else
  2832. {
  2833. table.Range.Bookmarks["ClientName"].Text = "--";
  2834. }
  2835. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2836. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2837. table.Range.Bookmarks["JointTicket"].Text = "--";
  2838. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2839. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2840. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2841. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2842. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2843. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2844. }
  2845. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2846. //保存合并后的文档
  2847. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2848. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2849. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2850. return Ok(JsonView(true, "成功!", rst));
  2851. }
  2852. else
  2853. {
  2854. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2855. DocumentBuilder builder = new DocumentBuilder(doc);
  2856. int tableIndex = 0;//表格索引
  2857. //得到文档中的第一个表格
  2858. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2859. List<string> texts = new List<string>();
  2860. foreach (var item in _AirTicketReservations)
  2861. {
  2862. string[] FlightsCode = item.FlightsCode.Split('/');
  2863. if (FlightsCode.Length != 0)
  2864. {
  2865. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2866. if (_AirCompany != null)
  2867. {
  2868. if (!transDic.ContainsKey(_AirCompany.CnName))
  2869. {
  2870. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2871. }
  2872. }
  2873. else
  2874. {
  2875. if (!transDic.ContainsKey("--"))
  2876. {
  2877. transDic.Add("--", "--");
  2878. }
  2879. }
  2880. }
  2881. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2882. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2883. string name = "";
  2884. foreach (string clientName in nameArray)
  2885. {
  2886. name += clientName + ",";
  2887. }
  2888. if (!texts.Contains(name))
  2889. {
  2890. texts.Add(name);
  2891. }
  2892. List<AirInfo> airs = new List<AirInfo>();
  2893. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2894. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2895. for (int i = 0; i < FlightsCode.Length; i++)
  2896. {
  2897. AirInfo air = new AirInfo();
  2898. string[] tempstr = DayArray[i]
  2899. .Replace("\r\n", string.Empty)
  2900. .Replace("\\r\\n", string.Empty)
  2901. .TrimStart().TrimEnd()
  2902. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2903. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2904. if (star_Three != null)
  2905. {
  2906. if (!transDic.ContainsKey(star_Three.AirPort))
  2907. {
  2908. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2909. }
  2910. }
  2911. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2912. if (End_Three != null)
  2913. {
  2914. if (!transDic.ContainsKey(End_Three.AirPort))
  2915. {
  2916. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2917. }
  2918. }
  2919. if (!texts.Contains(item.CTypeName))
  2920. {
  2921. texts.Add(item.CTypeName);
  2922. }
  2923. }
  2924. }
  2925. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2926. if (transData.Count > 0)
  2927. {
  2928. foreach (TranslateResult item in transData)
  2929. {
  2930. if (!transDic.ContainsKey(item.Query))
  2931. {
  2932. transDic.Add(item.Query, item.Translation);
  2933. }
  2934. }
  2935. }
  2936. foreach (var item in _AirTicketReservations)
  2937. {
  2938. #region 处理固定数据
  2939. string[] FlightsCode = item.FlightsCode.Split('/');
  2940. if (FlightsCode.Length != 0)
  2941. {
  2942. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2943. if (_AirCompany != null)
  2944. {
  2945. string str = "--";
  2946. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2947. if (!string.IsNullOrEmpty(translateResult))
  2948. {
  2949. str = translateResult;
  2950. str = _airTicketResRep.Processing(str);
  2951. }
  2952. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2953. }
  2954. else
  2955. {
  2956. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2957. }
  2958. }
  2959. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2960. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2961. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2962. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2963. string names = "";
  2964. foreach (string clientName in nameArray)
  2965. {
  2966. names += clientName + ",";
  2967. }
  2968. if (!string.IsNullOrWhiteSpace(names))
  2969. {
  2970. string str = "--";
  2971. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2972. if (!string.IsNullOrEmpty(translateResult))
  2973. {
  2974. str = translateResult;
  2975. str = _airTicketResRep.Processing(str);
  2976. }
  2977. table.Range.Bookmarks["ClientName"].Text = str;
  2978. }
  2979. else
  2980. {
  2981. table.Range.Bookmarks["ClientName"].Text = "--";
  2982. }
  2983. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2984. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2985. table.Range.Bookmarks["JointTicket"].Text = "--";
  2986. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2987. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2988. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2989. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2990. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2991. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2992. #endregion
  2993. #region 循环数据处理
  2994. List<AirInfo> airs = new List<AirInfo>();
  2995. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2996. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2997. for (int i = 0; i < FlightsCode.Length; i++)
  2998. {
  2999. AirInfo air = new AirInfo();
  3000. string[] tempstr = DayArray[i]
  3001. .Replace("\r\n", string.Empty)
  3002. .Replace("\\r\\n", string.Empty)
  3003. .TrimStart().TrimEnd()
  3004. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3005. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3006. string starCity = "";
  3007. if (star_Three != null)
  3008. {
  3009. string str2 = "--";
  3010. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3011. if (!string.IsNullOrEmpty(translateResult2))
  3012. {
  3013. str2 = translateResult2;
  3014. str2 = _airTicketResRep.Processing(str2);
  3015. }
  3016. starCity = str2;
  3017. }
  3018. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3019. string EndCity = "";
  3020. if (End_Three != null)
  3021. {
  3022. string str1 = "--";
  3023. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3024. if (!string.IsNullOrEmpty(translateResult1))
  3025. {
  3026. str1 = translateResult1;
  3027. str1 = _airTicketResRep.Processing(str1);
  3028. }
  3029. EndCity = str1;
  3030. }
  3031. air.Destination = starCity + "/" + EndCity;
  3032. air.Flight = FlightsCode[i];
  3033. string str = "--";
  3034. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3035. if (!string.IsNullOrEmpty(translateResult))
  3036. {
  3037. str = translateResult;
  3038. str = _airTicketResRep.Processing(str);
  3039. }
  3040. air.SeatingClass = str;
  3041. string dateTime = tempstr[2];
  3042. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3043. air.FlightDate = DateTemp;
  3044. air.DepartureTime = tempstr[5];
  3045. air.LandingTime = tempstr[6];
  3046. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3047. air.TicketStatus = "--";
  3048. air.Luggage = "--";
  3049. air.DepartureTerminal = "--";
  3050. air.LandingTerminal = "--";
  3051. airs.Add(air);
  3052. }
  3053. int row = 13;
  3054. for (int i = 0; i < airs.Count; i++)
  3055. {
  3056. if (airs.Count > 2)
  3057. {
  3058. for (int j = 0; j < airs.Count - 2; j++)
  3059. {
  3060. var CopyRow = table.Rows[12].Clone(true);
  3061. table.Rows.Add(CopyRow);
  3062. }
  3063. }
  3064. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3065. int index = 0;
  3066. foreach (PropertyInfo property in properties)
  3067. {
  3068. string value = property.GetValue(airs[i]).ToString();
  3069. Cell ishcel0 = table.Rows[row].Cells[index];
  3070. Paragraph p = new Paragraph(doc);
  3071. string s = value;
  3072. p.AppendChild(new Run(doc, s));
  3073. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3074. ishcel0.AppendChild(p);
  3075. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3076. //ishcel0.CellFormat.VerticalAlignment=
  3077. index++;
  3078. }
  3079. row++;
  3080. }
  3081. #endregion
  3082. Paragraph lastParagraph = new Paragraph(doc);
  3083. //第一个表格末尾加段落
  3084. table.ParentNode.InsertAfter(lastParagraph, table);
  3085. //复制第一个表格
  3086. Table cloneTable = (Table)table.Clone(true);
  3087. //在文档末尾段落后面加入复制的表格
  3088. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3089. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3090. {
  3091. int rownewsIndex = 13;
  3092. for (int i = 0; i < 2; i++)
  3093. {
  3094. var CopyRow = table.Rows[12].Clone(true);
  3095. table.Rows.RemoveAt(13);
  3096. table.Rows.Add(CopyRow);
  3097. rownewsIndex++;
  3098. }
  3099. }
  3100. else
  3101. {
  3102. table.Rows.RemoveAt(12);
  3103. }
  3104. cloneTable.Rows.RemoveAt(12);
  3105. }
  3106. if (_AirTicketReservations.Count != 0)
  3107. {
  3108. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3109. if (FlightsCode.Length != 0)
  3110. {
  3111. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3112. if (_AirCompany != null)
  3113. {
  3114. string str = "--";
  3115. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3116. if (!string.IsNullOrEmpty(translateResult))
  3117. {
  3118. str = translateResult;
  3119. str = _airTicketResRep.Processing(str);
  3120. }
  3121. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3122. }
  3123. else
  3124. {
  3125. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3126. }
  3127. }
  3128. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3129. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3130. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3131. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3132. string names = "";
  3133. foreach (string clientName in nameArray)
  3134. {
  3135. names += clientName + ",";
  3136. }
  3137. if (!string.IsNullOrWhiteSpace(names))
  3138. {
  3139. string str = "--";
  3140. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3141. if (!string.IsNullOrEmpty(translateResult))
  3142. {
  3143. str = translateResult;
  3144. str = _airTicketResRep.Processing(str);
  3145. }
  3146. table.Range.Bookmarks["ClientName"].Text = str;
  3147. }
  3148. else
  3149. {
  3150. table.Range.Bookmarks["ClientName"].Text = "--";
  3151. }
  3152. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3153. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3154. table.Range.Bookmarks["JointTicket"].Text = "--";
  3155. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3156. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3157. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3158. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3159. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3160. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3161. }
  3162. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3163. //保存合并后的文档
  3164. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3165. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3166. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3167. return Ok(JsonView(true, "成功!", rst));
  3168. }
  3169. }
  3170. }
  3171. catch (Exception ex)
  3172. {
  3173. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3174. throw;
  3175. }
  3176. }
  3177. #endregion
  3178. #region 团组增减款项 --> 其他款项
  3179. /// <summary>
  3180. /// 团组增减款项下拉框绑定
  3181. /// </summary>
  3182. /// <param name="dto"></param>
  3183. /// <returns></returns>
  3184. [HttpPost]
  3185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3186. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3187. {
  3188. #region 参数验证
  3189. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3190. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3191. #endregion
  3192. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3193. }
  3194. /// <summary>
  3195. /// 根据团组Id查询团组增减款项
  3196. /// </summary>
  3197. /// <param name="dto"></param>
  3198. /// <returns></returns>
  3199. [HttpPost]
  3200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3201. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3202. {
  3203. #region 参数验证
  3204. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3205. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3206. #endregion
  3207. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3208. }
  3209. /// <summary>
  3210. /// 团组增减款项操作(Status:1.新增,2.修改)
  3211. /// </summary>
  3212. /// <param name="dto"></param>
  3213. /// <returns></returns>
  3214. [HttpPost]
  3215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3216. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3217. {
  3218. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3219. if (groupData.Code != 200)
  3220. {
  3221. return Ok(JsonView(false, groupData.Msg));
  3222. }
  3223. #region 应用推送
  3224. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3225. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3226. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3227. //自动审核
  3228. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3229. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3230. //2024-10-21 新增LZ UID
  3231. var userIds = new List<int>() { 21 };
  3232. string title = $"系统通知";
  3233. string content = "";
  3234. var diId = dto.DiId;
  3235. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3236. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3237. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3238. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3239. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3240. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3241. #endregion
  3242. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3243. }
  3244. /// <summary>
  3245. /// 团组增减款项操作 删除
  3246. /// </summary>
  3247. /// <param name="dto"></param>
  3248. /// <returns></returns>
  3249. [HttpPost]
  3250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3251. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3252. {
  3253. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3254. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3255. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3256. if (res.Code == 0)
  3257. {
  3258. return Ok(JsonView(true, "删除成功!"));
  3259. }
  3260. return Ok(JsonView(false, "删除失败!"));
  3261. }
  3262. /// <summary>
  3263. /// 根据团组增减款项Id查询
  3264. /// </summary>
  3265. /// <param name="dto"></param>
  3266. /// <returns></returns>
  3267. [HttpPost]
  3268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3269. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3270. {
  3271. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3272. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3273. }
  3274. /// <summary>
  3275. /// 查询供应商名称
  3276. /// </summary>
  3277. /// <param name="dto"></param>
  3278. /// <returns></returns>
  3279. [HttpPost]
  3280. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3281. {
  3282. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3283. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3284. ?? new List<Grp_DecreasePayments>();
  3285. dbResult = dbResult.Distinct(new
  3286. ProductComparer()).ToList();
  3287. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3288. {
  3289. x.Id,
  3290. x.SupplierAddress,
  3291. x.SupplierArea,
  3292. x.SupplierContact,
  3293. x.SupplierContactNumber,
  3294. x.SupplierEmail,
  3295. x.SupplierName,
  3296. x.SupplierSocialAccount,
  3297. x.SupplierTypeId,
  3298. }).ToList());
  3299. return Ok(jw);
  3300. }
  3301. /// <summary>
  3302. /// 团组增减款项 OTA匹配
  3303. /// </summary>
  3304. /// <param name="file"></param>
  3305. /// <returns></returns>
  3306. [HttpPost]
  3307. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3308. {
  3309. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3310. string fileName = file.FileName;
  3311. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3312. {
  3313. return Ok(JsonView(false, "请上传Excel文件!"));
  3314. }
  3315. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3316. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3317. if (!Directory.Exists(path))
  3318. {
  3319. Directory.CreateDirectory(path);
  3320. }
  3321. var filePath = @$"{path}/{fileName}";
  3322. //保存文件
  3323. using (FileStream fs = System.IO.File.Create(filePath))
  3324. {
  3325. file.CopyTo(fs);
  3326. fs.Flush();
  3327. }
  3328. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3329. //读取ExcelFile
  3330. DataTable dt = ConvertExcelToDataTable(filePath);
  3331. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3332. dt.TableName = "TB";
  3333. //修改table列名
  3334. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3335. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3336. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3337. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3338. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3339. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3340. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3341. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3342. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3343. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3344. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3345. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3346. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3347. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3348. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3349. var otaOrderNos = new List<string>();
  3350. foreach (DataRow item in dt.Rows)
  3351. {
  3352. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3353. }
  3354. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3355. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3356. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3357. .Select((dp, di) => new
  3358. {
  3359. dp.PriceName,
  3360. dp.OTAOrderNo,
  3361. dp.FeeTotal,
  3362. di.TeamName,
  3363. })
  3364. .ToListAsync();
  3365. foreach (DataRow item in dt.Rows)
  3366. {
  3367. var otaOrderNo = item["OTAOrderNo"].ToString();
  3368. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3369. if (oaData == null) continue;
  3370. item["GroupName"] = oaData.TeamName;
  3371. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3372. }
  3373. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3374. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3375. List<DataTable> datas = new List<DataTable>();
  3376. datas.Add(dt);
  3377. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3378. return Ok(JsonView(true, "操作成功", new { url = url }));
  3379. }
  3380. #region
  3381. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3382. {
  3383. // 创建Workbook对象
  3384. Workbook workbook = new Workbook(excelFilePath);
  3385. // 获取第一个工作表
  3386. Worksheet worksheet = workbook.Worksheets[0];
  3387. // 将工作表转换为DataTable
  3388. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3389. return dataTable;
  3390. }
  3391. #endregion
  3392. #endregion
  3393. #region 文件上传、删除
  3394. /// <summary>
  3395. /// region 文件上传 可以带参数
  3396. /// </summary>
  3397. /// <param name="file"></param>
  3398. /// <returns></returns>
  3399. [HttpPost]
  3400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3401. public async Task<IActionResult> UploadProject(IFormFile file)
  3402. {
  3403. //var TypeName = Request.Headers["TypeName"].ToString();
  3404. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3405. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3406. ////文件名称
  3407. //string projectFileName = file.FileName;
  3408. ////上传的文件的路径
  3409. //string filePath = $"{fileDir}/{projectFileName}";
  3410. //if (TypeName == "A")//A代表团组增减款项
  3411. //{
  3412. // filePath = fileDir + $@"\团组增减款项相关文件";
  3413. // if (!Directory.Exists(filePath))
  3414. // {
  3415. // Directory.CreateDirectory(filePath);
  3416. // }
  3417. // //上传的文件的路径
  3418. // filePath += $@"\{projectFileName}";
  3419. //}
  3420. //else if (TypeName == "B")//B代表商邀相关文件
  3421. //{
  3422. // //上传的文件的路径
  3423. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3424. // if (!Directory.Exists(filePath))
  3425. // {
  3426. // Directory.CreateDirectory(filePath);
  3427. // }
  3428. // //上传的文件的路径
  3429. // filePath = $@"\{projectFileName}";
  3430. //}
  3431. //try
  3432. //{
  3433. // using (FileStream fs = System.IO.File.Create(filePath))
  3434. // {
  3435. // file.CopyTo(fs);
  3436. // fs.Flush();
  3437. // }
  3438. //}
  3439. //catch (Exception ex)
  3440. //{
  3441. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3442. //}
  3443. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3444. try
  3445. {
  3446. var TypeName = Request.Headers["TypeName"].ToString();
  3447. if (file != null)
  3448. {
  3449. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3450. //文件名称
  3451. string projectFileName = file.FileName;
  3452. //上传的文件的路径
  3453. string filePath = $"{fileDir}/{projectFileName}";
  3454. if (TypeName == "A")//A代表团组增减款项
  3455. {
  3456. if (!Directory.Exists(fileDir))
  3457. {
  3458. Directory.CreateDirectory(fileDir);
  3459. }
  3460. //上传的文件的路径
  3461. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3462. }
  3463. else if (TypeName == "B")//B代表商邀相关文件
  3464. {
  3465. if (!Directory.Exists(fileDir))
  3466. {
  3467. Directory.CreateDirectory(fileDir);
  3468. }
  3469. //上传的文件的路径
  3470. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3471. }
  3472. using (FileStream fs = System.IO.File.Create(filePath))
  3473. {
  3474. file.CopyTo(fs);
  3475. fs.Flush();
  3476. }
  3477. return Ok(JsonView(true, "上传成功!", projectFileName));
  3478. }
  3479. else
  3480. {
  3481. return Ok(JsonView(false, "上传失败!"));
  3482. }
  3483. }
  3484. catch (Exception ex)
  3485. {
  3486. return Ok(JsonView(false, "程序错误!"));
  3487. }
  3488. }
  3489. /// <summary>
  3490. /// 删除指定文件
  3491. /// </summary>
  3492. /// <param name="dto"></param>
  3493. /// <returns></returns>
  3494. [HttpPost]
  3495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3496. public async Task<IActionResult> DelFile(DelFileDto dto)
  3497. {
  3498. try
  3499. {
  3500. var TypeName = Request.Headers["TypeName"].ToString();
  3501. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3502. string filePath = "";
  3503. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3504. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3505. int id = 0;
  3506. if (TypeName == "A")
  3507. {
  3508. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3509. // 删除该文件
  3510. System.IO.File.Delete(filePath);
  3511. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3512. .Where(a => a.Id == dto.Id)
  3513. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3514. .ExecuteCommandAsync();
  3515. }
  3516. else if (TypeName == "B")
  3517. {
  3518. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3519. // 删除该文件
  3520. System.IO.File.Delete(filePath);
  3521. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3522. if (info != null)
  3523. {
  3524. string[] files = new string[] { };
  3525. if (!string.IsNullOrEmpty(info.Attachment))
  3526. {
  3527. try
  3528. {
  3529. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3530. }
  3531. catch (Exception)
  3532. {
  3533. files = new List<string>() { info.Attachment }.ToArray();
  3534. }
  3535. }
  3536. if (files.Length > 0)
  3537. {
  3538. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3539. string filePath2 = string.Empty;
  3540. if (files1.Length > 0)
  3541. {
  3542. filePath2 = JsonConvert.SerializeObject(files1);
  3543. }
  3544. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3545. .Where(a => a.Id == dto.Id)
  3546. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3547. .ExecuteCommandAsync();
  3548. }
  3549. }
  3550. }
  3551. if (id != 0)
  3552. {
  3553. return Ok(JsonView(true, "成功!"));
  3554. }
  3555. else
  3556. {
  3557. return Ok(JsonView(false, "失败!"));
  3558. }
  3559. }
  3560. catch (Exception ex)
  3561. {
  3562. return Ok(JsonView(false, "程序错误!"));
  3563. throw;
  3564. }
  3565. }
  3566. /// <summary>
  3567. /// 文件上传多个文件 可以带参数
  3568. /// </summary>
  3569. /// <param name="file"></param>
  3570. /// <returns></returns>
  3571. [HttpPost]
  3572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3573. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3574. {
  3575. try
  3576. {
  3577. var TypeName = Request.Headers["TypeName"].ToString();
  3578. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3579. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3580. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3581. var filePahts = new List<string>();
  3582. foreach (var file in files)
  3583. {
  3584. //文件名称
  3585. string projectFileName = file.FileName;
  3586. //上传的文件的路径
  3587. string filePath = $"{fileDir}/{projectFileName}";
  3588. if (TypeName == "A")//A代表团组增减款项
  3589. {
  3590. if (!Directory.Exists(fileDir))
  3591. {
  3592. Directory.CreateDirectory(fileDir);
  3593. }
  3594. //上传的文件的路径
  3595. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3596. }
  3597. else if (TypeName == "B")//B代表商邀相关文件
  3598. {
  3599. if (!Directory.Exists(fileDir))
  3600. {
  3601. Directory.CreateDirectory(fileDir);
  3602. }
  3603. //上传的文件的路径
  3604. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3605. }
  3606. using (FileStream fs = System.IO.File.Create(filePath))
  3607. {
  3608. file.CopyTo(fs);
  3609. fs.Flush();
  3610. }
  3611. filePahts.Add(projectFileName);
  3612. }
  3613. return Ok(JsonView(true, "上传成功!", filePahts));
  3614. }
  3615. catch (Exception ex)
  3616. {
  3617. return Ok(JsonView(false, "程序错误!"));
  3618. }
  3619. }
  3620. #endregion
  3621. #region 商邀费用录入
  3622. /// <summary>
  3623. /// 根据团组Id查询商邀费用列表
  3624. /// </summary>
  3625. /// <param name="dto"></param>
  3626. /// <returns></returns>
  3627. [HttpPost]
  3628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3629. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3630. {
  3631. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3632. if (groupData.Code != 0)
  3633. {
  3634. return Ok(JsonView(false, groupData.Msg));
  3635. }
  3636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3637. }
  3638. /// <summary>
  3639. /// 商邀费用列表
  3640. /// 下载文件
  3641. /// </summary>
  3642. /// <param name="dto"></param>
  3643. /// <returns></returns>
  3644. [HttpGet("{id}")]
  3645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3646. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3647. {
  3648. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3649. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3650. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3651. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3652. var filePaths = new List<string>();
  3653. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3654. try
  3655. {
  3656. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3657. }
  3658. catch (Exception ex)
  3659. {
  3660. filePaths.Add(info.Attachment);
  3661. }
  3662. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3663. for (int i = 0; i < filePaths.Count; i++)
  3664. {
  3665. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3666. }
  3667. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3668. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3669. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3670. {
  3671. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3672. {
  3673. foreach (string filePath in filePaths)
  3674. {
  3675. if (System.IO.File.Exists(filePath))
  3676. {
  3677. // 获取文件名
  3678. string fileName = Path.GetFileName(filePath);
  3679. // 将文件添加到ZIP归档中
  3680. zipArchive.CreateEntryFromFile(filePath, fileName);
  3681. }
  3682. }
  3683. }
  3684. }
  3685. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3686. }
  3687. /// <summary>
  3688. /// 商邀费用 Info Page 基础数据源
  3689. /// </summary>
  3690. /// <param name="dto"></param>
  3691. /// <returns></returns>
  3692. [HttpPost]
  3693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3694. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3695. {
  3696. try
  3697. {
  3698. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3699. if (groupData.Code != 0)
  3700. {
  3701. return Ok(JsonView(false, groupData.Msg));
  3702. }
  3703. return Ok(JsonView(true, "操作成功", groupData.Data));
  3704. }
  3705. catch (Exception ex)
  3706. {
  3707. return Ok(JsonView(false, ex.Message));
  3708. throw;
  3709. }
  3710. }
  3711. /// <summary>
  3712. /// 根据商邀费用ID查询C表和商邀费用数据
  3713. /// </summary>
  3714. /// <param name="dto"></param>
  3715. /// <returns></returns>
  3716. [HttpPost]
  3717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3718. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3719. {
  3720. try
  3721. {
  3722. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3723. if (groupData.Code != 0)
  3724. {
  3725. return Ok(JsonView(false, groupData.Msg));
  3726. }
  3727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3728. }
  3729. catch (Exception ex)
  3730. {
  3731. return Ok(JsonView(false, ex.Message));
  3732. throw;
  3733. }
  3734. }
  3735. /// <summary>
  3736. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3737. /// </summary>
  3738. /// <param name="dto"></param>
  3739. /// <returns></returns>
  3740. [HttpPost]
  3741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3742. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3743. {
  3744. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3745. if (groupData.Code != 0)
  3746. {
  3747. return Ok(JsonView(false, groupData.Msg));
  3748. }
  3749. #region 应用推送
  3750. try
  3751. {
  3752. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3753. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3754. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3755. //2024-10-21 新增LZ UID
  3756. var userIds = new List<int>() { 21 };
  3757. string title = $"系统通知";
  3758. string content = "";
  3759. var diId = dto.DiId;
  3760. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3761. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3762. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3763. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3764. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3765. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3766. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3767. }
  3768. catch (Exception ex)
  3769. {
  3770. }
  3771. #endregion
  3772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3773. }
  3774. /// <summary>
  3775. /// 商邀删除
  3776. /// </summary>
  3777. /// <param name="dto"></param>
  3778. /// <returns></returns>
  3779. [HttpPost]
  3780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3781. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3782. {
  3783. try
  3784. {
  3785. _sqlSugar.BeginTran();
  3786. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3787. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3788. {
  3789. IsDel = 1,
  3790. DeleteUserId = dto.DeleteUserId,
  3791. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3792. })
  3793. .Where(it => it.Id == dto.Id)
  3794. .ExecuteCommand();
  3795. if (res1 > 0)
  3796. {
  3797. int _diId = 0;
  3798. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3799. if (_ioaInfo != null)
  3800. {
  3801. _diId = _ioaInfo.DiId;
  3802. }
  3803. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3804. .SetColumns(a => new Grp_CreditCardPayment()
  3805. {
  3806. IsDel = 1,
  3807. DeleteUserId = dto.DeleteUserId,
  3808. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3809. })
  3810. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3811. .ExecuteCommand();
  3812. if (res2 > 0)
  3813. {
  3814. _sqlSugar.CommitTran();
  3815. return Ok(JsonView(true, "删除成功!"));
  3816. }
  3817. }
  3818. _sqlSugar.RollbackTran();
  3819. return Ok(JsonView(false, "删除失败"));
  3820. }
  3821. catch (Exception ex)
  3822. {
  3823. _sqlSugar.RollbackTran();
  3824. return Ok(JsonView(false, ex.Message));
  3825. }
  3826. }
  3827. /// <summary>
  3828. /// 团组模块文件上传
  3829. /// </summary>
  3830. /// <param name="dto"></param>
  3831. /// <returns></returns>
  3832. [HttpPost]
  3833. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3834. {
  3835. var jw = JsonView(false);
  3836. long M = 1024 * 1024;
  3837. if (dto.Files == null || dto.Files.Count == 0)
  3838. {
  3839. jw.Msg = "无文件信息!";
  3840. return Ok(jw);
  3841. }
  3842. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3843. {
  3844. jw.Msg = "文件大小超过20M!";
  3845. return Ok(jw);
  3846. }
  3847. //var nameSp = dto.File.FileName.Split(".");
  3848. //if (nameSp.Length < 2)
  3849. //{
  3850. // jw.Msg = "拓展名称有误!";
  3851. // return Ok(jw);
  3852. //}
  3853. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3854. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3855. //{
  3856. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3857. // return Ok(jw);
  3858. //}
  3859. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3860. if (Ctable == null)
  3861. {
  3862. jw.Msg = "Ctable指向有误!";
  3863. return Ok(jw);
  3864. }
  3865. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3866. if (groupInfo == null)
  3867. {
  3868. jw.Msg = "团组信息不存在!";
  3869. return Ok(jw);
  3870. }
  3871. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3872. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3873. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3874. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3875. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3876. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3877. try
  3878. {
  3879. if (!Directory.Exists(fileBase))
  3880. {
  3881. Directory.CreateDirectory(fileBase);
  3882. }
  3883. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3884. foreach (var fileStream in dto.Files)
  3885. {
  3886. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3887. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3888. {
  3889. Cid = dto.Cid,
  3890. CreateTime = DateTime.Now,
  3891. CreateUserId = dto.Userid,
  3892. Ctable = dto.Ctable,
  3893. Diid = dto.Diid,
  3894. IsDel = 0,
  3895. FilePath = saveFilePath,
  3896. FileName = fileStream.FileName
  3897. };
  3898. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3899. {
  3900. fileStream.CopyTo(fs);
  3901. fs.Flush();
  3902. }
  3903. saveArr.Add(file);
  3904. }
  3905. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3906. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3907. jw = JsonView(true, "保存成功!", new
  3908. {
  3909. count = addResult,
  3910. filesName = saveArr.Select(x => x.FileName)
  3911. });
  3912. }
  3913. catch (Exception ex)
  3914. {
  3915. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3916. {
  3917. count = 0,
  3918. filesName = new string[0],
  3919. });
  3920. }
  3921. return Ok(jw);
  3922. }
  3923. /// <summary>
  3924. /// 查询各模块已保存文件
  3925. /// </summary>
  3926. /// <param name="dto"></param>
  3927. /// <returns></returns>
  3928. [HttpPost]
  3929. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3930. {
  3931. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3932. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3933. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3934. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3935. {
  3936. expression = Expressionable.Create<Grp_GroupModelFile>()
  3937. .And(x => visaIds.Contains(x.CreateUserId));
  3938. }
  3939. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3940. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3941. .Where(expression.ToExpression())
  3942. .ToList();
  3943. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3944. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3945. {
  3946. x.FileName,
  3947. x.Id,
  3948. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3949. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3950. })));
  3951. }
  3952. /// <summary>
  3953. /// 下载该团组下的所有文件
  3954. /// </summary>
  3955. /// <param name="dto"></param>
  3956. /// <returns></returns>
  3957. [HttpPost]
  3958. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3959. {
  3960. var jw = JsonView(false);
  3961. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3962. if (groupInfo == null)
  3963. {
  3964. jw.Msg = "团组信息不存在!";
  3965. return Ok(jw);
  3966. }
  3967. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3968. var isModule = Convert.ToBoolean(dto.isModule);
  3969. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3970. IOOperatorHelper io = new IOOperatorHelper();
  3971. if (isModule)
  3972. {
  3973. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3974. foreach (var moduleArr in moduleGroup)
  3975. {
  3976. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3977. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3978. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3979. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3980. foreach (var item in moduleArr)
  3981. {
  3982. if (System.IO.File.Exists(item.FilePath))
  3983. {
  3984. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3985. {
  3986. byte[] bytes = new byte[fileStream.Length];
  3987. fileStream.Read(bytes, 0, bytes.Length);
  3988. fileStream.Close();
  3989. Stream stream = new MemoryStream(bytes);
  3990. chiZips.Add(item.FileName, stream);
  3991. }
  3992. }
  3993. }
  3994. if (chiZips.Count > 0)
  3995. {
  3996. var byts = io.ConvertZipStream(chiZips);
  3997. Stream stream = new MemoryStream(byts);
  3998. Zips.Add(key.Name + "_.zip", stream);
  3999. }
  4000. }
  4001. }
  4002. else
  4003. {
  4004. foreach (var item in dbQuery)
  4005. {
  4006. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4007. {
  4008. byte[] bytes = new byte[fileStream.Length];
  4009. fileStream.Read(bytes, 0, bytes.Length);
  4010. fileStream.Close();
  4011. Stream stream = new MemoryStream(bytes);
  4012. while (Zips.Keys.Contains(item.FileName))
  4013. {
  4014. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4015. }
  4016. Zips.Add(item.FileName, stream);
  4017. }
  4018. }
  4019. }
  4020. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4021. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4022. if (Zips.Count > 0)
  4023. {
  4024. var byts = io.ConvertZipStream(Zips);
  4025. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4026. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4027. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4028. }
  4029. else
  4030. {
  4031. jw.Msg = "暂无生成文件!";
  4032. }
  4033. return Ok(jw);
  4034. }
  4035. /// <summary>
  4036. /// 下载该团组下此模块的所有文件
  4037. /// </summary>
  4038. /// <param name="dto"></param>
  4039. /// <returns></returns>
  4040. [HttpPost]
  4041. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4042. {
  4043. var jw = JsonView(false);
  4044. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4045. if (groupInfo == null)
  4046. {
  4047. jw.Msg = "团组信息不存在!";
  4048. return Ok(jw);
  4049. }
  4050. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4051. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4052. && x.IsDel == 0);
  4053. if (key == null)
  4054. {
  4055. jw.Msg = "Ctable指向错误!";
  4056. return Ok(jw);
  4057. }
  4058. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4059. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4060. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4061. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4062. IOOperatorHelper io = new IOOperatorHelper();
  4063. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4064. foreach (var item in dbQuery)
  4065. {
  4066. if (System.IO.File.Exists(item.FilePath))
  4067. {
  4068. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4069. {
  4070. byte[] bytes = new byte[fileStream.Length];
  4071. fileStream.Read(bytes, 0, bytes.Length);
  4072. fileStream.Close();
  4073. Stream stream = new MemoryStream(bytes);
  4074. while (Zips.Keys.Contains(item.FileName))
  4075. {
  4076. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4077. }
  4078. Zips.Add(item.FileName, stream);
  4079. }
  4080. }
  4081. }
  4082. if (Zips.Count > 0)
  4083. {
  4084. var byts = io.ConvertZipStream(Zips);
  4085. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4086. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4087. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4088. }
  4089. else
  4090. {
  4091. jw.Msg = "暂无生成文件!";
  4092. }
  4093. return Ok(jw);
  4094. }
  4095. /// <summary>
  4096. /// 删除该团组下的指定文件
  4097. /// </summary>
  4098. /// <param name="dto"></param>
  4099. /// <returns></returns>
  4100. [HttpPost]
  4101. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4102. {
  4103. var jw = JsonView(false);
  4104. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4105. if (sing == null)
  4106. {
  4107. jw.Msg = "暂无";
  4108. return Ok(jw);
  4109. }
  4110. if (System.IO.File.Exists(sing.FilePath))
  4111. {
  4112. try
  4113. {
  4114. System.IO.File.Delete(sing.FilePath);
  4115. }
  4116. catch (Exception ex)
  4117. {
  4118. jw.Msg = "删除失败!" + ex.Message;
  4119. return Ok(jw);
  4120. }
  4121. }
  4122. sing.IsDel = 1;
  4123. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4124. sing.DeleteUserId = dto.UserId;
  4125. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4126. jw = JsonView(true, "删除成功!");
  4127. return Ok(jw);
  4128. }
  4129. #endregion
  4130. #region 团组英文资料
  4131. /// <summary>
  4132. /// 查询团组英文所有资料
  4133. /// </summary>
  4134. /// <param name="dto"></param>
  4135. /// <returns></returns>
  4136. [HttpPost]
  4137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4138. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4139. {
  4140. try
  4141. {
  4142. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4143. if (groupData.Code != 0)
  4144. {
  4145. return Ok(JsonView(false, groupData.Msg));
  4146. }
  4147. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4148. }
  4149. catch (Exception ex)
  4150. {
  4151. return Ok(JsonView(false, "程序错误!"));
  4152. throw;
  4153. }
  4154. }
  4155. /// <summary>
  4156. /// 团组英文资料操作(Status:1.新增,2.修改)
  4157. /// </summary>
  4158. /// <param name="dto"></param>
  4159. /// <returns></returns>
  4160. [HttpPost]
  4161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4162. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4163. {
  4164. try
  4165. {
  4166. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4167. if (groupData.Code != 0)
  4168. {
  4169. return Ok(JsonView(false, groupData.Msg));
  4170. }
  4171. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4172. }
  4173. catch (Exception ex)
  4174. {
  4175. return Ok(JsonView(false, "程序错误!"));
  4176. throw;
  4177. }
  4178. }
  4179. /// <summary>
  4180. /// 团组英文资料Id查询数据
  4181. /// </summary>
  4182. /// <param name="dto"></param>
  4183. /// <returns></returns>
  4184. [HttpPost]
  4185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4186. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4187. {
  4188. try
  4189. {
  4190. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4191. if (_DelegationEnData != null)
  4192. {
  4193. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4194. }
  4195. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4196. }
  4197. catch (Exception ex)
  4198. {
  4199. return Ok(JsonView(false, "程序错误!"));
  4200. throw;
  4201. }
  4202. }
  4203. /// <summary>
  4204. /// 团组英文资料删除
  4205. /// </summary>
  4206. /// <param name="dto"></param>
  4207. /// <returns></returns>
  4208. [HttpPost]
  4209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4210. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4211. {
  4212. try
  4213. {
  4214. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4215. if (!res)
  4216. {
  4217. return Ok(JsonView(false, "删除失败"));
  4218. }
  4219. return Ok(JsonView(true, "删除成功!"));
  4220. }
  4221. catch (Exception ex)
  4222. {
  4223. return Ok(JsonView(false, "程序错误!"));
  4224. throw;
  4225. }
  4226. }
  4227. #endregion
  4228. #region 导出邀请函
  4229. /// <summary>
  4230. /// 导出邀请函页面初始化
  4231. /// </summary>
  4232. /// <param name="dto"></param>
  4233. /// <returns></returns>
  4234. [HttpPost]
  4235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4236. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4237. {
  4238. try
  4239. {
  4240. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4241. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4242. if (dto.DiId == 0)
  4243. {
  4244. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4245. }
  4246. else
  4247. {
  4248. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4249. }
  4250. return Ok(JsonView(true, "查询成功!", new
  4251. {
  4252. deleClient = crm_Deles,
  4253. delegations = grp_Delegations
  4254. }));
  4255. }
  4256. catch (Exception ex)
  4257. {
  4258. return Ok(JsonView(false, "程序错误!"));
  4259. throw;
  4260. }
  4261. }
  4262. /// <summary>
  4263. /// 导出邀请函
  4264. /// </summary>
  4265. /// <param name="dto"></param>
  4266. /// <returns></returns>
  4267. [HttpPost]
  4268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4269. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4270. {
  4271. #region 参数验证
  4272. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4273. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4274. #endregion
  4275. try
  4276. {
  4277. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4278. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4279. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4280. From Grp_TourClientList tcl
  4281. Left Join
  4282. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4283. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4284. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4285. From Crm_DeleClient dc
  4286. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4287. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4288. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4289. Where dc.IsDel = 0) temp
  4290. On temp.DcId =tcl.ClientId
  4291. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4292. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4293. List<string> texts = new List<string>();
  4294. if (datas.Count != 0)
  4295. {
  4296. foreach (TourClientListDetailsView item in datas)
  4297. {
  4298. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4299. {
  4300. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4301. }
  4302. else
  4303. {
  4304. string name = item.LastName + item.FirstName;
  4305. texts.Add(name);
  4306. }
  4307. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4308. {
  4309. if (!transDic.ContainsKey(item.Job))
  4310. {
  4311. texts.Add(item.Job);
  4312. }
  4313. }
  4314. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4315. {
  4316. texts.Add(item.CompanyFullName);
  4317. }
  4318. }
  4319. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4320. if (transData.Count > 0)
  4321. {
  4322. foreach (TranslateResult item in transData)
  4323. {
  4324. if (!transDic.ContainsKey(item.Query))
  4325. {
  4326. transDic.Add(item.Query, item.Translation);
  4327. }
  4328. }
  4329. }
  4330. List<GuestList> list = new List<GuestList>();
  4331. foreach (TourClientListDetailsView dele in datas)
  4332. {
  4333. GuestList guestList = new GuestList();
  4334. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4335. {
  4336. guestList.Name = dele.Pinyin;
  4337. }
  4338. else
  4339. {
  4340. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4341. guestList.Name = Name;
  4342. }
  4343. if (dele.Sex == 0)
  4344. {
  4345. guestList.Sex = "Male";
  4346. }
  4347. else if (dele.Sex == 1)
  4348. {
  4349. guestList.Sex = "Female";
  4350. }
  4351. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4352. if (!string.IsNullOrEmpty(dele.Job))
  4353. {
  4354. guestList.Job = dele.Job;
  4355. }
  4356. list.Add(guestList);
  4357. }
  4358. //载入模板
  4359. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4360. DocumentBuilder builder = new DocumentBuilder(doc);
  4361. //获取word里所有表格
  4362. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4363. //获取所填表格的序数
  4364. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4365. var rowStart = tableOne.Rows[0]; //获取第1行
  4366. //循环赋值
  4367. for (int i = 0; i < list.Count; i++)
  4368. {
  4369. builder.MoveToCell(0, i + 1, 0, 0);
  4370. builder.Write(list[i].Name.ToString());
  4371. builder.MoveToCell(0, i + 1, 1, 0);
  4372. builder.Write(list[i].Sex.ToString());
  4373. builder.MoveToCell(0, i + 1, 2, 0);
  4374. builder.Write(list[i].DOB.ToString());
  4375. builder.MoveToCell(0, i + 1, 3, 0);
  4376. builder.Write(list[i].Job.ToString());
  4377. }
  4378. //删除多余行
  4379. while (tableOne.Rows.Count > list.Count + 1)
  4380. {
  4381. tableOne.Rows.RemoveAt(list.Count + 1);
  4382. }
  4383. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4384. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4385. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4386. doc.Save(filePath);
  4387. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4388. return Ok(JsonView(true, "操作成功!", Url));
  4389. }
  4390. else
  4391. {
  4392. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4393. }
  4394. }
  4395. catch (Exception ex)
  4396. {
  4397. return Ok(JsonView(false, ex.Message));
  4398. throw;
  4399. }
  4400. }
  4401. #endregion
  4402. #region 团组经理模块 出入境费用
  4403. ///// <summary>
  4404. ///// 团组模块 - 出入境费用
  4405. ///// </summary>
  4406. ///// <returns></returns>
  4407. //[HttpPost]
  4408. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4409. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4410. //{
  4411. // try
  4412. // {
  4413. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4414. // if (data.Code != 0)
  4415. // {
  4416. // return Ok(JsonView(false, data.Msg));
  4417. // }
  4418. // return Ok(JsonView(true, "查询成功!"));
  4419. // }
  4420. // catch (Exception ex)
  4421. // {
  4422. // return Ok(JsonView(false, ex.Message));
  4423. // throw;
  4424. // }
  4425. //}
  4426. /// <summary>
  4427. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4428. /// </summary>
  4429. /// <returns></returns>
  4430. [HttpPost]
  4431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4432. public async Task<IActionResult> SetDayAndCostAreaChange()
  4433. {
  4434. try
  4435. {
  4436. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4437. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4438. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4439. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4440. foreach (var item in unite) //处理交集数据
  4441. {
  4442. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4443. }
  4444. foreach (var item in merge) //处理差集数据
  4445. {
  4446. int nationalTravelFeeId = 0;
  4447. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4448. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4449. else
  4450. {
  4451. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4452. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4453. }
  4454. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4455. }
  4456. //只更新dayAndCost 的 nationalTravelFeeId;
  4457. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4458. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4459. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4460. }
  4461. catch (Exception ex)
  4462. {
  4463. return Ok(JsonView(false, ex.Message));
  4464. throw;
  4465. }
  4466. }
  4467. /// <summary>
  4468. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4469. /// </summary>
  4470. /// <returns></returns>
  4471. [HttpPost]
  4472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4473. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4474. {
  4475. try
  4476. {
  4477. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4478. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4479. //SetDataInfoView
  4480. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4481. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4482. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4483. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4484. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4485. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4486. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4487. //默认币种显示
  4488. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4489. {
  4490. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4491. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4492. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4493. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4494. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4495. };
  4496. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4497. if (_currencyRate.Count > 0)
  4498. {
  4499. foreach (var item in _currencyInfos)
  4500. {
  4501. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4502. if (rateInfo != null)
  4503. {
  4504. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4505. rate1 *= 1.035M;
  4506. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4507. }
  4508. }
  4509. }
  4510. return Ok(JsonView(true, "查询成功!", new
  4511. {
  4512. GroupNameData = groupNameData.Data,
  4513. CurrencyData = _CurrencyData,
  4514. WordTypeData = _WordTypeData,
  4515. ExcelTypeData = _ExcelTypeData,
  4516. CurrencyInit = _currencyInfos
  4517. }));
  4518. }
  4519. catch (Exception ex)
  4520. {
  4521. return Ok(JsonView(false, ex.Message));
  4522. throw;
  4523. }
  4524. }
  4525. /// <summary>
  4526. /// 团组模块 - 出入境费用
  4527. /// 实时汇率 tips
  4528. /// 签证费用 tips
  4529. /// 机票费用 tips
  4530. /// </summary>
  4531. /// <returns></returns>
  4532. [HttpPost]
  4533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4534. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4535. {
  4536. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4537. //默认币种显示
  4538. var _currencyInfos = _currencyInit;
  4539. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4540. List<dynamic> reteInfos = new List<dynamic>();
  4541. if (_currencyRate.Count > 0)
  4542. {
  4543. foreach (var item in _currencyInfos)
  4544. {
  4545. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4546. if (rateInfo != null)
  4547. {
  4548. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4549. decimal rate1 = item.Rate;
  4550. rate1 *= 1.03M;
  4551. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4552. reteInfos.Add(new
  4553. {
  4554. currCode = item.CurrencyCode,
  4555. currName = item.CurrencyName,
  4556. rate = rate2,
  4557. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4558. });
  4559. }
  4560. }
  4561. }
  4562. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4563. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4564. return Ok(JsonView(true, "查询成功!", new
  4565. {
  4566. //GroupNameData = groupNameData.Data,
  4567. visaData = visaData.Data,
  4568. airData = airData.Data,
  4569. reteInfos = reteInfos
  4570. }));
  4571. }
  4572. /// <summary>
  4573. /// 团组模块 - 出入境费用 - Info
  4574. /// </summary>
  4575. /// <returns></returns>
  4576. [HttpPost]
  4577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4578. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4579. {
  4580. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4581. }
  4582. /// <summary>
  4583. /// 团组模块 - 出入境费用 - Add And Update
  4584. /// </summary>
  4585. /// <returns></returns>
  4586. [HttpPost]
  4587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4588. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4589. {
  4590. try
  4591. {
  4592. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4593. if (dto.DayOtherPriceData.Any())
  4594. {
  4595. var inserList = dto.DayOtherPriceData
  4596. .Where(x => x.Id == 0)
  4597. .Select(x => new Grp_DayOtherPrice
  4598. {
  4599. Cost = x.Cost,
  4600. Id = x.Id,
  4601. CreateTime = DateTime.Now,
  4602. CreateUserId = dto.UserId,
  4603. Currency = x.Currency,
  4604. Diid = x.DiId,
  4605. Index = x.Index,
  4606. IsDel = 0,
  4607. SetDataId = x.SetDataId,
  4608. SubTotal = x.SubTotal,
  4609. Remark = x.Remark
  4610. })
  4611. .ToList();
  4612. var updateList = dto.DayOtherPriceData
  4613. .Where(x => x.Id != 0)
  4614. .Select(x => new Grp_DayOtherPrice
  4615. {
  4616. Cost = x.Cost,
  4617. Id = x.Id,
  4618. CreateTime = DateTime.Now,
  4619. CreateUserId = dto.UserId,
  4620. Currency = x.Currency,
  4621. Diid = x.DiId,
  4622. Index = x.Index,
  4623. IsDel = 0,
  4624. SetDataId = x.SetDataId,
  4625. SubTotal = x.SubTotal,
  4626. Remark = x.Remark
  4627. })
  4628. .ToList();
  4629. //添加
  4630. _sqlSugar.BeginTran();
  4631. if (inserList.Any())
  4632. {
  4633. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4634. }
  4635. if (updateList.Any())
  4636. {
  4637. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4638. }
  4639. _sqlSugar.CommitTran();
  4640. }
  4641. if (data.Code != 0)
  4642. {
  4643. return Ok(JsonView(false, data.Msg));
  4644. }
  4645. //生成默认文件pdf并且通知人员
  4646. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4647. {
  4648. DiId = dto.DiId,
  4649. ExportType = 1,
  4650. SubTypeId = 1005
  4651. }, "pdf");
  4652. //发送通知
  4653. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4654. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4655. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4656. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4657. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4658. //汇率信息记录
  4659. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4660. return Ok(JsonView(true, data.Msg, data.Data));
  4661. }
  4662. catch (Exception ex)
  4663. {
  4664. return Ok(JsonView(false, ex.Message));
  4665. }
  4666. }
  4667. /// <summary>
  4668. /// 团组模块 - 出入境费用 - Confirm 费用
  4669. /// </summary>
  4670. /// <returns></returns>
  4671. [HttpPost]
  4672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4673. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4674. {
  4675. //TODO:测试完毕需把对应的用户ID更改
  4676. //1、数据表添加字段
  4677. //2、更改字段接口()
  4678. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4679. //3、确认成功 给财务发送消息
  4680. if (_view.Code == 200)
  4681. {
  4682. if (dto.Type == 1)
  4683. {
  4684. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4685. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4686. }
  4687. }
  4688. return Ok(_view);
  4689. }
  4690. /// <summary>
  4691. /// 团组模块 - 出入境费用 - File downlaod
  4692. /// </summary>
  4693. /// <param name="dto"></param>
  4694. /// <returns></returns>
  4695. [HttpPost]
  4696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4697. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4698. {
  4699. try
  4700. {
  4701. if (dto.DiId < 1)
  4702. {
  4703. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4704. }
  4705. if (dto.ExportType < 1)
  4706. {
  4707. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4708. }
  4709. if (dto.SubTypeId < 1)
  4710. {
  4711. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4712. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4713. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4714. 3 团组成员名单 1 团组成员名单", ""));
  4715. }
  4716. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4717. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4718. if (_EnterExitCosts == null)
  4719. {
  4720. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4721. }
  4722. //数据源
  4723. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4724. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4725. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4726. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4727. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4728. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4729. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4730. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4731. .Select((x, a, b) => new
  4732. {
  4733. x.Index,
  4734. itemName = a.Name,
  4735. CurrencyStr = b.Name,
  4736. x.Cost,
  4737. x.SubTotal,
  4738. x.Remark
  4739. })
  4740. .OrderBy((x) => x.Index)
  4741. .ToList(); //其他款项费用
  4742. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4743. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4744. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4745. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4746. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4747. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4748. .Select((tcl, dc, cc) => new
  4749. {
  4750. Name = dc.LastName + dc.FirstName,
  4751. Sex = dc.Sex,
  4752. Birthday = dc.BirthDay,
  4753. Company = cc.CompanyFullName,
  4754. Job = dc.Job
  4755. })
  4756. .ToList();
  4757. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4758. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4759. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4760. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4761. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4762. if (dto.ExportType == 1) //明细表
  4763. {
  4764. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4765. {
  4766. //获取模板
  4767. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4768. //载入模板
  4769. Document doc = new Document(tempPath);
  4770. DocumentBuilder builder = new DocumentBuilder(doc);
  4771. //利用键值对存放数据
  4772. Dictionary<string, string> dic = new Dictionary<string, string>();
  4773. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4774. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4775. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4776. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4777. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4778. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4779. //境内费用(其他费用)
  4780. if (_EnterExitCosts.ChoiceOne == 1)
  4781. {
  4782. string row1_1 = "";
  4783. if (_EnterExitCosts.Visa > 0)
  4784. {
  4785. //insidePayTotal += _EnterExitCosts.Visa;
  4786. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4787. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4788. {
  4789. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4790. }
  4791. }
  4792. string row1_2 = "";
  4793. if (_EnterExitCosts.YiMiao > 0)
  4794. {
  4795. //insidePayTotal += _EnterExitCosts.YiMiao;
  4796. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4797. }
  4798. if (_EnterExitCosts.HeSuan > 0)
  4799. {
  4800. //insidePayTotal += _EnterExitCosts.HeSuan;
  4801. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4802. }
  4803. if (_EnterExitCosts.Service > 0)
  4804. {
  4805. //insidePayTotal += _EnterExitCosts.Service;
  4806. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4807. }
  4808. string row1_3 = "";
  4809. if (_EnterExitCosts.Safe > 0)
  4810. {
  4811. //insidePayTotal += _EnterExitCosts.Safe;
  4812. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4813. }
  4814. if (_EnterExitCosts.Ticket > 0)
  4815. {
  4816. //insidePayTotal += _EnterExitCosts.Ticket;
  4817. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4818. }
  4819. string row1 = "";
  4820. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4821. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4822. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4823. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4824. dic.Add("Row1Str", row1);
  4825. }
  4826. string airTotalStr = string.Empty,
  4827. airPriceStr = string.Empty;
  4828. //经济舱
  4829. if (_EnterExitCosts.SumJJC == 1)
  4830. {
  4831. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4832. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4833. }
  4834. //公务舱
  4835. if (_EnterExitCosts.SumGWC == 1)
  4836. {
  4837. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4838. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4839. }
  4840. //头等舱
  4841. if (_EnterExitCosts.SumTDC == 1)
  4842. {
  4843. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4844. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4845. }
  4846. dic.Add("AirTotalStr", airTotalStr);
  4847. dic.Add("AirPriceStr", airPriceStr);
  4848. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4849. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4850. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4851. int table1Row = 0,
  4852. table2Row = 0,
  4853. table3Row = 0,
  4854. table4Row = 0,
  4855. table5Row = 0;
  4856. //住宿费
  4857. if (_EnterExitCosts.ChoiceThree == 1)
  4858. {
  4859. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4860. table1Row = dac1.Count;
  4861. #region 填充word表格内容
  4862. for (int i = 0; i < dac1.Count; i++)
  4863. {
  4864. Grp_DayAndCost dac = dac1[i];
  4865. if (dac == null) continue;
  4866. builder.MoveToCell(0, i, 0, 0);
  4867. builder.Write("第" + dac.Days.ToString() + "晚:");
  4868. builder.MoveToCell(0, i, 1, 0);
  4869. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4870. //builder.Write(dac.Place == null ? "" : dac.Place);
  4871. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4872. builder.MoveToCell(0, i, 2, 0);
  4873. builder.Write("费用标准:");
  4874. string curr = "";
  4875. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4876. if (currData != null)
  4877. {
  4878. curr = currData.Name;
  4879. }
  4880. builder.MoveToCell(0, i, 3, 0);
  4881. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4882. builder.MoveToCell(0, i, 4, 0);
  4883. builder.Write("费用小计:");
  4884. builder.MoveToCell(0, i, 5, 0);
  4885. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4886. }
  4887. #endregion
  4888. }
  4889. else dic.Add("SubZS", "0.00");
  4890. //删除多余行
  4891. while (table1.Rows.Count > table1Row)
  4892. {
  4893. table1.Rows.RemoveAt(table1Row);
  4894. }
  4895. //伙食费
  4896. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4897. if (_EnterExitCosts.ChoiceFour == 1)
  4898. {
  4899. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4900. table2Row = dac2.Count;
  4901. #region 填充word表格内容
  4902. for (int i = 0; i < dac2.Count; i++)
  4903. {
  4904. Grp_DayAndCost dac = dac2[i];
  4905. if (dac == null) continue;
  4906. builder.MoveToCell(1, i, 0, 0);
  4907. builder.Write("第" + dac.Days.ToString() + "天:");
  4908. builder.MoveToCell(1, i, 1, 0);
  4909. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4910. builder.MoveToCell(1, i, 2, 0);
  4911. builder.Write("费用标准:");
  4912. string curr = "";
  4913. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4914. if (currData != null)
  4915. {
  4916. curr = currData.Name;
  4917. }
  4918. builder.MoveToCell(1, i, 3, 0);
  4919. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4920. builder.MoveToCell(1, i, 4, 0);
  4921. builder.Write("费用小计:");
  4922. builder.MoveToCell(1, i, 5, 0);
  4923. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4924. }
  4925. #endregion
  4926. }
  4927. else dic.Add("SubHS", "0.00");
  4928. //删除多余行
  4929. while (table2.Rows.Count > table2Row)
  4930. {
  4931. table2.Rows.RemoveAt(table2Row);
  4932. }
  4933. //公杂费
  4934. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4935. if (_EnterExitCosts.ChoiceFive == 1)
  4936. {
  4937. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4938. table3Row = dac3.Count;
  4939. #region 填充word表格内容
  4940. for (int i = 0; i < dac3.Count; i++)
  4941. {
  4942. Grp_DayAndCost dac = dac3[i];
  4943. if (dac == null) continue;
  4944. builder.MoveToCell(2, i, 0, 0);
  4945. builder.Write("第" + dac.Days.ToString() + "天:");
  4946. builder.MoveToCell(2, i, 1, 0);
  4947. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4948. builder.MoveToCell(2, i, 2, 0);
  4949. builder.Write("费用标准:");
  4950. string curr = "";
  4951. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4952. if (currData != null)
  4953. {
  4954. curr = currData.Name;
  4955. }
  4956. builder.MoveToCell(2, i, 3, 0);
  4957. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4958. builder.MoveToCell(2, i, 4, 0);
  4959. builder.Write("费用小计:");
  4960. builder.MoveToCell(2, i, 5, 0);
  4961. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4962. }
  4963. //删除多余行
  4964. while (table3.Rows.Count > table3Row)
  4965. {
  4966. table3.Rows.RemoveAt(table3Row);
  4967. }
  4968. #endregion
  4969. }
  4970. else dic.Add("SubGZF", "0.00");
  4971. //删除多余行
  4972. while (table3.Rows.Count > table3Row)
  4973. {
  4974. table3.Rows.RemoveAt(table3Row);
  4975. }
  4976. //培训费
  4977. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4978. if (_EnterExitCosts.ChoiceSix == 1)
  4979. {
  4980. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4981. dic.Add("SubPX", pxStr);
  4982. table4Row = dac4.Count;
  4983. #region 填充word表格内容
  4984. for (int i = 0; i < dac4.Count; i++)
  4985. {
  4986. Grp_DayAndCost dac = dac4[i];
  4987. if (dac == null) continue;
  4988. builder.MoveToCell(3, i, 0, 0);
  4989. builder.Write("第" + dac.Days.ToString() + "天:");
  4990. builder.MoveToCell(3, i, 1, 0);
  4991. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4992. builder.MoveToCell(3, i, 2, 0);
  4993. builder.Write("费用标准:");
  4994. string curr = "";
  4995. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4996. if (currData != null)
  4997. {
  4998. curr = currData.Name;
  4999. }
  5000. builder.MoveToCell(3, i, 3, 0);
  5001. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5002. builder.MoveToCell(3, i, 4, 0);
  5003. builder.Write("费用小计:");
  5004. builder.MoveToCell(3, i, 5, 0);
  5005. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5006. }
  5007. #endregion
  5008. }
  5009. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5010. //删除多余行
  5011. while (table4.Rows.Count > table4Row)
  5012. {
  5013. table4.Rows.RemoveAt(table4Row);
  5014. }
  5015. //其他费用
  5016. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5017. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5018. {
  5019. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5020. dic.Add("titleQi", qtStr);
  5021. table5Row = dac5.Count;
  5022. #region 填充word表格内容
  5023. for (int i = 0; i < dac5.Count; i++)
  5024. {
  5025. var dac = dac5[i];
  5026. if (dac == null) continue;
  5027. builder.MoveToCell(4, i, 0, 0);
  5028. builder.Write("第" + dac.Index.ToString() + "项:");
  5029. builder.MoveToCell(4, i, 1, 0);
  5030. builder.Write(dac.itemName);
  5031. builder.MoveToCell(4, i, 2, 0);
  5032. builder.Write("费用标准:");
  5033. builder.MoveToCell(4, i, 3, 0);
  5034. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5035. builder.MoveToCell(4, i, 4, 0);
  5036. builder.Write("费用小计:");
  5037. builder.MoveToCell(4, i, 5, 0);
  5038. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5039. builder.MoveToCell(4, i, 6, 0);
  5040. builder.Write("备注:");
  5041. builder.MoveToCell(4, i, 7, 0);
  5042. builder.Write(dac.Remark);
  5043. }
  5044. #endregion
  5045. }
  5046. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5047. //删除多余行
  5048. while (table5.Rows.Count > table5Row)
  5049. {
  5050. table5.Rows.RemoveAt(table5Row);
  5051. }
  5052. //加上其他费用
  5053. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5054. decimal subJJC = 0.00M,
  5055. subGWC = 0.00M,
  5056. subTDC = 0.00M;
  5057. //经济舱
  5058. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5059. //公务舱
  5060. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5061. //头等舱
  5062. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5063. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5064. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5065. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5066. #region 填充word模板书签内容
  5067. foreach (var key in dic.Keys)
  5068. {
  5069. Bookmark bookmark = doc.Range.Bookmarks[key];
  5070. if (bookmark != null)
  5071. {
  5072. builder.MoveToBookmark(key);
  5073. builder.Write(dic[key]);
  5074. }
  5075. }
  5076. #endregion
  5077. //文件名
  5078. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5079. AsposeHelper.removewatermark_v2180();
  5080. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5081. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5082. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5083. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5084. }
  5085. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5086. {
  5087. //获取模板
  5088. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5089. //载入模板
  5090. Document doc = new Document(tempPath);
  5091. DocumentBuilder builder = new DocumentBuilder(doc);
  5092. Dictionary<string, string> dic = new Dictionary<string, string>();
  5093. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5094. {
  5095. List<string> list = new List<string>();
  5096. try
  5097. {
  5098. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5099. foreach (var item in spilitArr)
  5100. {
  5101. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5102. var depCode = spDotandEmpty[2].Substring(0, 3);
  5103. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5104. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5105. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5106. list.Add(depName);
  5107. list.Add(arrName);
  5108. }
  5109. list = list.Distinct().ToList();
  5110. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5111. }
  5112. catch (Exception)
  5113. {
  5114. dic.Add("ReturnCode", "行程录入不正确!");
  5115. }
  5116. }
  5117. else
  5118. {
  5119. dic.Add("ReturnCode", "未录入行程!");
  5120. }
  5121. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5122. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5123. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5124. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5125. {
  5126. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5127. dic.Add("Day", sp.Days.ToString());
  5128. }
  5129. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5130. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5131. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5132. //dic.Add("Names", Names);
  5133. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5134. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5135. decimal dac1totalPrice = 0.00M;
  5136. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5137. foreach (var dac in dac1)
  5138. {
  5139. if (dac.SubTotal == 0.00M)
  5140. {
  5141. continue;
  5142. }
  5143. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5144. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5145. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5146. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5147. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5148. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5149. builder.Write(currency);//币种
  5150. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5151. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5152. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5153. builder.Write("");//人数
  5154. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5155. builder.Write("");//天数
  5156. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5157. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5158. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5159. decimal rate = 0.00M;
  5160. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5161. builder.Write(rate.ToString("#0.0000"));//汇率
  5162. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5163. decimal rbmPrice = dac.SubTotal;
  5164. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5165. accommodationStartIndex++;
  5166. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5167. }
  5168. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5169. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5170. {
  5171. table1.Rows.RemoveAt(i - 1);
  5172. foodandotherStartIndex--;
  5173. }
  5174. if (dac2.Count == dac3.Count)//国家 币种 金额
  5175. {
  5176. for (int i = 0; i < dac2.Count; i++)
  5177. {
  5178. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5179. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5180. }
  5181. }
  5182. decimal dac2totalPrice = 0.00M;
  5183. foreach (var dac in dac2)
  5184. {
  5185. if (dac.SubTotal == 0)
  5186. {
  5187. continue;
  5188. }
  5189. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5190. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5191. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5192. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5193. builder.Write(currency);//币种
  5194. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5195. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5196. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5197. builder.Write("");//人数
  5198. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5199. builder.Write("");//天数
  5200. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5201. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5202. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5203. decimal rate = 0.00M;
  5204. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5205. builder.Write(rate.ToString("#0.0000"));//汇率
  5206. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5207. decimal rbmPrice = dac.SubTotal;
  5208. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5209. foodandotherStartIndex++;
  5210. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5211. }
  5212. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5213. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5214. {
  5215. table1.Rows.RemoveAt(i - 1);
  5216. }
  5217. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5218. string otherFeeStr = "";
  5219. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5220. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5221. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5222. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5223. foreach (var otherInfo in dac5)
  5224. {
  5225. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5226. }
  5227. #endregion
  5228. if (otherFeeStr.Length > 0)
  5229. {
  5230. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5231. otherFeeStr = $"({otherFeeStr})";
  5232. dic.Add("OtherFeeStr", otherFeeStr);
  5233. }
  5234. //总计
  5235. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5236. //国际旅费
  5237. string outsideAir = string.Empty;
  5238. string allPriceAir = string.Empty;
  5239. if (_EnterExitCosts.SumJJC == 1)
  5240. {
  5241. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5242. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5243. }
  5244. if (_EnterExitCosts.SumGWC == 1)
  5245. {
  5246. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5247. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5248. }
  5249. if (_EnterExitCosts.SumTDC == 1)
  5250. {
  5251. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5252. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5253. }
  5254. dic.Add("InTravelPrice", $"({outsideAir})");
  5255. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5256. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5257. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5258. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5259. foreach (var key in dic.Keys)
  5260. {
  5261. builder.MoveToBookmark(key);
  5262. builder.Write(dic[key]);
  5263. }
  5264. //模板文件名
  5265. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5266. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5267. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5268. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5269. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5270. }
  5271. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5272. {
  5273. //获取模板
  5274. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5275. //载入模板
  5276. WorkbookDesigner designer = new WorkbookDesigner();
  5277. designer.Workbook = new Workbook(tempPath);
  5278. Dictionary<string, string> dic = new Dictionary<string, string>();
  5279. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5280. {
  5281. List<string> list = new List<string>();
  5282. try
  5283. {
  5284. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5285. foreach (var item in spilitArr)
  5286. {
  5287. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5288. var depCode = spDotandEmpty[2].Substring(0, 3);
  5289. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5290. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5291. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5292. list.Add(depName);
  5293. list.Add(arrName);
  5294. }
  5295. list = list.Distinct().ToList();
  5296. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5297. }
  5298. catch (Exception)
  5299. {
  5300. dic.Add("ReturnCode", "行程录入不正确!");
  5301. }
  5302. }
  5303. else
  5304. {
  5305. dic.Add("ReturnCode", "未录入行程!");
  5306. }
  5307. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5308. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5309. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5310. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5311. {
  5312. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5313. dic.Add("Day", sp.Days.ToString());
  5314. }
  5315. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5316. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5317. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5318. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5319. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5320. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5321. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5322. designer.SetDataSource("Name", Names);
  5323. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5324. designer.SetDataSource("Day", dic["Day"] + "天");
  5325. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5326. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5327. int startIndex = 10;
  5328. const int startIndexcopy = 10;
  5329. if (dac2.Count == dac3.Count)//国家 币种 金额
  5330. {
  5331. for (int i = 0; i < dac2.Count; i++)
  5332. {
  5333. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5334. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5335. }
  5336. }
  5337. DataTable dtdac1 = new DataTable();
  5338. List<string> place = new List<string>();
  5339. dtdac1.Columns.AddRange(new DataColumn[] {
  5340. new DataColumn(){ ColumnName = "city"},
  5341. new DataColumn(){ ColumnName = "curr"},
  5342. new DataColumn(){ ColumnName = "criterion"},
  5343. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5344. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5345. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5346. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5347. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5348. });
  5349. DataTable dtdac2 = new DataTable();
  5350. dtdac2.Columns.AddRange(new DataColumn[] {
  5351. new DataColumn(){ ColumnName = "city"},
  5352. new DataColumn(){ ColumnName = "curr"},
  5353. new DataColumn(){ ColumnName = "criterion"},
  5354. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5355. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5356. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5357. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5358. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5359. });
  5360. dtdac1.TableName = "tb1";
  5361. dtdac2.TableName = "tb2";
  5362. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5363. foreach (var item in dac1)
  5364. {
  5365. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5366. if (place.Contains(item.Place))
  5367. {
  5368. continue;
  5369. }
  5370. DataRow row = dtdac1.NewRow();
  5371. row["city"] = item.Place;
  5372. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5373. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5374. row["curr"] = currency;
  5375. row["rate"] = rate.ToString("#0.0000");
  5376. row["criterion"] = item.Cost.ToString("#0.00");
  5377. row["number"] = 1;
  5378. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5379. //row["costRMB"] = rbmPrice;
  5380. dtdac1.Rows.Add(row);
  5381. place.Add(item.Place);
  5382. }
  5383. place = new List<string>();
  5384. foreach (var item in dac2)
  5385. {
  5386. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5387. if (place.Contains(item.Place))
  5388. {
  5389. continue;
  5390. }
  5391. DataRow row = dtdac2.NewRow();
  5392. row["city"] = item.Place;
  5393. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5394. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5395. row["curr"] = currency;
  5396. row["rate"] = rate.ToString("#0.0000");
  5397. row["criterion"] = item.Cost.ToString("#0.00");
  5398. row["number"] = 1;
  5399. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5400. //row["cost"] = item.SubTotal;
  5401. //row["costRMB"] = rbmPrice;
  5402. dtdac2.Rows.Add(row);
  5403. place.Add(item.Place);
  5404. //dac2totalPrice += rbmPrice;
  5405. }
  5406. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5407. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5408. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5409. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5410. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5411. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5412. string cell4Str1 = string.Empty;
  5413. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5414. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5415. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5416. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5417. string cellStr = $" 5.其他费用(";
  5418. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5419. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5420. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5421. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5422. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5423. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5424. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5425. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5426. foreach (var otherInfo in dac5)
  5427. {
  5428. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5429. }
  5430. #endregion
  5431. if (cellStr.Length > 8)
  5432. {
  5433. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5434. }
  5435. cellStr += ")";
  5436. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5437. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5438. decimal pxFee = dac4.Sum(it => it.Cost);
  5439. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5440. string celllastStr1 = "";
  5441. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5442. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5443. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5444. celllastStr1 += $",国际旅费 元";
  5445. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5446. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5447. designer.SetDataSource("cell4Str", cell4Str);
  5448. designer.SetDataSource("cellStr", cellStr);
  5449. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5450. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5451. designer.SetDataSource("celllastStr", celllastStr);
  5452. Workbook wb = designer.Workbook;
  5453. var sheet = wb.Worksheets[0];
  5454. //绑定datatable数据集
  5455. designer.SetDataSource(dtdac1);
  5456. designer.SetDataSource(dtdac2);
  5457. designer.Process();
  5458. var rowStart = dtdac1.Rows.Count;
  5459. while (rowStart > 0)
  5460. {
  5461. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5462. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5463. startIndex++;
  5464. rowStart--;
  5465. }
  5466. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5467. startIndex += 1; //总计行
  5468. rowStart = dtdac2.Rows.Count;
  5469. while (rowStart > 0)
  5470. {
  5471. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5472. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5473. startIndex++;
  5474. rowStart--;
  5475. }
  5476. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5477. wb.CalculateFormula(true);
  5478. //模板文件名
  5479. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5480. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5481. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5482. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5483. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5484. }
  5485. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5486. {
  5487. //获取模板
  5488. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5489. //载入模板
  5490. Document doc = new Document(tempPath);
  5491. DocumentBuilder builder = new DocumentBuilder(doc);
  5492. Dictionary<string, string> dic = new Dictionary<string, string>();
  5493. dic.Add("GroupName", _DelegationInfo.TeamName);
  5494. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5495. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5496. string missionLeaderJob = "";//负责人job
  5497. int groupNumber = 0; //团人数
  5498. if (DeleClientList.Count > 0)
  5499. {
  5500. missionLeader = DeleClientList[0]?.Name ?? "";
  5501. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5502. }
  5503. dic.Add("MissionLeader", missionLeader); //团负责人
  5504. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5505. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5506. #region MyRegion
  5507. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5508. //{
  5509. // List<string> list = new List<string>();
  5510. // try
  5511. // {
  5512. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5513. // foreach (var item in spilitArr)
  5514. // {
  5515. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5516. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5517. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5518. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5519. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5520. // list.Add(depName);
  5521. // list.Add(arrName);
  5522. // }
  5523. // list = list.Distinct().ToList();
  5524. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5525. // }
  5526. // catch (Exception)
  5527. // {
  5528. // dic.Add("ReturnCode", "行程录入不正确!");
  5529. // }
  5530. //}
  5531. //else
  5532. //{
  5533. // dic.Add("ReturnCode", "未录入行程!");
  5534. //}
  5535. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5536. dic.Add("ReturnCode", string.Join("、", countrys));
  5537. #endregion
  5538. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5539. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5540. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5541. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5542. //{
  5543. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5544. // dic.Add("Day", sp.Days.ToString());
  5545. //}
  5546. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5547. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5548. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5549. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5550. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5551. //培训人员名单
  5552. int cultivateRowIndex = 7;
  5553. foreach (var item in DeleClientList)
  5554. {
  5555. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5556. builder.Write(item.Name);
  5557. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5558. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5559. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5560. string birthDay = "";
  5561. if (item.Birthday != null)
  5562. {
  5563. DateTime dt = Convert.ToDateTime(item.Birthday);
  5564. birthDay = $"{dt.Year}.{dt.Month}";
  5565. }
  5566. builder.Write(birthDay);
  5567. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5568. builder.Write(item.Company);
  5569. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5570. builder.Write(item.Job);
  5571. cultivateRowIndex++;
  5572. }
  5573. //删除多余行
  5574. //cultivateRowIndex -= 2;
  5575. int delRows = 10 + 7 - cultivateRowIndex;
  5576. if (delRows > 0)
  5577. {
  5578. for (int i = 0; i < delRows; i++)
  5579. {
  5580. table1.Rows.RemoveAt(cultivateRowIndex);
  5581. //cultivateRowIndex++;
  5582. }
  5583. }
  5584. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5585. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5586. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5587. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5588. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5589. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5590. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5591. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5592. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5593. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5594. //其他费用
  5595. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5596. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5597. //其他费用合计
  5598. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5599. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5600. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5601. //公务舱合计
  5602. //国际旅费
  5603. string outsideJJ = "";
  5604. string allPriceJJ = "";
  5605. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5606. {
  5607. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5608. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5609. }
  5610. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5611. {
  5612. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5613. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5614. }
  5615. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5616. {
  5617. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5618. dic.Add("AirFeeTotal", airFeeTotalStr);
  5619. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5620. dic.Add("FeeTotal", feeTotalStr);
  5621. }
  5622. foreach (var key in dic.Keys)
  5623. {
  5624. builder.MoveToBookmark(key);
  5625. builder.Write(dic[key]);
  5626. }
  5627. //模板文件名
  5628. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5629. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5630. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5631. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5632. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5633. }
  5634. }
  5635. else if (dto.ExportType == 2) //表格
  5636. {
  5637. //利用键值对存放数据
  5638. Dictionary<string, string> dic = new Dictionary<string, string>();
  5639. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5640. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5641. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5642. dic.Add("Day", sp.Days.ToString());
  5643. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5644. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5645. {
  5646. //获取模板
  5647. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5648. //载入模板
  5649. Document doc = new Document(tempPath);
  5650. DocumentBuilder builder = new DocumentBuilder(doc);
  5651. dic.Add("TeamName", _DelegationInfo.TeamName);
  5652. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5653. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5654. string missionLeaderName = "",
  5655. missionLeaderJob = "";
  5656. if (DeleClientList.Count > 0)
  5657. {
  5658. missionLeaderName = DeleClientList[0].Name;
  5659. missionLeaderJob = DeleClientList[0].Job;
  5660. }
  5661. dic.Add("MissionLeaderName", missionLeaderName);
  5662. dic.Add("MissionLeaderJob", missionLeaderJob);
  5663. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5664. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5665. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5666. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5667. int rowCount = 10;//总人数行
  5668. int startRowIndex = 7; //起始行
  5669. for (int i = 0; i < DeleClientList.Count; i++)
  5670. {
  5671. builder.MoveToCell(0, startRowIndex, 0, 0);
  5672. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5673. builder.MoveToCell(0, startRowIndex, 1, 0);
  5674. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5675. builder.Write(sex);//性别
  5676. builder.MoveToCell(0, startRowIndex, 2, 0);
  5677. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5678. builder.MoveToCell(0, startRowIndex, 3, 0);
  5679. builder.Write(DeleClientList[i].Company);//工作单位
  5680. builder.MoveToCell(0, startRowIndex, 4, 0);
  5681. builder.Write(DeleClientList[i].Job);//职务及级别
  5682. builder.MoveToCell(0, startRowIndex, 5, 0);
  5683. builder.Write("");//人员属性
  5684. builder.MoveToCell(0, startRowIndex, 6, 0);
  5685. builder.Write("");//上次出国时间
  5686. startRowIndex++;
  5687. }
  5688. int nullRow = rowCount - DeleClientList.Count;//空行
  5689. for (int i = 0; i < nullRow; i++)
  5690. {
  5691. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5692. }
  5693. foreach (var key in dic.Keys)
  5694. {
  5695. builder.MoveToBookmark(key);
  5696. builder.Write(dic[key]);
  5697. }
  5698. //模板文件名
  5699. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5700. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5701. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5702. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5703. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5704. }
  5705. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5706. {
  5707. //获取模板
  5708. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5709. //载入模板
  5710. Document doc = new Document(tempPath);
  5711. DocumentBuilder builder = new DocumentBuilder(doc);
  5712. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5713. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5714. dic.Add("Names", Names);
  5715. int accommodationRows = 12, foodandotherRows = 12;
  5716. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5717. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5718. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5719. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5720. int accommodationStartIndex = 6;
  5721. decimal dac1totalPrice = 0.00M;
  5722. foreach (var dac in dac1)
  5723. {
  5724. if (dac.SubTotal == 0)
  5725. {
  5726. continue;
  5727. }
  5728. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5729. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5730. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5731. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5732. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5733. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5734. builder.Write(currency);//币种
  5735. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5736. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5737. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5738. builder.Write("");//人数
  5739. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5740. builder.Write("");//天数
  5741. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5742. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5743. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5744. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5745. builder.Write(rate.ToString("#0.0000"));//汇率
  5746. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5747. decimal rbmPrice = rate * dac.SubTotal;
  5748. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5749. accommodationStartIndex++;
  5750. dac1totalPrice += rbmPrice;
  5751. }
  5752. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5753. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5754. builder.Write("小计");
  5755. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5756. builder.Write(dac1totalPrice.ToString("#0.00"));
  5757. accommodationStartIndex++;
  5758. int nullRow = accommodationRows - dac1.Count;
  5759. //删除空行
  5760. //if (nullRow > 0)
  5761. //{
  5762. // int rowIndex = accommodationStartIndex;
  5763. // for (int i = 0; i < nullRow; i++)
  5764. // {
  5765. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5766. // row.Remove();
  5767. // rowIndex++;
  5768. // }
  5769. //}
  5770. if (dac2.Count == dac3.Count)//国家 币种 金额
  5771. {
  5772. for (int i = 0; i < dac2.Count; i++)
  5773. {
  5774. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5775. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5776. }
  5777. }
  5778. int foodandotherStartIndex = 19;//
  5779. decimal dac2totalPrice = 0.00M;
  5780. foreach (var dac in dac2)
  5781. {
  5782. if (dac.SubTotal == 0)
  5783. {
  5784. continue;
  5785. }
  5786. //foodandotherStartIndex = 12;
  5787. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5788. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5789. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5790. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5791. builder.Write(currency);//币种
  5792. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5793. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5794. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5795. builder.Write("");//人数
  5796. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5797. builder.Write("");//天数
  5798. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5799. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5800. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5801. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5802. builder.Write(rate.ToString("#0.0000"));//汇率
  5803. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5804. decimal rbmPrice = rate * dac.SubTotal;
  5805. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5806. foodandotherStartIndex++;
  5807. dac2totalPrice += rbmPrice;
  5808. }
  5809. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5810. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5811. //删除空行
  5812. //if (dac2.Count < foodandotherRows)
  5813. //{
  5814. // while (table2.Rows.Count > dac2.Count)
  5815. // {
  5816. // table2.Rows.RemoveAt(dac2.Count);
  5817. // }
  5818. //}
  5819. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5820. string otherFeeStr = "";
  5821. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5822. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5823. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5824. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5825. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5826. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5827. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5828. foreach (var otherInfo in dac5)
  5829. {
  5830. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5831. }
  5832. #endregion
  5833. if (otherFeeStr.Length > 0)
  5834. {
  5835. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5836. otherFeeStr = $"({otherFeeStr})";
  5837. dic.Add("OtherFeeStr", otherFeeStr);
  5838. }
  5839. foreach (var key in dic.Keys)
  5840. {
  5841. builder.MoveToBookmark(key);
  5842. builder.Write(dic[key]);
  5843. }
  5844. //模板文件名
  5845. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5846. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5847. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5848. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5849. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5850. }
  5851. }
  5852. else if (dto.ExportType == 3)
  5853. {
  5854. if (dto.SubTypeId == 1) //团组成员名单
  5855. {
  5856. if (DeleClientList.Count < 1)
  5857. {
  5858. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5859. }
  5860. //获取模板
  5861. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5862. //载入模板
  5863. Document doc = new Document(tempPath);
  5864. DocumentBuilder builder = new DocumentBuilder(doc);
  5865. //获取word里所有表格
  5866. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5867. //获取所填表格的序数
  5868. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5869. var rowStart = tableOne.Rows[0]; //获取第1行
  5870. //循环赋值
  5871. for (int i = 0; i < DeleClientList.Count; i++)
  5872. {
  5873. builder.MoveToCell(0, i + 1, 0, 0);
  5874. builder.Write(DeleClientList[i].Name);
  5875. builder.MoveToCell(0, i + 1, 1, 0);
  5876. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5877. builder.Write(sex);
  5878. builder.MoveToCell(0, i + 1, 2, 0);
  5879. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5880. builder.MoveToCell(0, i + 1, 3, 0);
  5881. builder.Write(DeleClientList[i].Company);
  5882. builder.MoveToCell(0, i + 1, 4, 0);
  5883. builder.Write(DeleClientList[i].Job);
  5884. }
  5885. //删除多余行
  5886. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5887. {
  5888. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5889. }
  5890. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5891. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5892. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5893. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5894. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5895. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5896. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5897. }
  5898. }
  5899. return Ok(JsonView(400, "操作失败!", ""));
  5900. }
  5901. catch (Exception ex)
  5902. {
  5903. return Ok(JsonView(400, ex.Message, ""));
  5904. }
  5905. }
  5906. /// <summary>
  5907. /// 获取三公费用标准city
  5908. /// </summary>
  5909. /// <param name="placeData"></param>
  5910. /// <param name="nationalTravelFeeId"></param>
  5911. /// <returns></returns>
  5912. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5913. {
  5914. string _city = string.Empty;
  5915. if (placeData.Count < 1) return _city;
  5916. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5917. if (data == null) return _city;
  5918. string country = data.Country;
  5919. string city = data.City;
  5920. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5921. else _city = city;
  5922. return _city;
  5923. }
  5924. /// <summary>
  5925. /// 团组模块 - 出入境费用 - 明细表导出
  5926. /// </summary>
  5927. /// <returns></returns>
  5928. [HttpPost]
  5929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5930. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5931. {
  5932. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5933. if (data.Code != 0)
  5934. {
  5935. return Ok(JsonView(false, data.Msg));
  5936. }
  5937. return Ok(JsonView(true, data.Msg, data.Data));
  5938. }
  5939. /// <summary>
  5940. /// 团组模块 - 出入境费用 - 一键清空
  5941. /// </summary>
  5942. /// <returns></returns>
  5943. [HttpPost]
  5944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5945. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5946. {
  5947. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5948. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5949. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5950. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5951. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5952. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5953. .SetColumns(x => new Grp_DayOtherPrice
  5954. {
  5955. IsDel = 1,
  5956. DeleteUserId = dto.UserId,
  5957. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5958. })
  5959. .ExecuteCommandAsync();
  5960. if (_view.Code == 0)
  5961. {
  5962. return Ok(JsonView(true, "操作成功"));
  5963. }
  5964. return Ok(JsonView(false, "操作失败"));
  5965. }
  5966. /// <summary>
  5967. /// 团组模块 - 出入境费用 - 子项删除
  5968. /// </summary>
  5969. /// <returns></returns>
  5970. [HttpPost]
  5971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5972. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5973. {
  5974. try
  5975. {
  5976. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5977. if (data.Code != 0)
  5978. {
  5979. return Ok(JsonView(false, data.Msg));
  5980. }
  5981. return Ok(JsonView(true, "操作成功!", data.Data));
  5982. }
  5983. catch (Exception ex)
  5984. {
  5985. return Ok(JsonView(false, ex.Message));
  5986. }
  5987. }
  5988. /// <summary>
  5989. /// 删除三公其他费用
  5990. /// </summary>
  5991. /// <param name="dto"></param>
  5992. /// <returns></returns>
  5993. [HttpPost]
  5994. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5995. {
  5996. var jw = JsonView(false,"删除失败!");
  5997. var data = new Grp_DayOtherPrice()
  5998. {
  5999. Id = dto.Id,
  6000. IsDel = 1,
  6001. DeleteUserId = dto.DeleteUserId,
  6002. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6003. };
  6004. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6005. if (del > 0)
  6006. {
  6007. jw.Code = 200;
  6008. jw.Msg = "删除成功!";
  6009. }
  6010. return Ok(jw);
  6011. }
  6012. /// <summary>
  6013. /// 团组模块 - 出入境国家费用标准 List
  6014. /// </summary>
  6015. /// <returns></returns>
  6016. [HttpPost]
  6017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6018. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6019. {
  6020. try
  6021. {
  6022. Stopwatch sw = new Stopwatch();
  6023. sw.Start();
  6024. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6025. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6026. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6027. Where gntf.Isdel = 0");
  6028. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6029. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6030. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6031. //foreach (var item in nationalTravel)
  6032. //{
  6033. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6034. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6035. // if (otherData != null)
  6036. // {
  6037. // cityData.Remove(otherData);
  6038. // cityData.Add(otherData);
  6039. // }
  6040. // nationalTravelFeeData1.Add(new
  6041. // {
  6042. // Country = item.Country,
  6043. // CityData = cityData
  6044. // });
  6045. //}
  6046. sw.Stop();
  6047. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6048. }
  6049. catch (Exception ex)
  6050. {
  6051. return Ok(JsonView(false, ex.Message));
  6052. throw;
  6053. }
  6054. }
  6055. /// <summary>
  6056. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6057. /// </summary>
  6058. /// <returns></returns>
  6059. [HttpPost]
  6060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6061. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6062. {
  6063. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6064. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6065. List<string> countryData = new List<string>();
  6066. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6067. countryData = countryData.Distinct().ToList();
  6068. List<dynamic> dataSource = new List<dynamic>();
  6069. foreach (var item in countryData)
  6070. {
  6071. List<string> cityData1 = new List<string>();
  6072. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6073. var countryData2 = new
  6074. {
  6075. CountryName = item,
  6076. CityData = cityData1
  6077. };
  6078. dataSource.Add(countryData2);
  6079. }
  6080. return Ok(JsonView(true, "查询成功!", dataSource));
  6081. }
  6082. /// <summary>
  6083. /// 团组模块 - 出入境国家费用标准 Page List
  6084. /// </summary>
  6085. /// <returns></returns>
  6086. [HttpPost]
  6087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6088. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6089. {
  6090. int portId = dto.PortType;
  6091. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6092. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6093. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6094. string whereSql = string.Empty;
  6095. if (!string.IsNullOrEmpty(dto.Country))
  6096. {
  6097. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6098. }
  6099. if (!string.IsNullOrEmpty(dto.City))
  6100. {
  6101. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6102. }
  6103. string pageSql = string.Format(@"Select * From (
  6104. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6105. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6106. From Grp_NationalTravelFee gntf
  6107. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6108. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6109. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6110. RefAsync<int> total = 0;
  6111. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6112. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6113. }
  6114. /// <summary>
  6115. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6116. /// </summary>
  6117. /// <returns></returns>
  6118. [HttpPost]
  6119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6120. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6121. {
  6122. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6123. int portId = dto.PortType;
  6124. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6125. string whereSql = string.Empty;
  6126. if (!string.IsNullOrEmpty(dto.Country))
  6127. {
  6128. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6129. }
  6130. if (!string.IsNullOrEmpty(dto.City))
  6131. {
  6132. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6133. }
  6134. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6135. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6136. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6137. From Grp_NationalTravelFee gntf
  6138. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6139. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6140. Where gntf.Isdel = 0 {0} ", whereSql);
  6141. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6142. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6143. }
  6144. /// <summary>
  6145. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6146. /// </summary>
  6147. /// <returns></returns>
  6148. [HttpPost]
  6149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6150. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6151. {
  6152. try
  6153. {
  6154. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6155. if (data.Code != 0)
  6156. {
  6157. return Ok(JsonView(false, data.Msg));
  6158. }
  6159. return Ok(JsonView(true, "操作成功!", data.Data));
  6160. }
  6161. catch (Exception ex)
  6162. {
  6163. return Ok(JsonView(false, ex.Message));
  6164. }
  6165. }
  6166. /// <summary>
  6167. /// 团组模块 - 出入境国家费用标准 - Del
  6168. /// </summary>
  6169. /// <returns></returns>
  6170. [HttpPost]
  6171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6172. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6173. {
  6174. try
  6175. {
  6176. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6177. {
  6178. Id = dto.Id,
  6179. DeleteUserId = dto.DeleteUserId,
  6180. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6181. IsDel = 1
  6182. };
  6183. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6184. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6185. .WhereColumns(it => new { it.Id })
  6186. .ExecuteCommandAsync();
  6187. if (delStatus <= 0)
  6188. {
  6189. return Ok(JsonView(false, "删除失败!"));
  6190. }
  6191. return Ok(JsonView(true, "操作成功!"));
  6192. }
  6193. catch (Exception ex)
  6194. {
  6195. return Ok(JsonView(false, ex.Message));
  6196. }
  6197. }
  6198. /// <summary>
  6199. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6200. /// 注:Get 请求Headers 加 Token
  6201. /// </summary>
  6202. /// <param name="groupId"></param>
  6203. /// <returns></returns>
  6204. [HttpGet("{groupId}")]
  6205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6206. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6207. {
  6208. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6209. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6210. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6211. data.ForEach(x =>
  6212. {
  6213. x.CreateUserId = _currUserInfo.UserId;
  6214. });
  6215. if (data.Count > 0)
  6216. {
  6217. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6218. if (add > 0)
  6219. {
  6220. return Ok(JsonView(true, "操作成功!"));
  6221. }
  6222. }
  6223. return Ok(JsonView(false, "未操作!"));
  6224. }
  6225. #endregion
  6226. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6227. /// <summary>
  6228. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6229. /// </summary>
  6230. /// <returns></returns>
  6231. [HttpPost]
  6232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6233. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6234. {
  6235. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6236. //SetDataInfoView
  6237. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6238. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6239. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6240. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6241. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6242. //默认币种显示
  6243. var _currencyInfos = _currencyInit;
  6244. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6245. if (_currencyRate.Count > 0)
  6246. {
  6247. foreach (var item in _currencyInfos)
  6248. {
  6249. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6250. if (rateInfo != null)
  6251. {
  6252. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6253. rate1 *= 1.035M;
  6254. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6255. }
  6256. }
  6257. }
  6258. return Ok(JsonView(true, "查询成功!", new
  6259. {
  6260. WordTypeData = _WordTypeData,
  6261. ExcelTypeData = _ExcelTypeData,
  6262. CurrencyInit = _currencyInfos
  6263. }));
  6264. }
  6265. /// <summary>
  6266. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6267. /// </summary>
  6268. /// <returns></returns>
  6269. [HttpPost]
  6270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6271. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6272. {
  6273. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6274. RefAsync<int> total = 0;
  6275. int diId = 0;
  6276. var status = int.TryParse(dto.GroupName, out diId);
  6277. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6278. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6279. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6280. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6281. .Select(x => new
  6282. {
  6283. Id = x.Id,
  6284. GroupName = x.TeamName
  6285. })
  6286. .OrderByDescending(x => x.Id)
  6287. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6288. return Ok(JsonView(true, "查询成功!", data, total));
  6289. }
  6290. /// <summary>
  6291. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6292. /// </summary>
  6293. /// <returns></returns>
  6294. [HttpPost]
  6295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6296. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6297. {
  6298. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6299. RefAsync<int> total = 0;
  6300. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6301. .Where(x => x.IsDel == 0 && x.STid == 66)
  6302. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6303. .Select(x => new
  6304. {
  6305. id = x.Id,
  6306. name = x.Name,
  6307. remark = x.Remark,
  6308. })
  6309. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6310. return Ok(JsonView(true, "查询成功!", data, total));
  6311. }
  6312. /// <summary>
  6313. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种基础数据Data
  6314. /// </summary>
  6315. /// <returns></returns>
  6316. [HttpPost]
  6317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6318. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6319. {
  6320. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6321. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6322. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6323. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6324. var groupOtherRateData = groupRateData.TeamRates;
  6325. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6326. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6327. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6328. groupOtherRateData = groupOtherRateData
  6329. .Select(x => new TeamRateDescAddCurrencyIdView {
  6330. CurrencyId = x.CurrencyId,
  6331. CurrencyName = x.CurrencyName,
  6332. CurrencyCode = x.CurrencyCode,
  6333. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6334. }).ToList();
  6335. return Ok(JsonView(true, "查询成功!", groupOtherRateData));
  6336. }
  6337. /// <summary>
  6338. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6339. /// </summary>
  6340. /// <returns></returns>
  6341. [HttpPost]
  6342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6343. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6344. {
  6345. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6346. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6347. var tipsData = new List<int>() {1,2,3 };
  6348. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6349. if (dto.TipsType == 1)
  6350. {
  6351. //默认币种显示
  6352. var _currencyInfos = _currencyInit;
  6353. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6354. List<dynamic> reteInfos = new List<dynamic>();
  6355. if (_currencyRate.Count > 0)
  6356. {
  6357. foreach (var item in _currencyInfos)
  6358. {
  6359. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6360. if (rateInfo != null)
  6361. {
  6362. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6363. decimal rate1 = item.Rate;
  6364. rate1 *= 1.03M;
  6365. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6366. reteInfos.Add(new
  6367. {
  6368. currCode = item.CurrencyCode,
  6369. currName = item.CurrencyName,
  6370. rate = rate2,
  6371. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6372. });
  6373. }
  6374. }
  6375. }
  6376. return Ok(JsonView(true, "查询成功!", reteInfos));
  6377. }
  6378. else if (dto.TipsType == 2)
  6379. {
  6380. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6381. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6382. }
  6383. else if (dto.TipsType == 3)
  6384. {
  6385. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6386. return Ok(JsonView(true, "查询成功!", airData.Data));
  6387. }
  6388. return Ok(JsonView(false));
  6389. }
  6390. /// <summary>
  6391. /// 团组模块 - 出入境国家费用标准-移动端 List
  6392. /// </summary>
  6393. /// <returns></returns>
  6394. [HttpPost]
  6395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6396. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6397. {
  6398. Stopwatch sw = new Stopwatch();
  6399. sw.Start();
  6400. RefAsync<int> total = 0;
  6401. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6402. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6403. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6404. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6405. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6406. .Select((ntf, sd, u) => new
  6407. {
  6408. Id = ntf.Id,
  6409. Area = $"{ntf.Country}-{ntf.City}",
  6410. Currency = ntf.Currency,
  6411. CurrencyCode = sd.Name,
  6412. CurrencyName = sd.Remark,
  6413. RoomCost = ntf.RoomCost,
  6414. FoodCost = ntf.FoodCost,
  6415. PublicCost = ntf.PublicCost,
  6416. LastUpdateUserId = ntf.LastUpdateUserId,
  6417. LastUpdateUserName = u.CnName,
  6418. LastUpdateTime = ntf.LastUpdateTime,
  6419. })
  6420. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6421. sw.Stop();
  6422. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6423. }
  6424. /// <summary>
  6425. /// 团组模块 - 出入境费用-移动端 - Info
  6426. /// </summary>
  6427. /// <returns></returns>
  6428. [HttpPost]
  6429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6430. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6431. {
  6432. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6433. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6434. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6435. return Ok(data);
  6436. }
  6437. /// <summary>
  6438. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6439. /// </summary>
  6440. /// <returns></returns>
  6441. [HttpPost]
  6442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6443. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6444. {
  6445. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6446. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6447. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6448. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6449. if (eecInfo == null) return Ok(mobileInfo);
  6450. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6451. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6452. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6453. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6454. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6455. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6456. {
  6457. SubId = dac.Id,
  6458. DiId = dac.DiId,
  6459. Type = dac.Type,
  6460. Days = dac.Days,
  6461. NationalTravelFeeId = dac.NationalTravelFeeId,
  6462. Arae = $"{ntf.Country}-{ntf.City}",
  6463. Cost = dac.Cost,
  6464. Currency = dac.Currency,
  6465. CurrencyName = sd.Name,
  6466. SubTotal = dac.SubTotal,
  6467. })
  6468. .ToList();
  6469. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6470. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6471. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6472. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6473. mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  6474. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6475. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6476. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6477. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6478. //其他款项
  6479. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6480. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6481. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6482. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6483. .OrderBy((dop, sd1, sd2) => dop.Index)
  6484. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6485. {
  6486. SubId = dop.Id,
  6487. DiId = dop.Diid,
  6488. Index = dop.Index,
  6489. SetDataId = dop.SetDataId,
  6490. SetDataName = sd1.Name,
  6491. Cost = dop.Cost,
  6492. Currency = dop.Currency,
  6493. CurrencyName = sd2.Remark,
  6494. SubTotal = dop.SubTotal,
  6495. Remark = dop.Remark,
  6496. })
  6497. .ToArray();
  6498. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6499. return Ok(mobileInfo);
  6500. }
  6501. /// <summary>
  6502. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6503. /// </summary>
  6504. /// <returns></returns>
  6505. [HttpPost]
  6506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6507. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6508. {
  6509. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6510. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6511. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6512. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6513. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6514. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6515. var subType = dto.SubType;
  6516. if (subType == 1) //1:境内费用
  6517. {
  6518. var oneData = new ChoiceOneMobileSubInfoView()
  6519. {
  6520. Id = eecInfo.Id,
  6521. ChoiceOne = eecInfo.ChoiceOne,
  6522. ChoiceOneTotalCost = eecInfo.InsidePay,
  6523. Visa = eecInfo.Visa,
  6524. VisaRemark = eecInfo.VisaRemark,
  6525. YiMiao = eecInfo.YiMiao,
  6526. HeSuan = eecInfo.HeSuan,
  6527. Service = eecInfo.Service,
  6528. Ticket = eecInfo.Ticket,
  6529. Safe = eecInfo.Safe,
  6530. };
  6531. return Ok(JsonView(oneData));
  6532. }
  6533. else if (subType == 2) //2:国际旅费
  6534. {
  6535. var twoData = new ChoiceTwoMobileSubInfoView() {
  6536. Id = eecInfo.Id,
  6537. ChoiceTwoJJ = eecInfo.SumJJC,
  6538. OutsideJJPay = eecInfo.OutsideJJPay,
  6539. ChoiceTwoGW = eecInfo.SumGWC,
  6540. OutsideGWPay = eecInfo.OutsideGWPay,
  6541. ChoiceTwoTD = eecInfo.SumTDC,
  6542. OutsideTDPay = eecInfo.OutsideTDPay,
  6543. AirJJ = eecInfo.AirJJ,
  6544. AirGW = eecInfo.AirGW,
  6545. AirTD = eecInfo.AirTD,
  6546. CityTranffic = eecInfo.CityTranffic
  6547. };
  6548. return Ok(JsonView(twoData));
  6549. }
  6550. else if (subType == 3) //3:住宿费
  6551. {
  6552. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6553. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6554. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6555. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6556. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6557. {
  6558. SubId = dac.Id,
  6559. DiId = dac.DiId,
  6560. Type = dac.Type,
  6561. Days = dac.Days,
  6562. NationalTravelFeeId = dac.NationalTravelFeeId,
  6563. Arae = $"{ntf.Country}-{ntf.City}",
  6564. Cost = dac.Cost,
  6565. Currency = dac.Currency,
  6566. CurrencyName = sd.Name,
  6567. SubTotal = dac.SubTotal,
  6568. })
  6569. .ToArray();
  6570. var data = new ChoiceThreeMobileSubInfoView() {
  6571. ParentId = eecInfo.Id,
  6572. ChoiceThree = eecInfo.ChoiceThree,
  6573. ChoiceThreeTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6574. Details = dayAndCostDatas
  6575. };
  6576. return Ok(JsonView(data));
  6577. }
  6578. else if (subType == 4) //4:伙食费
  6579. {
  6580. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6581. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6582. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6583. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6584. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6585. {
  6586. SubId = dac.Id,
  6587. DiId = dac.DiId,
  6588. Type = dac.Type,
  6589. Days = dac.Days,
  6590. NationalTravelFeeId = dac.NationalTravelFeeId,
  6591. Arae = $"{ntf.Country}-{ntf.City}",
  6592. Cost = dac.Cost,
  6593. Currency = dac.Currency,
  6594. CurrencyName = sd.Name,
  6595. SubTotal = dac.SubTotal,
  6596. })
  6597. .ToArray();
  6598. var data = new ChoiceFourMobileSubInfoView()
  6599. {
  6600. ParentId = eecInfo.Id,
  6601. ChoiceFour = eecInfo.ChoiceFour,
  6602. ChoiceFourTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6603. Details = dayAndCostDatas
  6604. };
  6605. return Ok(JsonView(data));
  6606. }
  6607. else if (subType == 5) //5:公杂费
  6608. {
  6609. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6610. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6611. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6612. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6613. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6614. {
  6615. SubId = dac.Id,
  6616. DiId = dac.DiId,
  6617. Type = dac.Type,
  6618. Days = dac.Days,
  6619. NationalTravelFeeId = dac.NationalTravelFeeId,
  6620. Arae = $"{ntf.Country}-{ntf.City}",
  6621. Cost = dac.Cost,
  6622. Currency = dac.Currency,
  6623. CurrencyName = sd.Name,
  6624. SubTotal = dac.SubTotal,
  6625. })
  6626. .ToArray();
  6627. var data = new ChoiceFiveMobileSubInfoView()
  6628. {
  6629. ParentId = eecInfo.Id,
  6630. ChoiceFive = eecInfo.ChoiceFive,
  6631. ChoiceFiveTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6632. Details = dayAndCostDatas
  6633. };
  6634. return Ok(JsonView(data));
  6635. }
  6636. else if (subType == 6) //6:培训费
  6637. {
  6638. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6639. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6640. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6641. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6642. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6643. {
  6644. SubId = dac.Id,
  6645. DiId = dac.DiId,
  6646. Type = dac.Type,
  6647. Days = dac.Days,
  6648. NationalTravelFeeId = dac.NationalTravelFeeId,
  6649. Arae = $"{ntf.Country}-{ntf.City}",
  6650. Cost = dac.Cost,
  6651. Currency = dac.Currency,
  6652. CurrencyName = sd.Name,
  6653. SubTotal = dac.SubTotal,
  6654. })
  6655. .ToArray();
  6656. var data = new ChoiceSixMobileSubInfoView()
  6657. {
  6658. ParentId = eecInfo.Id,
  6659. ChoiceSix = eecInfo.ChoiceSix,
  6660. ChoiceSixTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6661. Details = dayAndCostDatas
  6662. };
  6663. return Ok(JsonView(data));
  6664. }
  6665. else if (subType == 7) //7:其他
  6666. {
  6667. //其他款项
  6668. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6669. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6670. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6671. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6672. .OrderBy((dop, sd1, sd2) => dop.Index)
  6673. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6674. {
  6675. SubId = dop.Id,
  6676. DiId = dop.Diid,
  6677. Index = dop.Index,
  6678. SetDataId = dop.SetDataId,
  6679. SetDataName = sd1.Name,
  6680. Cost = dop.Cost,
  6681. Currency = dop.Currency,
  6682. CurrencyName = sd2.Remark,
  6683. SubTotal = dop.SubTotal,
  6684. Remark = dop.Remark,
  6685. })
  6686. .ToArray();
  6687. var data = new ChoiceSevenMobileSubInfoView()
  6688. {
  6689. ParentId = eecInfo.Id,
  6690. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6691. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6692. Details = otherData
  6693. };
  6694. return Ok(JsonView(data));
  6695. }
  6696. return Ok(JsonView(false));
  6697. }
  6698. #region op
  6699. /// <summary>
  6700. /// 移动端更新费用消息通知
  6701. /// </summary>
  6702. /// <param name="diid"></param>
  6703. /// <param name="id"></param>
  6704. /// <param name="currUserId"></param>
  6705. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6706. {
  6707. try
  6708. {
  6709. ////生成默认文件pdf并且通知人员
  6710. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6711. //{
  6712. // DiId = diid,
  6713. // ExportType = 1,
  6714. // SubTypeId = 1005
  6715. //}, "pdf");
  6716. ////发送通知
  6717. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6718. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6719. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6720. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6721. ////汇率信息记录
  6722. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6723. }
  6724. catch (Exception ex)
  6725. {
  6726. //记录日志
  6727. throw;
  6728. }
  6729. }
  6730. /// <summary>
  6731. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6732. /// </summary>
  6733. /// <returns></returns>
  6734. [HttpPost]
  6735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6736. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6737. {
  6738. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6739. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6740. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6741. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6742. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6743. int id = dto.Id;
  6744. if (id <= 0) //add
  6745. {
  6746. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6747. if (add < 1) return Ok(JsonView(false));
  6748. id = add;
  6749. }
  6750. else //update
  6751. {
  6752. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6753. if (upd < 1) return Ok(JsonView(false));
  6754. }
  6755. #region 汇率变更时更改币种相关费用
  6756. var opDayCosts = new List<Grp_DayAndCost>();
  6757. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6758. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6759. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6760. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6761. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6762. .Select((dac, sd) => new {
  6763. dac.Id,
  6764. dac.DiId,
  6765. CurrencyCode = sd.Name,
  6766. dac.Cost
  6767. })
  6768. .ToList();
  6769. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6770. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6771. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6772. .Select((dop, sd) => new {
  6773. dop.Id,
  6774. dop.Diid,
  6775. CurrencyCode = sd.Name,
  6776. dop.Cost
  6777. })
  6778. .ToList();
  6779. if (dayCosts.Count > 0)
  6780. {
  6781. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6782. foreach (var dc in new_dayCosts)
  6783. {
  6784. var thisCurrency = dc.Key.ToUpper();
  6785. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6786. if (thisRate == 0.00M) continue;
  6787. foreach (var dcSub in dc)
  6788. {
  6789. opDayCosts.Add(new Grp_DayAndCost() {
  6790. Id = dcSub.Id,
  6791. DiId = dcSub.DiId,
  6792. Cost = dcSub.Cost,
  6793. SubTotal = dcSub.Cost * thisRate,
  6794. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6795. });
  6796. }
  6797. }
  6798. if (opDayCosts.Count > 0)
  6799. {
  6800. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6801. }
  6802. }
  6803. if (dayOtherCosts.Count > 0)
  6804. {
  6805. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6806. foreach (var dc in new_dayOtherCosts)
  6807. {
  6808. var thisCurrency = dc.Key.ToUpper();
  6809. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6810. if (thisRate == 0.00M) continue;
  6811. foreach (var dcSub in dc)
  6812. {
  6813. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6814. {
  6815. Id = dcSub.Id,
  6816. Diid = dcSub.Diid,
  6817. Cost = dcSub.Cost,
  6818. SubTotal = dcSub.Cost * thisRate,
  6819. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6820. });
  6821. }
  6822. }
  6823. if (opDayOtherCosts.Count > 0)
  6824. {
  6825. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6826. }
  6827. }
  6828. #endregion
  6829. //消息通知
  6830. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6831. return Ok(JsonView(true));
  6832. }
  6833. /// <summary>
  6834. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6835. /// </summary>
  6836. /// <returns></returns>
  6837. [HttpPost]
  6838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6839. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6840. {
  6841. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6842. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6843. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6844. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6845. int id = dto.Id;
  6846. if (id <= 0) //add
  6847. {
  6848. checkboxInfo.CreateUserId = dto.CurrUserId;
  6849. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6850. if (add < 1) return Ok(JsonView(false));
  6851. }
  6852. else //update
  6853. {
  6854. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6855. .UpdateColumns(x => new {
  6856. x.ChoiceOne,
  6857. x.ChoiceTwo,
  6858. x.SumJJC,
  6859. x.SumGWC,
  6860. x.SumTDC,
  6861. x.ChoiceThree,
  6862. x.ChoiceFour,
  6863. x.ChoiceFive,
  6864. x.ChoiceSix,
  6865. x.OtherExpenses_Checked
  6866. })
  6867. .Where(x => x.Id == id)
  6868. .ExecuteCommandAsync();
  6869. if (upd < 1) return Ok(JsonView(false));
  6870. }
  6871. return Ok(JsonView(true));
  6872. }
  6873. /// <summary>
  6874. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6875. /// </summary>
  6876. /// <returns></returns>
  6877. [HttpPost]
  6878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6879. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6880. {
  6881. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6882. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6883. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6884. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6885. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6886. int id = dto.Id;
  6887. if (id <= 0) //add
  6888. {
  6889. info.CreateUserId = dto.CurrUserId;
  6890. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  6891. if (add < 1) return Ok(JsonView(false));
  6892. id = add;
  6893. }
  6894. else //update
  6895. {
  6896. var upd = await _sqlSugar.Updateable(info)
  6897. .UpdateColumns(x => new {
  6898. x.ChoiceOne,
  6899. x.InsidePay,
  6900. x.VisaRemark,
  6901. x.Visa,
  6902. x.Service,
  6903. x.Safe,
  6904. x.Ticket,
  6905. x.HeSuan,
  6906. x.YiMiao,
  6907. })
  6908. .Where(x => x.Id == id)
  6909. .ExecuteCommandAsync();
  6910. if (upd < 1) return Ok(JsonView(false));
  6911. }
  6912. //消息通知
  6913. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6914. return Ok(JsonView(new { itemTotal = info.InsidePay }));
  6915. }
  6916. /// <summary>
  6917. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  6918. /// </summary>
  6919. /// <returns></returns>
  6920. [HttpPost]
  6921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6922. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  6923. {
  6924. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6925. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6926. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6927. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6928. info.AirJJC_Checked = dto.ChoiceTwoJJ;
  6929. info.AirGWC_Checked = dto.ChoiceTwoGW;
  6930. info.AirTDC_Checked = dto.ChoiceTwoTD;
  6931. int id = dto.Id;
  6932. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  6933. if (id <= 0) //add
  6934. {
  6935. info.CreateUserId = dto.CurrUserId;
  6936. var addInfo = await _sqlSugar.Insertable(info).ExecuteReturnEntityAsync();
  6937. if (addInfo == null) return Ok(JsonView(false));
  6938. id = addInfo.Id;
  6939. }
  6940. else //update
  6941. {
  6942. var upd = await _sqlSugar.Updateable(info)
  6943. .UpdateColumns(x => new {
  6944. x.AirJJC_Checked,
  6945. x.OutsideJJPay,
  6946. x.AirGWC_Checked,
  6947. x.OutsideGWPay,
  6948. x.AirTDC_Checked,
  6949. x.OutsideTDPay,
  6950. x.AirJJ,
  6951. x.AirGW,
  6952. x.AirTD,
  6953. x.CityTranffic
  6954. })
  6955. .Where(x => x.Id == id)
  6956. .ExecuteCommandAsync();
  6957. if (upd > 0) return Ok(JsonView(false));
  6958. }
  6959. jjcItemTotal = info.AirJJ + info.CityTranffic;
  6960. gwcItemTotal = info.AirGW + info.CityTranffic;
  6961. tdcItemTotal = info.AirTD + info.CityTranffic;
  6962. //消息通知
  6963. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6964. return Ok(JsonView(new
  6965. {
  6966. choiceTwoJJ = dto.ChoiceTwoJJ,
  6967. jjcItemTotal = jjcItemTotal,
  6968. choiceTwoGW = dto.ChoiceTwoGW,
  6969. gwcItemTotal = gwcItemTotal,
  6970. choiceTwoTD = dto.ChoiceTwoTD,
  6971. tdcItemTotal = tdcItemTotal
  6972. }));
  6973. }
  6974. /// <summary>
  6975. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  6976. /// </summary>
  6977. /// <returns></returns>
  6978. [HttpPost]
  6979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6980. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  6981. {
  6982. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6983. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6984. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6985. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  6986. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  6987. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  6988. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  6989. var infos = infos1.Select(x => new Grp_DayAndCost
  6990. {
  6991. Id = x.Id,
  6992. DiId = dto.DiId,
  6993. Type = dto.FeeType,
  6994. Days = x.Days,
  6995. NationalTravelFeeId = x.NationalTravelFeeId,
  6996. Cost = x.Cost,
  6997. Currency = x.Currency,
  6998. SubTotal = x.SubTotal,
  6999. CreateUserId = dto.CurrUserId
  7000. })
  7001. .ToList();
  7002. var adds = infos.Where(x => x.Id <= 0).ToList();
  7003. var upds = infos.Where(x => x.Id > 0).ToList();
  7004. if (adds.Count > 0)
  7005. {
  7006. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7007. if (add < 1) return Ok(JsonView(false));
  7008. }
  7009. if (upds.Count > 0)
  7010. {
  7011. var upd = await _sqlSugar.Updateable(adds)
  7012. .UpdateColumns(x => new
  7013. {
  7014. x.Days,
  7015. x.NationalTravelFeeId,
  7016. x.Cost,
  7017. x.Currency,
  7018. x.SubTotal
  7019. })
  7020. .WhereColumns(x => new { x.Id })
  7021. .ExecuteCommandAsync();
  7022. if (upd < 1) return Ok(JsonView(false));
  7023. }
  7024. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7025. //消息通知
  7026. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7027. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7028. return Ok(JsonView(new { itemTotal = itemTotal }));
  7029. }
  7030. /// <summary>
  7031. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7032. /// </summary>
  7033. /// <returns></returns>
  7034. [HttpPost]
  7035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7036. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7037. {
  7038. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7039. int parentId = dto.ParentId, subId = dto.SubId, feeType = dto.FeeType;
  7040. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7041. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7042. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7043. if (!feeTypeIds.Contains(feeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7044. var parentInfo = new Grp_EnterExitCost();
  7045. parentInfo.Id = dto.ParentId;
  7046. parentInfo.CreateUserId = dto.CurrUserId;
  7047. if (feeType == 1) parentInfo.ChoiceThree = dto.IsSelect;
  7048. else if (feeType == 2) parentInfo.ChoiceFour = dto.IsSelect;
  7049. else if (feeType == 3) parentInfo.ChoiceFive = dto.IsSelect;
  7050. else if (feeType == 4) parentInfo.ChoiceSix = dto.IsSelect;
  7051. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7052. subInfo.Id = subId;
  7053. subInfo.CreateUserId = dto.CurrUserId;
  7054. _sqlSugar.BeginTran();
  7055. //主表op
  7056. if (parentId < 1) //添加
  7057. {
  7058. var parentAdd = await _sqlSugar.Insertable(parentInfo).ExecuteCommandAsync();
  7059. if (parentAdd < 1)
  7060. {
  7061. _sqlSugar.RollbackTran();
  7062. return Ok(JsonView(false));
  7063. }
  7064. //子表op
  7065. if (subId < 1)
  7066. {
  7067. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7068. if (subAdd < 1)
  7069. {
  7070. _sqlSugar.RollbackTran();
  7071. return Ok(JsonView(false));
  7072. }
  7073. }
  7074. else
  7075. {
  7076. var subUpd = await _sqlSugar.Updateable(subInfo)
  7077. .UpdateColumns(x => new
  7078. {
  7079. x.Days,
  7080. x.NationalTravelFeeId,
  7081. x.Cost,
  7082. x.Currency,
  7083. x.SubTotal
  7084. })
  7085. .WhereColumns(x => new { x.Id })
  7086. .ExecuteCommandAsync();
  7087. if (subUpd < 1)
  7088. {
  7089. _sqlSugar.RollbackTran();
  7090. return Ok(JsonView(false));
  7091. }
  7092. }
  7093. }
  7094. else
  7095. {
  7096. var parentUpd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  7097. .SetColumnsIF(feeType == 1, it => it.ChoiceThree == dto.IsSelect)
  7098. .SetColumnsIF(feeType == 2, it => it.ChoiceFour == dto.IsSelect)
  7099. .SetColumnsIF(feeType == 3, it => it.ChoiceFive == dto.IsSelect)
  7100. .SetColumnsIF(feeType == 4, it => it.ChoiceSix == dto.IsSelect)
  7101. .Where(it => it.Id == parentId)
  7102. .ExecuteCommandAsync();
  7103. if (parentUpd < 1)
  7104. {
  7105. _sqlSugar.RollbackTran();
  7106. return Ok(JsonView(false));
  7107. }
  7108. //子表op
  7109. if (subId < 1)
  7110. {
  7111. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7112. if (subAdd < 1)
  7113. {
  7114. _sqlSugar.RollbackTran();
  7115. return Ok(JsonView(false));
  7116. }
  7117. }
  7118. else
  7119. {
  7120. var subUpd = await _sqlSugar.Updateable(subInfo)
  7121. .UpdateColumns(x => new
  7122. {
  7123. x.Days,
  7124. x.NationalTravelFeeId,
  7125. x.Cost,
  7126. x.Currency,
  7127. x.SubTotal
  7128. })
  7129. .WhereColumns(x => new { x.Id })
  7130. .ExecuteCommandAsync();
  7131. if (subUpd < 1)
  7132. {
  7133. _sqlSugar.RollbackTran();
  7134. return Ok(JsonView(false));
  7135. }
  7136. }
  7137. }
  7138. _sqlSugar.CommitTran();
  7139. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7140. //消息通知
  7141. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7142. return Ok(JsonView(new { isSelect = dto.IsSelect, itemTotal = itemTotal }));
  7143. }
  7144. /// <summary>
  7145. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7146. /// </summary>
  7147. /// <returns></returns>
  7148. [HttpPost]
  7149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7150. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7151. {
  7152. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7153. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7154. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7155. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7156. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7157. {
  7158. Id = x.Id,
  7159. Diid = dto.DiId,
  7160. SetDataId = x.SetDataId,
  7161. Index = x.Index,
  7162. Cost = x.Cost,
  7163. Currency = x.Currency,
  7164. SubTotal = x.SubTotal,
  7165. CreateUserId = dto.CurrUserId,
  7166. Remark = x.Remark
  7167. }).ToList();
  7168. var adds = infos.Where(x => x.Id <= 0).ToList();
  7169. var upds = infos.Where(x => x.Id > 0).ToList();
  7170. if (adds.Count > 0)
  7171. {
  7172. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7173. if (add < 1) return Ok(JsonView(false));
  7174. }
  7175. if (upds.Count > 0)
  7176. {
  7177. var upd = await _sqlSugar.Updateable(adds)
  7178. .UpdateColumns(x => new
  7179. {
  7180. x.Index,
  7181. x.SetDataId,
  7182. x.Cost,
  7183. x.Currency,
  7184. x.SubTotal,
  7185. x.Remark
  7186. })
  7187. .WhereColumns(x => new { x.Id })
  7188. .ExecuteCommandAsync();
  7189. if (upd < 1) return Ok(JsonView(false));
  7190. }
  7191. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7192. //消息通知
  7193. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7194. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7195. return Ok(JsonView(new { itemTotal = itemTotal }));
  7196. }
  7197. /// <summary>
  7198. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7199. /// </summary>
  7200. /// <returns></returns>
  7201. [HttpPost]
  7202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7203. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7204. {
  7205. int parentId = dto.ParentId, subId = dto.SubId;
  7206. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7207. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7208. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7209. var parentInfo = new Grp_EnterExitCost();
  7210. parentInfo.Id = parentId;
  7211. parentInfo.OtherExpenses_Checked = dto.IsSelect;
  7212. parentInfo.CreateUserId = dto.CurrUserId;
  7213. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7214. subInfo.Id = subId;
  7215. subInfo.CreateUserId = dto.CurrUserId;
  7216. #region 主表op
  7217. _sqlSugar.BeginTran();
  7218. //主表op
  7219. if (parentId < 1)
  7220. {
  7221. var parentAdd = await _sqlSugar.Insertable(parentInfo).ExecuteCommandAsync();
  7222. if (parentAdd < 1)
  7223. {
  7224. _sqlSugar.RollbackTran();
  7225. return Ok(JsonView(false));
  7226. }
  7227. #region 子表op
  7228. if (subId < 1)//add
  7229. {
  7230. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7231. if (subAdd < 1)
  7232. {
  7233. _sqlSugar.RollbackTran();
  7234. return Ok(JsonView(false));
  7235. }
  7236. }
  7237. else //upd
  7238. {
  7239. var subUpd = await _sqlSugar.Updateable(subInfo)
  7240. .UpdateColumns(x => new
  7241. {
  7242. x.Index,
  7243. x.SetDataId,
  7244. x.Cost,
  7245. x.Currency,
  7246. x.SubTotal,
  7247. x.Remark
  7248. })
  7249. .WhereColumns(x => new { x.Id })
  7250. .ExecuteCommandAsync();
  7251. if (subUpd < 1)
  7252. {
  7253. _sqlSugar.RollbackTran();
  7254. return Ok(JsonView(false));
  7255. }
  7256. }
  7257. #endregion
  7258. }
  7259. else
  7260. {
  7261. var parentUpd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  7262. .SetColumns(it => it.OtherExpenses_Checked == dto.IsSelect)
  7263. .Where(it => it.Id == parentId)
  7264. .ExecuteCommandAsync();
  7265. if (parentUpd < 1)
  7266. {
  7267. _sqlSugar.RollbackTran();
  7268. return Ok(JsonView(false));
  7269. }
  7270. #region 子表op
  7271. if (subId < 1)//add
  7272. {
  7273. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7274. if (subAdd < 1)
  7275. {
  7276. _sqlSugar.RollbackTran();
  7277. return Ok(JsonView(false));
  7278. }
  7279. }
  7280. else //upd
  7281. {
  7282. var subUpd = await _sqlSugar.Updateable(subInfo)
  7283. .UpdateColumns(x => new
  7284. {
  7285. x.Index,
  7286. x.SetDataId,
  7287. x.Cost,
  7288. x.Currency,
  7289. x.SubTotal,
  7290. x.Remark
  7291. })
  7292. .WhereColumns(x => new { x.Id })
  7293. .ExecuteCommandAsync();
  7294. if (subUpd < 1)
  7295. {
  7296. _sqlSugar.RollbackTran();
  7297. return Ok(JsonView(false));
  7298. }
  7299. }
  7300. #endregion
  7301. }
  7302. _sqlSugar.CommitTran();
  7303. #endregion
  7304. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7305. //消息通知
  7306. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7307. return Ok(JsonView(new { isSelect = dto.IsSelect, itemTotal = itemTotal }));
  7308. }
  7309. #endregion
  7310. #endregion
  7311. #region 签证费用录入
  7312. /// <summary>
  7313. /// 根据diid查询签证费用列表
  7314. /// </summary>
  7315. /// <param name="dto"></param>
  7316. /// <returns></returns>
  7317. [HttpPost]
  7318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7319. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7320. {
  7321. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7322. if (groupData.Code != 0)
  7323. {
  7324. return Ok(JsonView(false, groupData.Msg));
  7325. }
  7326. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7327. }
  7328. /// <summary>
  7329. /// 根据签证费用Id查询单条数据及c表数据
  7330. /// </summary>
  7331. /// <param name="dto"></param>
  7332. /// <returns></returns>
  7333. [HttpPost]
  7334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7335. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7336. {
  7337. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7338. if (groupData.Code != 0)
  7339. {
  7340. return Ok(JsonView(false, groupData.Msg));
  7341. }
  7342. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7343. }
  7344. /// <summary>
  7345. /// 签证费用删除
  7346. /// </summary>
  7347. /// <param name="dto"></param>
  7348. /// <returns></returns>
  7349. [HttpPost]
  7350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7351. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7352. {
  7353. _sqlSugar.BeginTran();
  7354. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7355. if (!res)
  7356. {
  7357. _sqlSugar.RollbackTran();
  7358. return Ok(JsonView(false, "删除失败"));
  7359. }
  7360. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7361. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7362. .SetColumns(a => new Grp_CreditCardPayment()
  7363. {
  7364. IsDel = 1,
  7365. DeleteUserId = dto.DeleteUserId,
  7366. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7367. })
  7368. .ExecuteCommand();
  7369. if (resSub < 1)
  7370. {
  7371. _sqlSugar.RollbackTran();
  7372. return Ok(JsonView(false, "删除失败"));
  7373. }
  7374. _sqlSugar.CommitTran();
  7375. return Ok(JsonView(true, "删除成功!"));
  7376. }
  7377. /// <summary>
  7378. /// 签证费用录入下拉框初始化
  7379. /// </summary>
  7380. /// <returns></returns>
  7381. [HttpPost]
  7382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7383. public async Task<IActionResult> VisaPriceAddSelect()
  7384. {
  7385. //支付方式
  7386. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7387. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7388. //币种
  7389. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7390. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7391. //乘客类型
  7392. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7393. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7394. //卡类型
  7395. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7396. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7397. //代办费类型
  7398. var agencyFeeTypeData = new List<dynamic>() {
  7399. new { id = 0 , Text = "未选择" },
  7400. new { id = 1 , Text = "小公务" },
  7401. new { id = 2 , Text = "大公务" },
  7402. };
  7403. //签证费用标准国家Data
  7404. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7405. var data = new
  7406. {
  7407. Payment = _Payment,
  7408. CurrencyList = _CurrencyList,
  7409. PassengerType = _PassengerType,
  7410. BankCard = _BankCard,
  7411. AgencyFeeType = agencyFeeTypeData,
  7412. CountryFeeData = visaCountryFeeData
  7413. };
  7414. return Ok(JsonView(true, "查询成功!", data));
  7415. }
  7416. /// <summary>
  7417. /// 签证费用录入操作(Status:1.新增,2.修改)
  7418. /// </summary>
  7419. /// <param name="dto"></param>
  7420. /// <returns></returns>
  7421. [HttpPost]
  7422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7423. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7424. {
  7425. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7426. if (groupData.Code != 0)
  7427. {
  7428. return Ok(JsonView(false, groupData.Msg));
  7429. }
  7430. #region 应用推送
  7431. try
  7432. {
  7433. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7434. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7435. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7436. //2024-10-21 新增LZ UID
  7437. var userIds = new List<int>() { 21 };
  7438. string title = $"系统通知";
  7439. string content = "";
  7440. var diId = dto.DiId;
  7441. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7442. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7443. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7444. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7445. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7446. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7447. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7448. }
  7449. catch (Exception ex)
  7450. {
  7451. }
  7452. #endregion
  7453. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7454. }
  7455. #endregion
  7456. #region 签证提成录入
  7457. /// <summary>
  7458. /// 签证提成录入
  7459. /// 基础数据
  7460. /// </summary>
  7461. /// <param name="_dto"></param>
  7462. /// <returns></returns>
  7463. [HttpGet]
  7464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7465. public async Task<IActionResult> VisaCommissionInit()
  7466. {
  7467. return Ok(await _visaCommissionRep.Init());
  7468. }
  7469. /// <summary>
  7470. /// 签证提成录入
  7471. /// Item
  7472. /// </summary>
  7473. /// <param name="_dto"></param>
  7474. /// <returns></returns>
  7475. [HttpPost]
  7476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7477. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7478. {
  7479. var validator = new VisaCommissionItemDtoValidator();
  7480. var validatorRes = await validator.ValidateAsync(_dto);
  7481. if (!validatorRes.IsValid)
  7482. {
  7483. StringBuilder sb = new StringBuilder();
  7484. foreach (var item in validatorRes.Errors)
  7485. {
  7486. sb.AppendLine(item.ErrorMessage);
  7487. }
  7488. return Ok(JsonView(false, sb.ToString()));
  7489. }
  7490. return Ok(await _visaCommissionRep.Item(_dto));
  7491. }
  7492. /// <summary>
  7493. /// 签证提成录入
  7494. /// Save
  7495. /// </summary>
  7496. /// <param name="_dto"></param>
  7497. /// <returns></returns>
  7498. [HttpPost]
  7499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7500. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7501. {
  7502. //参数验证
  7503. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7504. foreach (var item in _dto.Items)
  7505. {
  7506. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7507. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7508. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7509. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7510. }
  7511. return Ok(await _visaCommissionRep.Save(_dto));
  7512. }
  7513. /// <summary>
  7514. /// 签证提成录入
  7515. /// Create
  7516. /// </summary>
  7517. /// <param name="_dto"></param>
  7518. /// <returns></returns>
  7519. [HttpPost]
  7520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7521. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7522. {
  7523. var validator = new VisaCommissionCreateDtoValidator();
  7524. var validatorRes = await validator.ValidateAsync(_dto);
  7525. if (!validatorRes.IsValid)
  7526. {
  7527. StringBuilder sb = new StringBuilder();
  7528. foreach (var item in validatorRes.Errors)
  7529. {
  7530. sb.AppendLine(item.ErrorMessage);
  7531. }
  7532. return Ok(JsonView(false, sb.ToString()));
  7533. }
  7534. return Ok(await _visaCommissionRep.Create(_dto));
  7535. }
  7536. /// <summary>
  7537. /// 签证提成录入
  7538. /// Put(编辑)
  7539. /// </summary>
  7540. /// <param name="id"></param>
  7541. /// <param name="_dto"></param>
  7542. /// <returns></returns>
  7543. [HttpPut]
  7544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7545. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7546. {
  7547. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7548. var validator = new VisaCommissionCreateDtoValidator();
  7549. var validatorRes = await validator.ValidateAsync(_dto);
  7550. if (!validatorRes.IsValid)
  7551. {
  7552. StringBuilder sb = new StringBuilder();
  7553. foreach (var item in validatorRes.Errors)
  7554. {
  7555. sb.AppendLine(item.ErrorMessage);
  7556. }
  7557. return Ok(JsonView(false, sb.ToString()));
  7558. }
  7559. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7560. }
  7561. /// <summary>
  7562. /// 签证提成录入
  7563. /// Del
  7564. /// </summary>
  7565. /// <param name="id"></param>
  7566. /// <param name="currUserId"></param>
  7567. /// <returns></returns>
  7568. [HttpPost]
  7569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7570. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7571. {
  7572. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7573. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7574. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7575. }
  7576. #endregion
  7577. #region op费用录入
  7578. /// <summary>
  7579. /// 根据diid查询op费用列表
  7580. /// </summary>
  7581. /// <param name="dto"></param>
  7582. /// <returns></returns>
  7583. [HttpPost]
  7584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7585. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7586. {
  7587. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7588. if (groupData.Code != 0)
  7589. {
  7590. return Ok(JsonView(false, groupData.Msg));
  7591. }
  7592. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7593. }
  7594. /// <summary>
  7595. /// 根据op费用Id查询单条数据及c表数据
  7596. /// </summary>
  7597. /// <param name="dto"></param>
  7598. /// <returns></returns>
  7599. [HttpPost]
  7600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7601. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7602. {
  7603. try
  7604. {
  7605. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7606. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7607. var data = new
  7608. {
  7609. CarTouristGuideGround = _groupData,
  7610. CreditCardPayment = _creditCardPayment
  7611. };
  7612. return Ok(JsonView(true, "查询成功!", data));
  7613. }
  7614. catch (Exception ex)
  7615. {
  7616. return Ok(JsonView(false, "程序错误!"));
  7617. }
  7618. }
  7619. /// <summary>
  7620. /// op费用删除
  7621. /// </summary>
  7622. /// <param name="dto"></param>
  7623. /// <returns></returns>
  7624. [HttpPost]
  7625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7626. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7627. {
  7628. try
  7629. {
  7630. _sqlSugar.BeginTran();
  7631. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7632. if (!res)
  7633. {
  7634. return Ok(JsonView(false, "删除失败"));
  7635. }
  7636. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7637. {
  7638. IsDel = 1,
  7639. DeleteUserId = dto.DeleteUserId,
  7640. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7641. }).ExecuteCommandAsync();
  7642. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7643. {
  7644. IsDel = 1,
  7645. DeleteUserId = dto.DeleteUserId,
  7646. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7647. }).ExecuteCommandAsync();
  7648. #region 删除超支相关数据
  7649. //删除导入的超支数据
  7650. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7651. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7652. {
  7653. IsDel = 1,
  7654. DeleteUserId = dto.DeleteUserId,
  7655. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7656. }).ExecuteCommand();
  7657. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7658. {
  7659. IsDel = 1,
  7660. DeleteUserId = dto.DeleteUserId,
  7661. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7662. }).ExecuteCommand();
  7663. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7664. {
  7665. IsDel = 1,
  7666. DeleteUserId = dto.DeleteUserId,
  7667. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7668. }).ExecuteCommand();
  7669. #endregion
  7670. _sqlSugar.CommitTran();
  7671. return Ok(JsonView(true, "删除成功!"));
  7672. }
  7673. catch (Exception ex)
  7674. {
  7675. _sqlSugar.RollbackTran();
  7676. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7677. }
  7678. }
  7679. /// <summary>
  7680. /// op费用录入操作(Status:1.新增,2.修改)
  7681. /// </summary>
  7682. /// <param name="dto"></param>
  7683. /// <returns></returns>
  7684. [HttpPost]
  7685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7686. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7687. {
  7688. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7689. if (groupData.Code != 0)
  7690. {
  7691. return Ok(JsonView(false, groupData.Msg));
  7692. }
  7693. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7694. }
  7695. /// <summary>
  7696. /// 填写费用详细页面初始化绑定
  7697. /// </summary>
  7698. /// <param name="dto"></param>
  7699. /// <returns></returns>
  7700. [HttpPost]
  7701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7702. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7703. {
  7704. try
  7705. {
  7706. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7707. if (groupData.Code != 0)
  7708. {
  7709. return Ok(JsonView(false, groupData.Msg));
  7710. }
  7711. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7712. }
  7713. catch (Exception ex)
  7714. {
  7715. return Ok(JsonView(false, ex.Message));
  7716. }
  7717. }
  7718. /// <summary>
  7719. /// 根据op费用Id查询详细数据
  7720. /// </summary>
  7721. /// <param name="dto"></param>
  7722. /// <returns></returns>
  7723. [HttpPost]
  7724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7725. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7726. {
  7727. try
  7728. {
  7729. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7730. if (groupData.Code != 0)
  7731. {
  7732. return Ok(JsonView(false, groupData.Msg));
  7733. }
  7734. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7735. }
  7736. catch (Exception ex)
  7737. {
  7738. return Ok(JsonView(false, ex.Message));
  7739. }
  7740. }
  7741. /// <summary>
  7742. /// OP费用录入填写详情
  7743. /// </summary>
  7744. /// <param name="dto"></param>
  7745. /// <returns></returns>
  7746. [HttpPost]
  7747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7748. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7749. {
  7750. try
  7751. {
  7752. #region 参数校验
  7753. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7754. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7755. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7756. #endregion
  7757. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7758. if (groupData.Code != 0)
  7759. {
  7760. return Ok(JsonView(false, groupData.Msg));
  7761. }
  7762. //自动审核
  7763. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7764. #region 应用推送
  7765. try
  7766. {
  7767. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7768. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7769. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7770. //2024-10-21 新增LZ UID
  7771. var userIds = new List<int>() { 21 };
  7772. string title = $"系统通知";
  7773. var diId = dto.DiId;
  7774. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7775. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7776. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7777. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7778. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7779. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7780. }
  7781. catch (Exception ex)
  7782. {
  7783. }
  7784. #endregion
  7785. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7786. }
  7787. catch (Exception ex)
  7788. {
  7789. return Ok(JsonView(false, ex.Message));
  7790. }
  7791. }
  7792. /// <summary>
  7793. /// 获取三公详细所有城市
  7794. /// </summary>
  7795. /// <returns></returns>
  7796. [HttpGet]
  7797. public IActionResult OpCarCityResult()
  7798. {
  7799. var jw = JsonView(false);
  7800. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7801. {
  7802. x.Id,
  7803. x.Country,
  7804. x.City,
  7805. }).ToList();
  7806. if (data.Count > 0)
  7807. {
  7808. jw = JsonView(true, "获取成功!", data);
  7809. }
  7810. else
  7811. {
  7812. jw.Msg = "城市数据为空!";
  7813. jw.Data = new string[0];
  7814. }
  7815. return Ok(jw);
  7816. }
  7817. /// <summary>
  7818. /// 导出地接费用明细
  7819. /// </summary>
  7820. /// <param name="dto"></param>
  7821. /// <returns></returns>
  7822. [HttpPost]
  7823. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7824. {
  7825. var jw = JsonView(false);
  7826. if (dto.Diid < 1)
  7827. {
  7828. jw.Msg = "请输入正确的diid!";
  7829. return Ok(jw);
  7830. }
  7831. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7832. if (group == null)
  7833. {
  7834. jw.Msg = "未找到团组信息!";
  7835. return Ok(jw);
  7836. }
  7837. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7838. if (localGuideArr.Count == 0)
  7839. {
  7840. jw.Msg = "该团组暂无地接信息!";
  7841. return Ok(jw);
  7842. }
  7843. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7844. var overspendSoure = new Dictionary<int, int>
  7845. {
  7846. { 91, 982 }, //车
  7847. { 92 , 1059} ,//导游
  7848. { 994 , 1073}, //翻译
  7849. { 988 , 1074 }, //早餐
  7850. { 93 , 1075 }, //午餐
  7851. { 989 , 1076 }, //晚餐
  7852. };
  7853. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7854. foreach (var groupArr in localGroup)
  7855. {
  7856. var keyValue = groupArr.Key;
  7857. if (int.TryParse(keyValue, out int cityid))
  7858. {
  7859. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7860. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7861. }
  7862. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7863. foreach (var item in groupArr)
  7864. {
  7865. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7866. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7867. new Grp_CarTouristGuideGroundReservationsContentExtend
  7868. {
  7869. Count = a.Count,
  7870. CreateTime = a.CreateTime,
  7871. CreateUserId = a.CreateUserId,
  7872. CTGGRId = a.CTGGRId,
  7873. Currency = a.Currency,
  7874. DatePrice = a.DatePrice,
  7875. DeleteTime = a.DeleteTime,
  7876. DeleteUserId = a.DeleteUserId,
  7877. DiId = a.DiId,
  7878. Id = a.Id,
  7879. IsDel = a.IsDel,
  7880. Price = a.Price,
  7881. PriceContent = a.PriceContent,
  7882. Remark = a.Remark,
  7883. SId = a.SId,
  7884. SidName = b.Name,
  7885. Units = a.Units,
  7886. }
  7887. ).ToList();
  7888. if (content.Count > 0)
  7889. {
  7890. contentArr.Add(content);
  7891. }
  7892. }
  7893. //open excel
  7894. //set excel
  7895. //save excel
  7896. try
  7897. {
  7898. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7899. IWorkbook workbook;
  7900. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7901. {
  7902. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7903. }
  7904. else
  7905. {
  7906. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7907. }
  7908. ISheet sheet = workbook.GetSheetAt(0);
  7909. var rowStartIndex = 2;
  7910. var clounmCount = 10;
  7911. var initStyleRow = sheet.GetRow(2);
  7912. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7913. //var overspendArrDetail =
  7914. var existsId = new List<CarCompare>();
  7915. var lastElem = arr.Last();
  7916. var thisSid = -1;
  7917. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7918. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7919. {
  7920. Name = "未知币种!",
  7921. Remark = "未知币种!",
  7922. };
  7923. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7924. Action cloneRowFn = () =>
  7925. {
  7926. rowStartIndex++;
  7927. var cloneRow = sheet.CreateRow(rowStartIndex);
  7928. // 复制样式
  7929. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7930. {
  7931. ICell sourceCell = initStyleRow.GetCell(i);
  7932. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7933. // 确保单元格存在样式
  7934. if (sourceCell.CellStyle != null)
  7935. {
  7936. targetCell.CellStyle = sourceCell.CellStyle;
  7937. }
  7938. }
  7939. };
  7940. var mergeRow = () =>
  7941. {
  7942. for (int i = 2; i < sheet.LastRowNum; i++)
  7943. {
  7944. var row = sheet.GetRow(i);
  7945. var cellFirst = row.GetCell(0);
  7946. var thisIndex = i + 1;
  7947. while (thisIndex < sheet.LastRowNum)
  7948. {
  7949. var nextRow = sheet.GetRow(thisIndex);
  7950. var nextCellFirst = nextRow.GetCell(0);
  7951. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7952. {
  7953. thisIndex++;
  7954. }
  7955. else
  7956. {
  7957. break;
  7958. }
  7959. }
  7960. thisIndex--;
  7961. if (thisIndex != i)
  7962. {
  7963. //合并row
  7964. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7965. i, // 起始行索引(0-based)
  7966. thisIndex, // 结束行索引(0-based)
  7967. 0, // 起始列索引(0-based)
  7968. 0 // 结束列索引(0-based)
  7969. );
  7970. sheet.AddMergedRegion(cellRangeAddress);
  7971. i = thisIndex;
  7972. }
  7973. }
  7974. };
  7975. var chaoshiNumber = 0;
  7976. var totalNumber = 0.00M;
  7977. string lastStr = "";
  7978. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7979. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7980. {
  7981. b.IsAuditGM,
  7982. x.Id,
  7983. x.Area,
  7984. b.PayPercentage,
  7985. b.PayMoney,
  7986. }).ToList();
  7987. string yesPayment = "", noPayment = "";
  7988. foreach (var item in queryCarArrByCityAndDiid)
  7989. {
  7990. if (item.IsAuditGM == 1)
  7991. {
  7992. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7993. }
  7994. else
  7995. {
  7996. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7997. }
  7998. }
  7999. lastStr = yesPayment + noPayment;
  8000. foreach (var item in arr)
  8001. {
  8002. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  8003. {
  8004. if (thisSid != item.SId)
  8005. {
  8006. if (thisSid == -1)
  8007. {
  8008. thisSid = item.SId;
  8009. }
  8010. else
  8011. {
  8012. //合并小计行
  8013. //创建合并区域的实例
  8014. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8015. rowStartIndex, // 起始行索引(0-based)
  8016. rowStartIndex, // 结束行索引(0-based)
  8017. 0, // 起始列索引(0-based)
  8018. 3 // 结束列索引(0-based)
  8019. );
  8020. sheet.AddMergedRegion(cellRangeAddress);
  8021. var CellStyle = workbook.CreateCellStyle();
  8022. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8023. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8024. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8025. for (int i = 0; i <= clounmCount; i++)
  8026. {
  8027. if (i > 6)
  8028. {
  8029. var CellStyle1 = workbook.CreateCellStyle();
  8030. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8031. IFont Font = workbook.CreateFont(); // 创建字体
  8032. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8033. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8034. CellStyle1.SetFont(Font);
  8035. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8036. }
  8037. else
  8038. {
  8039. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8040. }
  8041. }
  8042. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8043. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8044. //超时合计
  8045. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8046. //超时数
  8047. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8048. //超时合计费用
  8049. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8050. thisSid = item.SId;
  8051. cloneRowFn();
  8052. chaoshiNumber = 0;
  8053. totalNumber = 0;
  8054. }
  8055. }
  8056. IRow row = sheet.GetRow(rowStartIndex);
  8057. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8058. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  8059. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  8060. if (isOpenOverspendSoure)
  8061. {
  8062. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8063. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  8064. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  8065. }
  8066. for (int i = 0; i <= clounmCount; i++)
  8067. {
  8068. var cell = row.GetCell(i);
  8069. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  8070. if (cell == null)
  8071. {
  8072. cell = row.CreateCell(i);
  8073. }
  8074. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  8075. fontRed.CloneStyleFrom(cell.CellStyle);
  8076. IFont Font = workbook.CreateFont(); // 创建字体
  8077. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8078. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8079. fontRed.SetFont(Font);
  8080. byte[] rgb = new byte[3] { 255, 242, 204 };
  8081. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8082. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8083. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8084. if (workbook is XSSFWorkbook)
  8085. {
  8086. BackgroundColor255_242_204.FillForegroundColor = 0;
  8087. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8088. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8089. }
  8090. else
  8091. {
  8092. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8093. }
  8094. if (i == 1 || i > 6)
  8095. {
  8096. if (i > 6)
  8097. {
  8098. fontRed.FillForegroundColor = 0;
  8099. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8100. fontRed.FillPattern = FillPattern.SolidForeground;
  8101. }
  8102. cell.CellStyle = fontRed;
  8103. }
  8104. if (i > 2 && i < 7)
  8105. {
  8106. cell.CellStyle = BackgroundColor255_242_204;
  8107. }
  8108. cell.SetCellValue(setCellValue); //写入单元格
  8109. }
  8110. if (overspendSoure.ContainsKey(thisSid))
  8111. {
  8112. var overspendId = overspendSoure[thisSid];
  8113. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8114. }
  8115. cloneRowFn();
  8116. existsId.Add(new CarCompare
  8117. {
  8118. DataPrice = item.DatePrice.ObjToDate(),
  8119. Sid = item.SId
  8120. });
  8121. }
  8122. if (item.Equals(lastElem))
  8123. {
  8124. //合并小计行
  8125. //创建合并区域的实例
  8126. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8127. rowStartIndex, // 起始行索引(0-based)
  8128. rowStartIndex, // 结束行索引(0-based)
  8129. 0, // 起始列索引(0-based)
  8130. 3 // 结束列索引(0-based)
  8131. );
  8132. sheet.AddMergedRegion(cellRangeAddress);
  8133. var CellStyle = workbook.CreateCellStyle();
  8134. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8135. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8136. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8137. for (int i = 0; i <= clounmCount; i++)
  8138. {
  8139. if (i > 6)
  8140. {
  8141. var CellStyle1 = workbook.CreateCellStyle();
  8142. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8143. IFont Font = workbook.CreateFont(); // 创建字体
  8144. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8145. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8146. CellStyle1.SetFont(Font);
  8147. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8148. }
  8149. else
  8150. {
  8151. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8152. }
  8153. }
  8154. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8155. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8156. //超时合计
  8157. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8158. //超时数
  8159. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8160. //超时合计费用
  8161. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8162. cloneRowFn();
  8163. // 创建合并区域的实例
  8164. cellRangeAddress = new CellRangeAddress(
  8165. rowStartIndex, // 起始行索引(0-based)
  8166. rowStartIndex, // 结束行索引(0-based)
  8167. 0, // 起始列索引(0-based)
  8168. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8169. );
  8170. // 添加合并区域
  8171. sheet.AddMergedRegion(cellRangeAddress);
  8172. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8173. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8174. }
  8175. }
  8176. mergeRow();
  8177. // 保存修改后的Excel文件到新文件
  8178. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8179. // new FileStream(newFilePath, FileMode.CreateNew)
  8180. using (var stream = new MemoryStream())
  8181. {
  8182. workbook.Write(stream, true);
  8183. stream.Flush();
  8184. stream.Seek(0, SeekOrigin.Begin);
  8185. MemoryStream memoryStream = new MemoryStream();
  8186. stream.CopyTo(memoryStream);
  8187. memoryStream.Seek(0, SeekOrigin.Begin);
  8188. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8189. }
  8190. workbook.Close();
  8191. workbook.Dispose();
  8192. }
  8193. catch (Exception ex)
  8194. {
  8195. jw.Msg = "出现异常!" + ex.Message;
  8196. return Ok(jw);
  8197. }
  8198. }
  8199. if (Zips.Count > 0)
  8200. {
  8201. IOOperatorHelper io = new IOOperatorHelper();
  8202. var byts = io.ConvertZipStream(Zips);
  8203. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8204. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8205. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8206. }
  8207. else
  8208. {
  8209. jw.Msg = "暂无生成文件!";
  8210. }
  8211. return Ok(jw);
  8212. }
  8213. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8214. {
  8215. string outStr = string.Empty;
  8216. switch (i)
  8217. {
  8218. case 0:
  8219. outStr = arr[0].SidName;
  8220. break;
  8221. case 1:
  8222. outStr = arr[0].DataPriceStr;
  8223. break;
  8224. case 2:
  8225. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8226. break;
  8227. case 4:
  8228. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8229. break;
  8230. case 7:
  8231. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8232. {
  8233. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8234. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8235. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8236. }
  8237. break;
  8238. case 8:
  8239. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8240. {
  8241. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8242. }
  8243. break;
  8244. case 9:
  8245. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8246. {
  8247. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8248. }
  8249. break;
  8250. case 10:
  8251. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8252. {
  8253. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8254. }
  8255. break;
  8256. }
  8257. return outStr;
  8258. }
  8259. #region OP行程单
  8260. /// <summary>
  8261. /// OP行程单初始化
  8262. /// </summary>
  8263. /// <param name="dto"></param>
  8264. /// <returns></returns>
  8265. [HttpPost]
  8266. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8267. {
  8268. var jw = JsonView(false);
  8269. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8270. var group = groupList.First();
  8271. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8272. if (group == null)
  8273. {
  8274. jw.Msg = "暂无团组!";
  8275. return Ok(jw);
  8276. }
  8277. group = groupList.Find(x => x.Id == diid);
  8278. if (group == null)
  8279. {
  8280. jw.Msg = "请输入正确的团组ID!";
  8281. return Ok(jw);
  8282. }
  8283. string city = string.Empty;
  8284. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8285. if (blackCode.Count > 0)
  8286. {
  8287. var black = blackCode.First();
  8288. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8289. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8290. if (blackSp.Length > 0)
  8291. {
  8292. try
  8293. {
  8294. var cityArrCode = new List<string>(20);
  8295. foreach (var item in blackSp)
  8296. {
  8297. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8298. var IndexSelect = itemSp[2];
  8299. var cityArrCodeLength = cityArrCode.Count - 1;
  8300. var startCity = IndexSelect.Substring(0, 3);
  8301. if (cityArrCodeLength > 0)
  8302. {
  8303. var arrEndCity = cityArrCode[cityArrCodeLength];
  8304. if (arrEndCity != startCity)
  8305. {
  8306. cityArrCode.Add(startCity.ToUpper());
  8307. }
  8308. }
  8309. else
  8310. {
  8311. cityArrCode.Add(startCity.ToUpper());
  8312. }
  8313. var endCity = IndexSelect.Substring(3, 3);
  8314. cityArrCode.Add(endCity.ToUpper());
  8315. }
  8316. var cityThree = string.Empty;
  8317. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8318. cityThree = cityThree.TrimEnd(',');
  8319. if (string.IsNullOrWhiteSpace(cityThree))
  8320. {
  8321. throw new
  8322. Exception("error");
  8323. }
  8324. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8325. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8326. foreach (var item in cityArrCode)
  8327. {
  8328. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8329. if (find != null)
  8330. {
  8331. city += find.City + "/";
  8332. }
  8333. else
  8334. {
  8335. city += item + "三字码未收入/";
  8336. }
  8337. }
  8338. city = city.TrimEnd('/');
  8339. }
  8340. catch (Exception e)
  8341. {
  8342. city = "黑屏代码格式不正确!";
  8343. }
  8344. }
  8345. }
  8346. else
  8347. {
  8348. city = "未录入黑屏代码";
  8349. }
  8350. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8351. {
  8352. Date = x.Date,
  8353. Days = x.Days,
  8354. Diffgroup = x.Diffgroup,
  8355. Diid = x.Diid,
  8356. Traffic_First = x.Traffic_First,
  8357. Traffic_Second = x.Traffic_Second,
  8358. Trip = x.Trip,
  8359. WeekDay = x.WeekDay,
  8360. Id = x.Id
  8361. }).ToList();
  8362. jw.Data = new
  8363. {
  8364. groupList = groupList.Select(x => new
  8365. {
  8366. x.Id,
  8367. x.TeamName,
  8368. x.TourCode
  8369. }).ToList(),
  8370. groupInfo = new
  8371. {
  8372. group.VisitDays,
  8373. group.TourCode,
  8374. group.VisitPNumber,
  8375. group.TeamName,
  8376. city
  8377. },
  8378. OpTravelList
  8379. };
  8380. jw.Code = 200;
  8381. jw.Msg = "操作成功!";
  8382. return Ok(jw);
  8383. }
  8384. /// <summary>
  8385. /// 删除团组行程单
  8386. /// </summary>
  8387. /// <returns></returns>
  8388. [HttpPost]
  8389. public IActionResult DelTravel(DelOpTravelDto dto)
  8390. {
  8391. var jw = JsonView(false);
  8392. if (dto.UserId <= 0 || dto.Diid <= 0)
  8393. {
  8394. jw.Msg = "请输入正确的参数!";
  8395. return Ok(jw);
  8396. }
  8397. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8398. .SetColumns(x => new Grp_TravelList
  8399. {
  8400. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8401. DeleteUserId = dto.UserId,
  8402. IsDel = 1,
  8403. }).ExecuteCommand();
  8404. jw = JsonView(true);
  8405. return Ok(jw);
  8406. }
  8407. /// <summary>
  8408. /// 行程单保存
  8409. /// </summary>
  8410. /// <returns></returns>
  8411. [HttpPost]
  8412. public IActionResult TravelSave(TravelSaveDto dto)
  8413. {
  8414. var jw = JsonView(false);
  8415. if (dto.Arr.Count > 0)
  8416. {
  8417. try
  8418. {
  8419. _sqlSugar.BeginTran();
  8420. foreach (var item in dto.Arr)
  8421. {
  8422. if (item.Id == 0)
  8423. {
  8424. throw new Exception("请传入正确的Id");
  8425. }
  8426. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8427. .SetColumns(x => new Grp_TravelList
  8428. {
  8429. Trip = item.Trip
  8430. }).ExecuteCommand();
  8431. }
  8432. _sqlSugar.CommitTran();
  8433. jw = JsonView(true);
  8434. }
  8435. catch (Exception ex)
  8436. {
  8437. _sqlSugar.RollbackTran();
  8438. jw.Msg = "程序异常!" + ex.Message;
  8439. }
  8440. }
  8441. else
  8442. {
  8443. jw.Msg = "请传入正确的参数!";
  8444. }
  8445. return Ok(jw);
  8446. }
  8447. /// <summary>
  8448. /// 导出行程单
  8449. /// </summary>
  8450. /// <param name="dto"></param>
  8451. /// <returns></returns>
  8452. [HttpPost]
  8453. public IActionResult ExportTravel(ExportTravelDto dto)
  8454. {
  8455. var jw = JsonView(false);
  8456. jw.Data = "";
  8457. int diid = 0;
  8458. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8459. if (Find == null)
  8460. {
  8461. jw.Msg = "请选择正确的团组!";
  8462. return Ok(jw);
  8463. }
  8464. else
  8465. {
  8466. diid = Find.Id;
  8467. }
  8468. //数据源
  8469. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8470. DataTable dtBlack = null;
  8471. try
  8472. {
  8473. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8474. }
  8475. catch (Exception)
  8476. {
  8477. jw.Msg = "机票黑屏代码有误!";
  8478. return Ok(jw);
  8479. }
  8480. string CityStr = string.Empty;
  8481. if (dtBlack.Rows.Count == 0)
  8482. {
  8483. jw.Msg = "机票黑屏代码有误!";
  8484. return Ok(jw);
  8485. }
  8486. else
  8487. {
  8488. foreach (DataRow row in dtBlack.Rows)
  8489. {
  8490. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8491. {
  8492. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8493. return Ok(jw);
  8494. }
  8495. }
  8496. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8497. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8498. }
  8499. //创建数据源Table
  8500. DataTable dtSource = new DataTable();
  8501. dtSource.Columns.Add("Days", typeof(string));
  8502. dtSource.Columns.Add("Date", typeof(string));
  8503. dtSource.Columns.Add("Week", typeof(string));
  8504. dtSource.Columns.Add("Traffic", typeof(string));
  8505. dtSource.Columns.Add("Trip", typeof(string));
  8506. //获取数据,放到datatable
  8507. foreach (var item in _travelList)
  8508. {
  8509. DataRow dr = dtSource.NewRow();
  8510. dr["Days"] = item.Days;
  8511. dr["Date"] = item.Date;
  8512. dr["Week"] = item.WeekDay;
  8513. dr["Traffic"] = item.Traffic_First
  8514. + "\r\n"
  8515. + item.Traffic_Second;
  8516. dr["Trip"] = item.Trip;
  8517. dtSource.Rows.Add(dr);
  8518. }
  8519. Dictionary<string, string> dic = new Dictionary<string, string>();
  8520. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8521. dic.Add("City", CityStr);
  8522. dic.Add("Days", Find.VisitDays.ToString());
  8523. dic.Add("DeleCode", Find.TourCode);
  8524. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8525. //模板路径
  8526. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8527. //载入模板
  8528. Document doc = null;
  8529. DocumentBuilder builder = null;
  8530. try
  8531. {
  8532. //载入模板
  8533. doc = new Document(tempPath);
  8534. builder = new DocumentBuilder(doc);
  8535. }
  8536. catch (Exception)
  8537. {
  8538. jw.Msg = "模板位置不存在!";
  8539. return Ok(jw);
  8540. }
  8541. foreach (var key in dic.Keys)
  8542. {
  8543. Bookmark bookmark = doc.Range.Bookmarks[key];
  8544. if (bookmark != null)
  8545. {
  8546. builder.MoveToBookmark(key);
  8547. builder.Write(dic[key]);
  8548. }
  8549. }
  8550. //获取word里所有表格
  8551. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8552. //获取所填表格的序数
  8553. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8554. try
  8555. {
  8556. //循环赋值
  8557. for (int i = 0; i < dtSource.Rows.Count; i++)
  8558. {
  8559. builder.MoveToCell(0, i + 1, 0, 0);
  8560. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8561. builder.MoveToCell(0, i + 1, 1, 0);
  8562. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8563. builder.MoveToCell(0, i + 1, 2, 0);
  8564. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8565. var trip = dtSource.Rows[i]["Trip"].ToString();
  8566. builder.MoveToCell(0, i + 1, 3, 0);
  8567. builder.Write(trip);
  8568. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8569. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8570. // 获取特定索引的段落
  8571. Paragraph paragraph = (Paragraph)paragraphs[0];
  8572. Run run = paragraph.Runs[0];
  8573. Aspose.Words.Font font = run.Font;
  8574. font.Name = "黑体";
  8575. //设置双休红色
  8576. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8577. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8578. paragraph = (Paragraph)paragraphs[1];
  8579. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8580. {
  8581. run = paragraph.Runs[0];
  8582. font = run.Font;
  8583. font.Color = Color.Red;
  8584. }
  8585. }
  8586. }
  8587. catch (Exception ex)
  8588. {
  8589. }
  8590. //删除多余行
  8591. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8592. {
  8593. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8594. }
  8595. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8596. if (!Directory.Exists(savePath))
  8597. {
  8598. try
  8599. {
  8600. Directory.CreateDirectory(savePath);
  8601. }
  8602. catch
  8603. {
  8604. }
  8605. }
  8606. string path = savePath + Find.TeamName + "出访日程";
  8607. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8608. try
  8609. {
  8610. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8611. string postfix = ".docx";
  8612. if (dto.IsPDF == 1)
  8613. {
  8614. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8615. postfix = ".pdf";
  8616. }
  8617. doc.Save(path + postfix, saveFormat);
  8618. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8619. }
  8620. catch (Exception)
  8621. {
  8622. jw = JsonView(false);
  8623. }
  8624. return Ok(jw);
  8625. }
  8626. /// <summary>
  8627. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8628. /// </summary>
  8629. /// <param name="num"></param>
  8630. /// <returns></returns>
  8631. string GetNum(string num)
  8632. {
  8633. string str = "";
  8634. switch (num)
  8635. {
  8636. case "1":
  8637. str = "一";
  8638. break;
  8639. case "2":
  8640. str = "二";
  8641. break;
  8642. case "3":
  8643. str = "三";
  8644. break;
  8645. case "4":
  8646. str = "四";
  8647. break;
  8648. case "5":
  8649. str = "五";
  8650. break;
  8651. case "6":
  8652. str = "六";
  8653. break;
  8654. case "7":
  8655. str = "七";
  8656. break;
  8657. case "8":
  8658. str = "八";
  8659. break;
  8660. case "9":
  8661. str = "九";
  8662. break;
  8663. case "10":
  8664. str = "十";
  8665. break;
  8666. case "11":
  8667. str = "十一";
  8668. break;
  8669. case "12":
  8670. str = "十二";
  8671. break;
  8672. case "一":
  8673. str = "1";
  8674. break;
  8675. case "二":
  8676. str = "2";
  8677. break;
  8678. case "三":
  8679. str = "3";
  8680. break;
  8681. case "四":
  8682. str = "4";
  8683. break;
  8684. case "五":
  8685. str = "5";
  8686. break;
  8687. case "六":
  8688. str = "6";
  8689. break;
  8690. case "七":
  8691. str = "7";
  8692. break;
  8693. case "八":
  8694. str = "8";
  8695. break;
  8696. case "九":
  8697. str = "9";
  8698. break;
  8699. case "十":
  8700. str = "10";
  8701. break;
  8702. case "十一":
  8703. str = "11";
  8704. break;
  8705. case "十二":
  8706. str = "12";
  8707. break;
  8708. }
  8709. return str;
  8710. }
  8711. #endregion
  8712. #endregion
  8713. #region 团组成本
  8714. /// <summary>
  8715. /// 团组成本数据初始化
  8716. /// </summary>
  8717. /// <param name="dto"></param>
  8718. /// <returns></returns>
  8719. [HttpPost]
  8720. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8721. {
  8722. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8723. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8724. WHEN COUNT(*) >= 0 THEN 'True'
  8725. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8726. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8727. ").ToList(); //团组列表
  8728. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8729. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8730. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8731. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8732. if (groupinfoValue != null)
  8733. {
  8734. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8735. var spArr = new string[1] { countryArr };
  8736. if (countryArr.Contains("|"))
  8737. {
  8738. spArr = countryArr.Split("|");
  8739. }
  8740. else if (countryArr.Contains("、"))
  8741. {
  8742. spArr = countryArr.Split("、");
  8743. }
  8744. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8745. {
  8746. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8747. if (dbQueryCountry != null)
  8748. {
  8749. visaCountryInfoArr.Add(dbQueryCountry);
  8750. }
  8751. }
  8752. }
  8753. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8754. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8755. var create = _GroupCostRepository.
  8756. CreateGroupCostByBlackCode(dto.Diid);
  8757. if (groupCost.Count == 0 && create.Code == 0)
  8758. {
  8759. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8760. }
  8761. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8762. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8763. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8764. groupCostMap = groupCostMap.Select(x =>
  8765. {
  8766. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8767. {
  8768. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8769. }
  8770. return x;
  8771. }).ToList();
  8772. //GroupCostParameter.Add(new
  8773. // Grp_GroupCostParameter());
  8774. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8775. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8776. return Ok(JsonView(new
  8777. {
  8778. groupList,
  8779. groupInfo,
  8780. groupChecks,
  8781. groupCost = groupCostMap,
  8782. hotelNumber,
  8783. GroupCostParameter = GroupCostParameterMap,
  8784. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8785. {
  8786. x.VisaCountry,
  8787. x.VisaPrice,
  8788. x.Id,
  8789. }).ToList(),
  8790. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8791. blackCodeIsTrue = create.Code == 0 ? true : false,
  8792. hotelIsTrue = hotelIsTrue,
  8793. }));
  8794. }
  8795. /// <summary>
  8796. /// 团组成本信息保存
  8797. /// </summary>
  8798. /// <param name="dto"></param>
  8799. /// <returns></returns>
  8800. [HttpPost]
  8801. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8802. {
  8803. if (dto.Diid <= 0 || dto.Userid <= 0)
  8804. {
  8805. return Ok(JsonView(false));
  8806. }
  8807. JsonView jw = null;
  8808. bool isTrue = false;
  8809. #region 复制团组成本
  8810. //if (dto.Diid == 2581)
  8811. //{
  8812. // dto.Diid = 2599;
  8813. // dto.CheckBoxs.ForEach(x =>
  8814. // {
  8815. // x.Diid = 2599;
  8816. // });
  8817. // dto.GroupCosts.ForEach(x =>
  8818. // {
  8819. // x.Diid = 2599;
  8820. // });
  8821. // dto.CostTypeHotelNumbers.ForEach(x =>
  8822. // {
  8823. // x.Diid = 2599;
  8824. // });
  8825. // dto.GroupCostParameters.ForEach(x =>
  8826. // {
  8827. // x.DiId = 2599;
  8828. // });
  8829. //}
  8830. #endregion
  8831. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8832. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8833. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8834. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8835. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8836. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8837. try
  8838. {
  8839. _sqlSugar.BeginTran();
  8840. isTrue = await _GroupCostRepository.
  8841. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8842. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8843. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8844. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8845. _sqlSugar.CommitTran();
  8846. jw = JsonView(true, "保存成功!", isTrue);
  8847. }
  8848. catch (Exception)
  8849. {
  8850. _sqlSugar.RollbackTran();
  8851. jw = JsonView(false);
  8852. }
  8853. return Ok(jw);
  8854. }
  8855. /// <summary>
  8856. /// 司兼导数据
  8857. /// </summary>
  8858. /// <param name="dto"></param>
  8859. /// <returns></returns>
  8860. [HttpPost]
  8861. public IActionResult GetCarGuides(CarGuidesDto dto)
  8862. {
  8863. JsonView jw = null;
  8864. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8865. jw = JsonView(true, "获取成功!", Data);
  8866. return Ok(jw);
  8867. }
  8868. /// <summary>
  8869. /// 导游数据
  8870. /// </summary>
  8871. /// <param name="dto"></param>
  8872. /// <returns></returns>
  8873. [HttpPost]
  8874. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8875. {
  8876. JsonView jw = null;
  8877. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8878. // 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
  8879. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8880. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8881. jw = JsonView(true, "获取成功!", Data);
  8882. return Ok(jw);
  8883. }
  8884. /// <summary>
  8885. /// 成本车数据
  8886. /// </summary>
  8887. /// <param name="dto"></param>
  8888. /// <returns></returns>
  8889. [HttpPost]
  8890. public IActionResult GetCarInfo(CarGuidesDto dto)
  8891. {
  8892. JsonView jw = null;
  8893. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8894. jw = JsonView(true, "获取成功!", Data);
  8895. return Ok(jw);
  8896. }
  8897. /// <summary>
  8898. /// 景点数据
  8899. /// </summary>
  8900. /// <param name="dto"></param>
  8901. /// <returns></returns>
  8902. [HttpPost]
  8903. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8904. {
  8905. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8906. return Ok(JsonView(true, "获取成功!", Data));
  8907. }
  8908. /// <summary>
  8909. /// 成本通知
  8910. /// </summary>
  8911. /// <param name="dto"></param>
  8912. /// <returns></returns>
  8913. [HttpPost]
  8914. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8915. {
  8916. if (dto.Diid < 0)
  8917. {
  8918. return Ok(JsonView(false));
  8919. }
  8920. JsonView jw = null;
  8921. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8922. if (GroupCostParameter != null)
  8923. {
  8924. int IsShare = 0;
  8925. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8926. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8927. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8928. string msg = string.Empty;
  8929. if (isTrue)
  8930. {
  8931. if (IsShare == 0)
  8932. {
  8933. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8934. }
  8935. else
  8936. {
  8937. #region 企微通知对应岗位用户
  8938. try
  8939. {
  8940. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8941. }
  8942. catch (Exception ex)
  8943. {
  8944. }
  8945. #endregion
  8946. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8947. }
  8948. jw = JsonView(isTrue, msg, new { IsShare });
  8949. }
  8950. else
  8951. {
  8952. msg = "修改失败!";
  8953. jw = JsonView(isTrue, msg);
  8954. }
  8955. }
  8956. else
  8957. {
  8958. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8959. }
  8960. return Ok(jw);
  8961. }
  8962. /// <summary>
  8963. /// 导出报价单
  8964. /// </summary>
  8965. /// <param name="dto"></param>
  8966. /// <returns></returns>
  8967. [HttpPost]
  8968. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8969. {
  8970. if (dto.Diid == 0)
  8971. {
  8972. return Ok(JsonView(false, "请传递团组id"));
  8973. }
  8974. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8975. if (deleInfo.Code != 0)
  8976. {
  8977. return Ok(JsonView(false, "团组信息查询失败!"));
  8978. }
  8979. var di = deleInfo.Data as DelegationInfoWebView;
  8980. if (di != null)
  8981. {
  8982. di.TeamName = di.TeamName.Replace("|", "、");
  8983. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8984. //文件名
  8985. string strFileName = di.TeamName + "-收款账单.doc";
  8986. //获取模板
  8987. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8988. //载入模板
  8989. Document doc = new Document(tmppath);
  8990. decimal TotalPrice = 0.00M;
  8991. string itemStr = string.Empty;
  8992. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8993. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8994. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8995. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8996. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8997. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8998. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8999. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  9000. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  9001. foreach (var cost in groupCostType)
  9002. {
  9003. var List = cost.ToList();
  9004. if (cost.Key == "A")
  9005. {
  9006. foreach (var ListItem in List)
  9007. {
  9008. if (ListItem.number > 0)
  9009. {
  9010. if (ListItem.code.Contains("TBR"))
  9011. {
  9012. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9013. }
  9014. else
  9015. {
  9016. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9017. }
  9018. TotalPrice += (ListItem.number * ListItem.price);
  9019. }
  9020. }
  9021. }
  9022. else
  9023. {
  9024. itemStr = itemStr.Insert(0, "A段\r\n");
  9025. itemStr += "B段\r\n";
  9026. foreach (var ListItem in List)
  9027. {
  9028. if (ListItem.number > 0)
  9029. {
  9030. if (ListItem.code.Contains("TBR"))
  9031. {
  9032. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9033. }
  9034. else
  9035. {
  9036. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9037. }
  9038. TotalPrice += (ListItem.number * ListItem.price);
  9039. }
  9040. }
  9041. }
  9042. }
  9043. #region 替换Word模板书签内容
  9044. Dictionary<string, string> marks = new Dictionary<string, string>();
  9045. marks.Add("To", di.ClientUnit);//付款方
  9046. marks.Add("ToTel", di.TellPhone);//付款方电话
  9047. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  9048. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  9049. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  9050. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  9051. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  9052. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  9053. marks.Add("PayItemContent", itemStr);//详细信息
  9054. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  9055. #endregion
  9056. ////注
  9057. //if (doc.Range.Bookmarks["Attention"] != null)
  9058. //{
  9059. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  9060. // mark.Text = frList[0].Attention;
  9061. //}
  9062. foreach (var item in marks.Keys)
  9063. {
  9064. if (doc.Range.Bookmarks[item] != null)
  9065. {
  9066. Bookmark mark = doc.Range.Bookmarks[item];
  9067. mark.Text = marks[item];
  9068. }
  9069. }
  9070. byte[] bytes = null;
  9071. using (MemoryStream stream = new MemoryStream())
  9072. {
  9073. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9074. bytes = stream.ToArray();
  9075. }
  9076. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9077. return Ok(JsonView(true, "", new
  9078. {
  9079. Data = bytes,
  9080. strFileName,
  9081. }));
  9082. }
  9083. else
  9084. {
  9085. return Ok(JsonView(false, "团组信息不存在!"));
  9086. }
  9087. }
  9088. /// <summary>
  9089. /// 导出团组成本
  9090. /// </summary>
  9091. /// <param name="dto"></param>
  9092. /// <returns></returns>
  9093. [HttpPost]
  9094. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9095. {
  9096. var jw = JsonView(false);
  9097. if (dto.Diid == 0)
  9098. {
  9099. return Ok(JsonView(false, "请传递团组id"));
  9100. }
  9101. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9102. if (deleInfo.Code != 0)
  9103. {
  9104. return Ok(JsonView(false, "团组信息查询失败!"));
  9105. }
  9106. var di = deleInfo.Data as DelegationInfoWebView;
  9107. if (di == null)
  9108. {
  9109. return Ok(JsonView(false, "团组信息查询失败!"));
  9110. }
  9111. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9112. WorkbookDesigner designer = new WorkbookDesigner();
  9113. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9114. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9115. for (int i = 0; i < List_GC.Count; i++)
  9116. {
  9117. GroupCost_Excel gc = new GroupCost_Excel();
  9118. gc.Id = List_GC[i].Id;
  9119. gc.Diid = List_GC[i].Diid.ToString();
  9120. gc.DAY = List_GC[i].DAY;
  9121. string week = "";
  9122. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9123. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9124. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9125. gc.ITIN = List_GC[i].ITIN;
  9126. gc.CarType = List_GC[i].CarType;
  9127. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9128. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9129. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9130. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9131. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9132. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9133. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9134. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9135. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9136. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9137. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9138. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9139. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9140. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9141. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9142. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9143. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9144. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9145. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9146. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9147. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9148. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9149. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9150. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9151. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9152. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9153. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9154. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9155. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9156. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9157. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9158. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9159. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9160. List_GC1.Add(gc);
  9161. }
  9162. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9163. dt.TableName = "TB";
  9164. //报表标题等不用dt的值
  9165. designer.SetDataSource("TeamName", dto.title.TeamName);
  9166. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9167. designer.SetDataSource("Tax", dto.title.Tax);
  9168. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9169. designer.SetDataSource("Currency", dto.title.Currency);
  9170. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9171. designer.SetDataSource("Rate", dto.title.Rate);
  9172. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9173. var Aparams = hotels.Find(x => x.Type == "Default");
  9174. if (Aparams == null)
  9175. {
  9176. return Ok(jw);
  9177. }
  9178. //酒店数量
  9179. var txtSGRNumber = Aparams.SGR.ToString();
  9180. var txtTBRNumber = Aparams.TBR.ToString();
  9181. var txtJSESNumber = Aparams.JSES.ToString();
  9182. var txtSUITENumbe = Aparams.SUITE.ToString();
  9183. if (dto.costType == "B")
  9184. {
  9185. Aparams = hotels.Find(x => x.Type == "A");
  9186. var Bparams = hotels.Find(x => x.Type == "B");
  9187. if (Aparams == null || Bparams == null)
  9188. {
  9189. return Ok(jw);
  9190. }
  9191. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9192. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9193. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9194. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9195. }
  9196. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9197. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9198. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9199. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9200. var ws = designer.Workbook.Worksheets[0];
  9201. int Row = List_GC.Count;
  9202. int startIndex = 11;
  9203. int HideRows = 0;
  9204. List<int> hideRowsList = new List<int>();
  9205. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9206. #region A段left数据
  9207. var left = dto.leftInfo.Find(x => x.Type == "A");
  9208. if (left == null)
  9209. {
  9210. return Ok(jw);
  9211. }
  9212. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9213. if (leftBindData != null)
  9214. {
  9215. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9216. designer.SetDataSource("VisaRS", leftBindData.rs);
  9217. designer.SetDataSource("VisaXS", leftBindData.xs);
  9218. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9219. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9220. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9221. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9222. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9223. }
  9224. else
  9225. {
  9226. hideRowsList.Add(Row + startIndex + HideRows);
  9227. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9228. }
  9229. HideRows += 2;
  9230. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9231. if (leftBindData != null)
  9232. {
  9233. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9234. designer.SetDataSource("BXRS", leftBindData.rs);
  9235. designer.SetDataSource("BXXS", leftBindData.xs);
  9236. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9237. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9238. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9239. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9240. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9241. }
  9242. else
  9243. {
  9244. hideRowsList.Add(Row + startIndex + HideRows);
  9245. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9246. }
  9247. HideRows += 2;
  9248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9249. if (leftBindData != null)
  9250. {
  9251. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9252. designer.SetDataSource("HSRS", leftBindData.rs);
  9253. designer.SetDataSource("HSXS", leftBindData.xs);
  9254. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9255. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9256. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9257. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9258. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9259. }
  9260. else
  9261. {
  9262. hideRowsList.Add(Row + startIndex + HideRows);
  9263. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9264. }
  9265. HideRows += 2;
  9266. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9267. if (leftBindData != null)
  9268. {
  9269. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9270. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9271. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9272. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9273. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9274. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9275. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9276. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9277. }
  9278. else
  9279. {
  9280. hideRowsList.Add(Row + startIndex + HideRows);
  9281. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9282. }
  9283. HideRows += 2;
  9284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9285. if (leftBindData != null)
  9286. {
  9287. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9288. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9289. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9290. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9291. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9292. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9293. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9294. designer.SetDataSource("JPGWCZLR", ((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("头等舱"));
  9303. if (leftBindData != null)
  9304. {
  9305. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9306. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9307. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9308. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9309. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9310. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9311. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9312. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9313. }
  9314. else
  9315. {
  9316. hideRowsList.Add(Row + startIndex + HideRows);
  9317. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9318. }
  9319. HideRows += 2;
  9320. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9321. if (leftBindData != null)
  9322. {
  9323. ////TBR
  9324. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9325. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9326. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9327. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9328. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9329. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9330. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9331. designer.SetDataSource("HotelTBRZLR", ((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("SGR"));
  9340. if (leftBindData != null)
  9341. {
  9342. ////SGR
  9343. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9344. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9345. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9346. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9347. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9348. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9349. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9350. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9351. }
  9352. else
  9353. {
  9354. hideRowsList.Add(Row + startIndex + HideRows);
  9355. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9356. }
  9357. HideRows += 2;
  9358. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9359. if (leftBindData != null)
  9360. {
  9361. ////JS/ES
  9362. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9363. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9364. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9365. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9366. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9367. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9368. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9369. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9370. }
  9371. else
  9372. {
  9373. hideRowsList.Add(Row + startIndex + HideRows);
  9374. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9375. }
  9376. HideRows += 2;
  9377. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9378. if (leftBindData != null)
  9379. {
  9380. ////SUITE
  9381. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9382. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9383. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9384. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9385. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9386. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9387. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9388. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9389. }
  9390. else
  9391. {
  9392. hideRowsList.Add(Row + startIndex + HideRows);
  9393. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9394. }
  9395. HideRows += 2;
  9396. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9397. if (leftBindData != null)
  9398. {
  9399. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9400. designer.SetDataSource("DJRS", leftBindData.rs);
  9401. designer.SetDataSource("DJXS", leftBindData.xs);
  9402. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9403. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9404. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9405. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9406. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9407. }
  9408. else
  9409. {
  9410. hideRowsList.Add(Row + startIndex + HideRows);
  9411. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9412. }
  9413. HideRows += 2;
  9414. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9415. if (leftBindData != null)
  9416. {
  9417. designer.SetDataSource("HCPCB", leftBindData.cb);
  9418. designer.SetDataSource("HCPRS", leftBindData.rs);
  9419. designer.SetDataSource("HCPXS", leftBindData.xs);
  9420. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9421. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9422. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9423. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9424. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9425. }
  9426. else
  9427. {
  9428. hideRowsList.Add(Row + startIndex + HideRows);
  9429. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9430. }
  9431. HideRows += 2;
  9432. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9433. if (leftBindData != null)
  9434. {
  9435. designer.SetDataSource("CPCB", leftBindData.cb);
  9436. designer.SetDataSource("CPRS", leftBindData.rs);
  9437. designer.SetDataSource("CPXS", leftBindData.xs);
  9438. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9439. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9440. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9441. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9442. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9443. }
  9444. else
  9445. {
  9446. hideRowsList.Add(Row + startIndex + HideRows);
  9447. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9448. }
  9449. HideRows += 2;
  9450. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9451. if (leftBindData != null)
  9452. {
  9453. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9454. designer.SetDataSource("GWRS", leftBindData.rs);
  9455. designer.SetDataSource("GWXS", leftBindData.xs);
  9456. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9457. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9458. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9459. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9460. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9461. }
  9462. else
  9463. {
  9464. hideRowsList.Add(Row + startIndex + HideRows);
  9465. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9466. }
  9467. HideRows += 2;
  9468. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9469. if (leftBindData != null)
  9470. {
  9471. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9472. designer.SetDataSource("LYJRS", leftBindData.rs);
  9473. designer.SetDataSource("LYJXS", leftBindData.xs);
  9474. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9475. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9476. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9477. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9478. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9479. }
  9480. else
  9481. {
  9482. hideRowsList.Add(Row + startIndex + HideRows);
  9483. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9484. }
  9485. #endregion
  9486. #region A段Right信息
  9487. var right = dto.rightInfo.Find(x => x.Type == "A");
  9488. if (right == null)
  9489. {
  9490. return Ok(jw);
  9491. }
  9492. HideRows += 4;
  9493. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9494. if (rightBindData != null)
  9495. {
  9496. //经济舱 + 双人间 TBR
  9497. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9498. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9499. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9500. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9501. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9502. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9503. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9504. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9505. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9506. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9507. }
  9508. else
  9509. {
  9510. hideRowsList.Add(Row + startIndex + HideRows);
  9511. }
  9512. HideRows += 2;
  9513. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9514. if (rightBindData != null)
  9515. {
  9516. //经济舱 + 单人间 SGR
  9517. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9518. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9519. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9520. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9521. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9522. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9523. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9524. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9525. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9526. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9527. }
  9528. else
  9529. {
  9530. hideRowsList.Add(Row + startIndex + HideRows);
  9531. }
  9532. HideRows += 2;
  9533. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9534. if (rightBindData != null)
  9535. {
  9536. //公务舱 + 单人间 SGR
  9537. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9538. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9539. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9540. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9541. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9542. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9543. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9544. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9545. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9546. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9547. }
  9548. else
  9549. {
  9550. hideRowsList.Add(Row + startIndex + HideRows);
  9551. }
  9552. HideRows += 2;
  9553. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9554. if (rightBindData != null)
  9555. {
  9556. //公务舱 + 小套房 JSES
  9557. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9558. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9559. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9560. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9561. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9562. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9563. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9564. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9565. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9566. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9567. }
  9568. else
  9569. {
  9570. hideRowsList.Add(Row + startIndex + HideRows);
  9571. }
  9572. HideRows += 2;
  9573. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9574. if (rightBindData != null)
  9575. {
  9576. //公务舱 + 小套房 JSES
  9577. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9578. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9579. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9580. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9581. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9582. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9583. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9584. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9585. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9586. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9587. }
  9588. else
  9589. {
  9590. hideRowsList.Add(Row + startIndex + HideRows);
  9591. }
  9592. HideRows += 2;
  9593. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9594. if (rightBindData != null)
  9595. {
  9596. //经济舱 + 大套房
  9597. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9598. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9599. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9600. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9601. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9602. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9603. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9604. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9605. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9606. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9607. }
  9608. else
  9609. {
  9610. hideRowsList.Add(Row + startIndex + HideRows);
  9611. }
  9612. HideRows += 2;
  9613. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9614. if (rightBindData != null)
  9615. {
  9616. //头等舱 + 小套房 JSES
  9617. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9618. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9619. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9620. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9621. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9622. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9623. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9624. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9625. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9626. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9627. }
  9628. else
  9629. {
  9630. hideRowsList.Add(Row + startIndex + HideRows);
  9631. }
  9632. HideRows += 2;
  9633. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9634. if (rightBindData != null)
  9635. {
  9636. //头等舱 + 大套房
  9637. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9638. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9639. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9640. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9641. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9642. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9643. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9644. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9645. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9646. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9647. }
  9648. else
  9649. {
  9650. hideRowsList.Add(Row + startIndex + HideRows);
  9651. }
  9652. #endregion
  9653. #region B段标题清空
  9654. designer.SetDataSource("CostBDRCB", "");
  9655. designer.SetDataSource("CostBRS", "");
  9656. designer.SetDataSource("CostBXS", "");
  9657. designer.SetDataSource("CostBZCB", "");
  9658. designer.SetDataSource("CostBDRBJ", "");
  9659. designer.SetDataSource("CostBZBJ", "");
  9660. designer.SetDataSource("CostBDRLR", "");
  9661. designer.SetDataSource("CostBZLR", "");
  9662. designer.SetDataSource("CostBDRCBOM", "");
  9663. designer.SetDataSource("CostBRSOM", "");
  9664. designer.SetDataSource("CostBZCBOM", "");
  9665. designer.SetDataSource("CostBDRBJOM", "");
  9666. designer.SetDataSource("CostBZBJOM", "");
  9667. designer.SetDataSource("CostBDRLROM", "");
  9668. designer.SetDataSource("CostBZLROM", "");
  9669. #endregion
  9670. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9671. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9672. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9673. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9674. designer.SetDataSource("DJName", "地接(CNY)");
  9675. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9676. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9677. designer.SetDataSource("GWName", "公务(CNY)");
  9678. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9679. designer.SetDataSource("LYJName", "零用金(CNY)");
  9680. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9681. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9682. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9683. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9684. designer.SetDataSource("BXName", "保险(CNY)");
  9685. designer.SetDataSource("VisaName", "签证(CNY)");
  9686. #region B段基本数据
  9687. if (dto.costType == "B")
  9688. {
  9689. left = dto.leftInfo.Find(x => x.Type == "B");
  9690. if (left == null)
  9691. {
  9692. return Ok(jw);
  9693. }
  9694. #region B段left数据
  9695. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9696. if (leftBindData != null)
  9697. {
  9698. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9699. designer.SetDataSource("BHSRS", leftBindData.rs);
  9700. designer.SetDataSource("BHSXS", leftBindData.xs);
  9701. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9702. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9703. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9704. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9705. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9706. }
  9707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9708. if (leftBindData != null)
  9709. {
  9710. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9711. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9712. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9713. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9714. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9715. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9716. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9717. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9718. }
  9719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9720. if (leftBindData != null)
  9721. {
  9722. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9723. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9724. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9725. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9726. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9727. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9728. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9729. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9730. }
  9731. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9732. if (leftBindData != null)
  9733. {
  9734. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9735. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9736. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9737. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9738. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9739. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9740. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9741. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9742. }
  9743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9744. if (leftBindData != null)
  9745. {
  9746. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9747. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9748. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9749. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9750. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9751. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9752. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9753. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9754. }
  9755. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9756. if (leftBindData != null)
  9757. {
  9758. designer.SetDataSource("BCPCB", leftBindData.cb);
  9759. designer.SetDataSource("BCPRS", leftBindData.rs);
  9760. designer.SetDataSource("BCPXS", leftBindData.xs);
  9761. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9762. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9763. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9764. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9765. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9766. }
  9767. //TBR
  9768. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9769. if (leftBindData != null)
  9770. {
  9771. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9772. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9773. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9774. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9775. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9776. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9777. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9778. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9779. }
  9780. //SGR
  9781. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9782. if (leftBindData != null)
  9783. {
  9784. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9785. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9786. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9787. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9788. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9789. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9790. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9791. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9792. }
  9793. //JS/ES
  9794. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9795. if (leftBindData != null)
  9796. {
  9797. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9798. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9799. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9800. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9801. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9802. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9803. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9804. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9805. }
  9806. //SUITE
  9807. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9808. if (leftBindData != null)
  9809. {
  9810. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9811. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9812. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9813. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9814. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9815. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9816. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9817. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9818. }
  9819. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9820. if (leftBindData != null)
  9821. {
  9822. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  9823. designer.SetDataSource("BDJRS", leftBindData.rs);
  9824. designer.SetDataSource("BDJXS", leftBindData.xs);
  9825. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9826. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9827. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9828. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9829. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9830. }
  9831. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9832. if (leftBindData != null)
  9833. {
  9834. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  9835. designer.SetDataSource("BGWRS", leftBindData.rs);
  9836. designer.SetDataSource("BGWXS", leftBindData.xs);
  9837. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9838. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9839. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9840. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9841. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9842. }
  9843. #region 优化方案
  9844. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9845. //excelBind.Add("零用金", new {
  9846. //cb="",
  9847. //rs="",
  9848. //xs ="",
  9849. //zcb = "",
  9850. //});
  9851. #endregion
  9852. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9853. if (leftBindData != null)
  9854. {
  9855. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9856. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9857. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9858. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9859. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9860. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9861. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9862. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9863. }
  9864. #endregion
  9865. #region B段Right信息
  9866. right = dto.rightInfo.Find(x => x.Type == "B");
  9867. if (right == null)
  9868. {
  9869. return Ok(jw);
  9870. }
  9871. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9872. if (rightBindData != null)
  9873. {
  9874. //经济舱 + 双人间 TBR
  9875. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9876. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9877. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9878. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9879. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9880. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9881. designer.SetDataSource("BlblJJCTBRZLR", (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("经济舱 SGR"));
  9887. if (rightBindData != null)
  9888. {
  9889. //经济舱 + 单人间 SGR
  9890. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9891. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9892. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9893. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9894. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9895. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9896. designer.SetDataSource("BlblJJCSGRZLR", (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("公务舱 SGR"));
  9902. if (rightBindData != null)
  9903. {
  9904. //公务舱 + 单人间 SGR
  9905. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9906. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9907. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9908. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9909. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9910. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9911. designer.SetDataSource("BlblGWCSGRZLR", (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. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9917. if (rightBindData != null)
  9918. {
  9919. //公务舱 + 小套房 JSES
  9920. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9921. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9922. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9923. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9924. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9925. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9926. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9927. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9928. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9929. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9930. }
  9931. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9932. if (rightBindData != null)
  9933. {
  9934. //公务舱 + 小套房 JSES
  9935. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9936. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9937. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9938. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9939. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9940. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9941. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9942. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9943. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9944. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9945. }
  9946. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9947. if (rightBindData != null)
  9948. {
  9949. //经济舱 + 大套房
  9950. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9951. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9952. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9953. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9954. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9955. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9956. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9957. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9958. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9959. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9960. }
  9961. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9962. if (rightBindData != null)
  9963. {
  9964. //头等舱 + 小套房 JSES
  9965. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9966. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9967. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9968. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9969. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9970. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9971. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9972. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9973. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9974. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9975. }
  9976. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9977. if (rightBindData != null)
  9978. {
  9979. //头等舱 + 大套房
  9980. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9981. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9982. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9983. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9984. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9985. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9986. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9987. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9988. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9989. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9990. }
  9991. #endregion
  9992. #region 标题
  9993. designer.SetDataSource("CostBDRCB", "单人成本");
  9994. designer.SetDataSource("CostBRS", "人数");
  9995. designer.SetDataSource("CostBXS", "系数");
  9996. designer.SetDataSource("CostBZCB", "总成本");
  9997. designer.SetDataSource("CostBDRBJ", "单人报价");
  9998. designer.SetDataSource("CostBZBJ", "总报价");
  9999. designer.SetDataSource("CostBDRLR", "单人利润");
  10000. designer.SetDataSource("CostBZLR", "总利润");
  10001. designer.SetDataSource("CostBDRCBOM", "单人成本");
  10002. designer.SetDataSource("CostBRSOM", "人数");
  10003. designer.SetDataSource("CostBZCBOM", "总成本");
  10004. designer.SetDataSource("CostBDRBJOM", "单人报价");
  10005. designer.SetDataSource("CostBZBJOM", "总报价");
  10006. designer.SetDataSource("CostBDRLROM", "单人利润");
  10007. designer.SetDataSource("CostBZLROM", "总利润");
  10008. #endregion
  10009. }
  10010. #endregion
  10011. designer.SetDataSource("TzZCB2", TzZCB2);
  10012. designer.SetDataSource("TzZBJ2", TzZBJ2);
  10013. designer.SetDataSource("TzZLR2", TzZLR2);
  10014. string[] dataSourceKeys = new string[]
  10015. {
  10016. "VF",
  10017. "TGS",
  10018. "TGOF",
  10019. "TGM",
  10020. "TGA",
  10021. "TGTF",
  10022. "TGEF",
  10023. "CFM",
  10024. "CFOF",
  10025. "B",
  10026. "L",
  10027. "D",
  10028. "TBR",
  10029. "SGR",
  10030. "JSES",
  10031. "Suite",
  10032. "TV",
  10033. "1L",
  10034. "IF",
  10035. "EF",
  10036. "BRF",
  10037. "TE",
  10038. "TGT",
  10039. "DRVT",
  10040. "PC",
  10041. "TLF",
  10042. "ECT"
  10043. };
  10044. foreach (var item in dataSourceKeys)
  10045. {
  10046. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  10047. if (find != null)
  10048. {
  10049. designer.SetDataSource(item, find.text);
  10050. }
  10051. else
  10052. {
  10053. designer.SetDataSource(item, 0);
  10054. }
  10055. }
  10056. designer.SetDataSource(dt);
  10057. //根据数据源处理生成报表内容
  10058. designer.Process();
  10059. designer.Workbook.Worksheets[0].Name = "清单";
  10060. Worksheet sheet = designer.Workbook.Worksheets[0];
  10061. foreach (var Rowindex in hideRowsList)
  10062. {
  10063. ws.Cells.HideRows(Rowindex, 2);
  10064. }
  10065. byte[] bytes = null;
  10066. string strFileName = di.TeamName + "-团组-成本.xls";
  10067. using (MemoryStream stream = new MemoryStream())
  10068. {
  10069. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  10070. bytes = stream.ToArray();
  10071. }
  10072. return Ok(JsonView(true, "", new
  10073. {
  10074. Data = bytes,
  10075. strFileName,
  10076. }));
  10077. }
  10078. /// <summary>
  10079. /// 导出客户报表
  10080. /// </summary>
  10081. /// <returns></returns>
  10082. [HttpPost]
  10083. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10084. {
  10085. var jw = JsonView(false);
  10086. if (dto.Diid == 0)
  10087. {
  10088. return Ok(JsonView(false, "请传递团组id"));
  10089. }
  10090. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10091. if (deleInfo.Code != 0)
  10092. {
  10093. return Ok(JsonView(false, "团组信息查询失败!"));
  10094. }
  10095. var di = deleInfo.Data as DelegationInfoWebView;
  10096. if (di == null)
  10097. {
  10098. return Ok(JsonView(false, "团组信息查询失败!"));
  10099. }
  10100. //文件名
  10101. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10102. //获取模板
  10103. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10104. //载入模板
  10105. Document doc = new Document(tmppath);
  10106. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10107. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10108. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10109. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10110. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10111. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10112. if (AParameter == null)
  10113. {
  10114. return Ok(JsonView(false, "系数不存在!"));
  10115. }
  10116. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10117. , TzAirDesc, TzZCost;
  10118. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10119. = TzAirDesc = TzZCost = string.Empty;
  10120. TzNumber = AParameter.CostTypenumber.ToString();
  10121. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10122. CarGuides1 = dto.CarGuides1;
  10123. Meal = dto.Meal;
  10124. SubsidizedMeals = dto.SubsidizedMeals;
  10125. NightRepair = dto.NightRepair;
  10126. AttractionsTickets = dto.AttractionsTickets;
  10127. MiscellaneousFees = dto.MiscellaneousFees;
  10128. ATip = dto.ATip;
  10129. TzHotelDesc = "";
  10130. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10131. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10132. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10133. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10134. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10135. TzAirDesc = "";
  10136. TzZCost = dto.TzZCost;
  10137. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10138. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10139. var index = 1;
  10140. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10141. foreach (var item in TzHotelDescArr)
  10142. {
  10143. if (AinfoArr != null)
  10144. {
  10145. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10146. if (Ainfo != null)
  10147. {
  10148. if (int.Parse(Ainfo.rs) <= 0)
  10149. {
  10150. continue;
  10151. }
  10152. var hotelText = string.Empty;
  10153. switch (item)
  10154. {
  10155. case "SGR":
  10156. hotelText = "单人间";
  10157. break;
  10158. case "JSES":
  10159. hotelText = "小套房";
  10160. break;
  10161. case "SUITE":
  10162. hotelText = "套房";
  10163. break;
  10164. case "TBR":
  10165. hotelText = "双人间";
  10166. break;
  10167. }
  10168. if (item != "TBR")
  10169. {
  10170. 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";
  10171. }
  10172. else
  10173. {
  10174. 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";
  10175. }
  10176. index++;
  10177. }
  10178. }
  10179. }
  10180. index = 1;
  10181. foreach (var item in TzAirDescArr)
  10182. {
  10183. if (AinfoArr != null)
  10184. {
  10185. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10186. if (Ainfo != null)
  10187. {
  10188. if (int.Parse(Ainfo.rs) <= 0)
  10189. {
  10190. continue;
  10191. }
  10192. 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";
  10193. index++;
  10194. }
  10195. }
  10196. }
  10197. if (dto.costType == "B")
  10198. {
  10199. if (BParameter == null)
  10200. {
  10201. return Ok(JsonView(false, "B段系数不存在!"));
  10202. }
  10203. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10204. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10205. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10206. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10207. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10208. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10209. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10210. foreach (var item in TzHotelDescArr)
  10211. {
  10212. if (AinfoArr != null)
  10213. {
  10214. TzHotelDesc += "B段信息 \r\n";
  10215. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10216. if (Ainfo != null)
  10217. {
  10218. if (int.Parse(Ainfo.rs) <= 0)
  10219. {
  10220. continue;
  10221. }
  10222. var hotelText = string.Empty;
  10223. switch (item)
  10224. {
  10225. case "SGR":
  10226. hotelText = "单人间";
  10227. break;
  10228. case "JSES":
  10229. hotelText = "小套房";
  10230. break;
  10231. case "SUITE":
  10232. hotelText = "套房";
  10233. break;
  10234. case "TBR":
  10235. hotelText = "双人间";
  10236. break;
  10237. }
  10238. if (item != "TBR")
  10239. {
  10240. 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";
  10241. }
  10242. else
  10243. {
  10244. 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";
  10245. }
  10246. index++;
  10247. }
  10248. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10249. }
  10250. }
  10251. index = 1;
  10252. foreach (var item in TzAirDescArr)
  10253. {
  10254. if (AinfoArr != null)
  10255. {
  10256. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10257. if (Ainfo != null)
  10258. {
  10259. if (int.Parse(Ainfo.rs) <= 0)
  10260. {
  10261. continue;
  10262. }
  10263. 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";
  10264. index++;
  10265. }
  10266. }
  10267. }
  10268. }
  10269. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10270. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10271. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10272. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10273. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10274. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10275. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10276. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10277. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10278. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10279. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10280. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10281. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10282. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10283. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10284. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10285. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10286. DickeyValue.Add("TzZCost", TzZCost);
  10287. foreach (var key in DickeyValue.Keys)
  10288. {
  10289. if (doc.Range.Bookmarks[key] != null)
  10290. {
  10291. Bookmark mark = doc.Range.Bookmarks[key];
  10292. mark.Text = DickeyValue[key];
  10293. }
  10294. }
  10295. byte[] bytes = null;
  10296. string strFileName = di.TeamName + "-客户报价.doc";
  10297. using (MemoryStream stream = new MemoryStream())
  10298. {
  10299. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10300. bytes = stream.ToArray();
  10301. }
  10302. return Ok(JsonView(true, "", new
  10303. {
  10304. Data = bytes,
  10305. strFileName,
  10306. }));
  10307. }
  10308. /// <summary>
  10309. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10310. /// </summary>
  10311. /// <param name="dto"></param>
  10312. /// <returns></returns>
  10313. [HttpPost]
  10314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10315. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10316. {
  10317. try
  10318. {
  10319. #region 参数验证
  10320. if (dto.DiId < 0)
  10321. {
  10322. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10323. }
  10324. List<int> cTableIds = new List<int>() {
  10325. 76 ,//酒店预订
  10326. 77 ,//行程
  10327. 79 ,//车/导游地接
  10328. 80 ,//签证
  10329. 81 ,//邀请/公务活
  10330. 82 ,//团组客户保险
  10331. 85 ,//机票预订
  10332. 98 ,//其他款项
  10333. 285 ,//收款退还
  10334. 751 ,//酒店早餐
  10335. 1015 // 超支费用
  10336. };
  10337. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10338. {
  10339. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10340. }
  10341. #endregion
  10342. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10343. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10344. if (_GroupCostParameters.Count <= 0)
  10345. {
  10346. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10347. }
  10348. if (_GroupCostParameters[0].IsShare == 0)
  10349. {
  10350. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10351. }
  10352. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10353. //处理date为空问题
  10354. if (_GroupCosts.Count > 0)
  10355. {
  10356. for (int i = 0; i < _GroupCosts.Count; i++)
  10357. {
  10358. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10359. {
  10360. if (i > 0)
  10361. {
  10362. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10363. }
  10364. }
  10365. }
  10366. }
  10367. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10368. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10369. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10370. string currCode = "";
  10371. #region currCode 验证
  10372. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10373. if (isInt)
  10374. {
  10375. var currData = currDatas.Find(it => it.Id == intCurrency);
  10376. if (currData != null)
  10377. {
  10378. currCode = currData.Name;
  10379. }
  10380. }
  10381. else
  10382. {
  10383. currCode = _GroupCostParameters[0].Currency.Trim();
  10384. }
  10385. #endregion
  10386. //op,酒店单段模式存储
  10387. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10388. {
  10389. CurrencyCode = currCode,
  10390. Rate = _GroupCostParameters[0].Rate,
  10391. CostType = _GroupCostParameters[0].CostType,
  10392. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10393. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10394. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10395. };
  10396. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10397. if (_GroupCostParameters.Count == 2)
  10398. {
  10399. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10400. }
  10401. foreach (var item in _GroupCostParameters)
  10402. {
  10403. decimal _rate = 1;
  10404. decimal _rate1 = item.Rate;
  10405. decimal _scale = 1;
  10406. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10407. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10408. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10409. //if (userInfo != null)
  10410. //{
  10411. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10412. // {
  10413. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10414. // {
  10415. // _scale = 1.00M;
  10416. // }
  10417. // }
  10418. //}
  10419. #endregion
  10420. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10421. {
  10422. CurrencyCode = currCode,
  10423. Rate = _rate1,
  10424. CostType = item.CostType,
  10425. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10426. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10427. CostTypeNumber = item.CostTypenumber
  10428. };
  10429. if (_GroupCostParameters.Count > 1)
  10430. {
  10431. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10432. }
  10433. else
  10434. {
  10435. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10436. }
  10437. if (dto.CTable == 79)//
  10438. {
  10439. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10440. modulePromptInfo.TotalCost = item.DJCB;
  10441. }
  10442. List<string> costTypes = new List<string>() { "A", "B" };
  10443. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10444. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10445. if (_GroupCostsDuplicates.Count() == 1)
  10446. {
  10447. _GroupCostsTypeData = _GroupCosts;
  10448. }
  10449. else
  10450. {
  10451. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10452. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10453. }
  10454. /*
  10455. * 76 酒店预订
  10456. * 77 行程
  10457. * 79 车/导游地接
  10458. * 80 签证
  10459. * 81 邀请/公务活动
  10460. * 82 团组客户保险
  10461. * 85 机票预订
  10462. * 98 其他款项
  10463. * 285 收款退还
  10464. * 751 酒店早餐
  10465. * 1015 超支费用
  10466. */
  10467. switch (dto.CTable)
  10468. {
  10469. case 76: // 酒店预订
  10470. _ModuleSubPromptInfo.AddRange(
  10471. _GroupCostsTypeData.Select(it => new
  10472. {
  10473. it.DAY,
  10474. it.Date,
  10475. it.ACCON,
  10476. it.ITIN,
  10477. it.SGR,
  10478. it.TBR,
  10479. it.JS_ES,
  10480. it.Suite
  10481. })
  10482. );
  10483. break;
  10484. case 79: // 车/导游地接
  10485. _ModuleSubPromptInfo.AddRange(
  10486. _GroupCostsTypeData.Select(it => new
  10487. {
  10488. Date = it.Date, //日期
  10489. CarFee = it.CarCost * _rate * _scale, //车费用
  10490. CarType = it.CarType, //车型
  10491. DriverFee = it.CFS * _rate * _scale, //司机工资
  10492. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10493. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10494. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10495. GuideFee = it.TGS * _rate * _scale, //导游费用
  10496. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10497. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10498. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10499. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10500. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10501. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10502. Breakfast = it.B * _rate * _scale, //早餐费
  10503. Lunch = it.L * _rate * _scale, //午餐费
  10504. Dinner = it.D * _rate * _scale, //晚餐费
  10505. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10506. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10507. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10508. TicketFee = it.EF * _rate * _scale, //门票费
  10509. TicketRemark = it.EFR, //门票费描述
  10510. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10511. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10512. SpentCash = it.PC * _rate * _scale, //零用金
  10513. LeadersFee = it.TLF * _rate * _scale, //领队费
  10514. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10515. })
  10516. );
  10517. break;
  10518. case 85: // 机票
  10519. List<dynamic> datas = new List<dynamic>();
  10520. datas.Add(
  10521. new
  10522. {
  10523. AirType = "经济舱",
  10524. AirNum = item.JJCRS,
  10525. AirDRCB = item.JJCCB,
  10526. AirZCB = (item.JJCRS * item.JJCCB)
  10527. }
  10528. );
  10529. datas.Add(
  10530. new
  10531. {
  10532. AirType = "公务舱",
  10533. AirNum = item.GWCRS,
  10534. AirDRCB = item.GWCCB,
  10535. AirZCB = (item.GWCRS * item.GWCCB)
  10536. }
  10537. );
  10538. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10539. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10540. modulePromptInfo.Data = new
  10541. {
  10542. airFeeData = datas,
  10543. airInitData = initDatas
  10544. };
  10545. _ModulePromptInfos.Add(modulePromptInfo);
  10546. break;
  10547. default:
  10548. break;
  10549. }
  10550. }
  10551. if (dto.CTable != 85)
  10552. {
  10553. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10554. _ModulePromptInfos.Add(_ModulePromptInfo);
  10555. }
  10556. _view.ModulePromptInfos = _ModulePromptInfos;
  10557. return Ok(JsonView(true, "操作成功!", _view));
  10558. }
  10559. catch (Exception ex)
  10560. {
  10561. return Ok(JsonView(false, ex.Message));
  10562. }
  10563. }
  10564. /// <summary>
  10565. /// 根据黑屏代码重新生成行程
  10566. /// </summary>
  10567. /// <param name="dto"></param>
  10568. /// <returns></returns>
  10569. [HttpPost]
  10570. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10571. {
  10572. var jw = JsonView(false);
  10573. var Create = _GroupCostRepository.
  10574. CreateGroupCostByBlackCode(dto.Diid);
  10575. jw.Msg = Create.Msg;
  10576. if (Create.Code == 0)
  10577. {
  10578. jw.Code = 200;
  10579. jw.Data = new
  10580. {
  10581. groupCost = Create.Data,
  10582. blackCodeIsTrue = true
  10583. };
  10584. }
  10585. else
  10586. {
  10587. jw.Code = 400;
  10588. jw.Data = new
  10589. {
  10590. groupCost = Create.Data,
  10591. blackCodeIsTrue = false,
  10592. };
  10593. }
  10594. return Ok(jw);
  10595. }
  10596. /// <summary>
  10597. /// 成本获取OP历史车费用
  10598. /// </summary>
  10599. /// <param name="dto"></param>
  10600. /// <returns></returns>
  10601. [HttpPost]
  10602. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10603. {
  10604. var jw = JsonView(false);
  10605. try
  10606. {
  10607. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10608. //获取现有所有车的数据
  10609. if (!dto.Param.IsNullOrWhiteSpace())
  10610. {
  10611. string sql = $@"
  10612. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10613. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10614. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10615. 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
  10616. AND gctggr.ServiceEndTime is not NULL
  10617. ORDER by gctggrc.id DESC
  10618. ";
  10619. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10620. var numeberResult = await Task.Run(() =>
  10621. {
  10622. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10623. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10624. return numberArr;
  10625. });
  10626. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10627. foreach (var item in numeberResult)
  10628. {
  10629. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10630. {
  10631. Country = "数据异常!",
  10632. City = string.Empty,
  10633. };
  10634. item.Area = find.Country + " " + find.City;
  10635. }
  10636. dbResult.AddRange(numeberResult);
  10637. if (dto.Param.Contains("、"))
  10638. {
  10639. var sp = dto.Param.Split("、");
  10640. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10641. .Where(x =>
  10642. {
  10643. return System.Array.Exists(sp, e =>
  10644. {
  10645. bool where = false;
  10646. if (x.Area != null)
  10647. {
  10648. where = x.Area.Contains(e);
  10649. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10650. {
  10651. return false;
  10652. }
  10653. }
  10654. if (x.PriceName != null && !where)
  10655. {
  10656. where = x.PriceName.Contains(e);
  10657. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10658. {
  10659. return false;
  10660. }
  10661. }
  10662. return where;
  10663. });
  10664. }).ToList();
  10665. }
  10666. else
  10667. {
  10668. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10669. .Where(x =>
  10670. {
  10671. bool where = false;
  10672. if (x.Area != null)
  10673. {
  10674. where = x.Area.Contains(dto.Param);
  10675. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10676. {
  10677. return false;
  10678. }
  10679. }
  10680. if (x.PriceName != null && !where)
  10681. {
  10682. where = x.PriceName.Contains(dto.Param);
  10683. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10684. {
  10685. return false;
  10686. }
  10687. }
  10688. return where;
  10689. }
  10690. )
  10691. .ToList();
  10692. }
  10693. }
  10694. var view = dbResult.Select(x =>
  10695. {
  10696. decimal dp = 0.00M;
  10697. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10698. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10699. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10700. {
  10701. if (startB && endB)
  10702. {
  10703. var timesp = endD.Subtract(startD);
  10704. if ((timesp.Days + 1) != 0)
  10705. {
  10706. dp = x.Price / (timesp.Days + 1);
  10707. }
  10708. }
  10709. }
  10710. else
  10711. {
  10712. dp = x.Price;
  10713. }
  10714. return new
  10715. {
  10716. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10717. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10718. x.Area,
  10719. x.id,
  10720. price = x.Price.ToString("F2"),
  10721. x.PriceName,
  10722. x.PriceContent,
  10723. x.TeamName,
  10724. x.DatePrice,
  10725. dayPrice = dp.ToString("F2"),
  10726. };
  10727. }).OrderByDescending(x => x.id).ToList();
  10728. jw = JsonView(true, "获取成功!", view);
  10729. }
  10730. catch (Exception e)
  10731. {
  10732. jw = JsonView(false, e.Message);
  10733. }
  10734. return Ok(jw);
  10735. }
  10736. #endregion
  10737. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10738. /// <summary>
  10739. /// 酒店预订
  10740. /// 酒店费用列表 根据团组Id查询
  10741. /// </summary>
  10742. /// <param name="_dto"></param>
  10743. /// <returns></returns>
  10744. [HttpPost]
  10745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10746. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10747. {
  10748. #region 参数验证
  10749. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10750. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10751. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10752. #region 团组操作权限验证 76 酒店预定模块
  10753. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10754. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10755. #endregion
  10756. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10757. #region 页面操作权限验证
  10758. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10759. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10760. #endregion
  10761. #endregion
  10762. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10763. }
  10764. /// <summary>
  10765. /// 酒店预订
  10766. /// 基础数据
  10767. /// </summary>
  10768. /// <param name="_dto"></param>
  10769. /// <returns></returns>
  10770. [HttpPost]
  10771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10772. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10773. {
  10774. #region 参数验证
  10775. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10776. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10777. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10778. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10779. #region 页面操作权限验证
  10780. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10781. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10782. #endregion
  10783. #region 团组操作权限验证 76 酒店预定模块
  10784. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10785. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10786. #endregion
  10787. #endregion
  10788. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10789. }
  10790. /// <summary>
  10791. /// 酒店预订
  10792. /// 创建 入住卷号码
  10793. /// </summary>
  10794. /// <param name="_dto"></param>
  10795. /// <returns></returns>
  10796. [HttpPost]
  10797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10798. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10799. {
  10800. #region 参数验证
  10801. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10802. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10803. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10804. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10805. #region 页面操作权限验证
  10806. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10807. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10808. #endregion
  10809. #region 团组操作权限验证 76 酒店预定模块
  10810. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10811. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10812. #endregion
  10813. #endregion
  10814. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10815. if (data.Code != 0)
  10816. {
  10817. return Ok(JsonView(false, data.Msg));
  10818. }
  10819. return Ok(JsonView(true, data.Msg, data.Data));
  10820. }
  10821. /// <summary>
  10822. /// 酒店预订
  10823. /// 详情
  10824. /// </summary>
  10825. /// <param name="_dto"></param>
  10826. /// <returns></returns>
  10827. [HttpPost]
  10828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10829. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10830. {
  10831. #region 参数验证
  10832. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10833. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10834. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10835. #region 团组操作权限验证 76 酒店预定模块
  10836. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10837. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10838. #endregion
  10839. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10840. #region 页面操作权限验证
  10841. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10842. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10843. #endregion
  10844. #endregion
  10845. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10846. }
  10847. /// <summary>
  10848. /// 酒店预订
  10849. /// Add Or Edit
  10850. /// </summary>
  10851. /// <param name="_dto"></param>
  10852. /// <returns></returns>
  10853. [HttpPost]
  10854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10855. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10856. {
  10857. #region 参数验证
  10858. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10859. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10860. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10861. #region 团组操作权限验证 76 酒店预定模块
  10862. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10863. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10864. #endregion
  10865. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10866. #region 页面操作权限验证
  10867. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10868. if (_dto.Id == 0) // Add
  10869. {
  10870. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10871. }
  10872. else if (_dto.Id > 1) // Edit
  10873. {
  10874. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10875. }
  10876. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10877. #endregion
  10878. #endregion
  10879. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10880. if (_view.Code != 200)
  10881. {
  10882. return Ok(_view);
  10883. }
  10884. #region 成本无酒店价格数据进入超支
  10885. _sqlSugar.BeginTran();
  10886. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10887. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10888. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10889. for (int i = 0; i < groupCost.Count; i++)
  10890. {
  10891. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10892. {
  10893. groupCost[i].Date = groupCost[i - 1].Date;
  10894. }
  10895. }
  10896. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10897. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10898. List<Fin_GroupExtraCostDto_OP>();
  10899. if (start_Bool && end_Bool)
  10900. {
  10901. while (start_Time < end_Time)
  10902. {
  10903. foreach (var item in groupCost_Grp)
  10904. {
  10905. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10906. {
  10907. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10908. {
  10909. extraCostList.Add(new
  10910. Fin_GroupExtraCostDto_OP
  10911. {
  10912. Area = _dto.AreaId,
  10913. coefficient = 1.5M,
  10914. createUser = _dto.UserId,
  10915. currency = _dto.CardPriceCurrency,
  10916. diId = _dto.DiId,
  10917. ManagerConfirm = 0,
  10918. SupervisorConfirm = 0,
  10919. SYsupervisorConfirm = 0,
  10920. editType = 1,
  10921. PortType = 1,
  10922. price = _dto.CardPrice,
  10923. PriceCount = 1,
  10924. priceType = 1027,
  10925. priceDetailType = 1044,
  10926. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10927. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10928. });
  10929. }
  10930. }
  10931. }
  10932. start_Time = start_Time.AddDays(1);
  10933. }
  10934. }
  10935. if (extraCostList.Any())
  10936. {
  10937. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10938. }
  10939. _sqlSugar.CommitTran();
  10940. #endregion
  10941. #region 应用推送
  10942. try
  10943. {
  10944. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10945. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10946. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10947. var diId = _dto.DiId;
  10948. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10949. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10950. #region 操作记录
  10951. var opInfo = new Crm_TableOperationRecord() {
  10952. TableName = "Grp_HotelReservations",
  10953. PortType = _dto.PortType,
  10954. DataId = hotelId,
  10955. CreateUserId = _dto.UserId
  10956. };
  10957. var opStatus = OperationEnum.NoOperation;
  10958. if (_dto.Id<1) //添加操作
  10959. {
  10960. opInfo.OperationItem = OperationEnum.Add;
  10961. }
  10962. else if (_dto.Id > 0)
  10963. {
  10964. opInfo.OperationItem = OperationEnum.Edit;
  10965. }
  10966. string opRemark = string.Empty;
  10967. if (ccpInfo != null)
  10968. {
  10969. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10970. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10971. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10972. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10973. }
  10974. opInfo.Remark = opRemark;
  10975. await _tableorRep.AddAsync(opInfo);
  10976. #endregion
  10977. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10978. //2024-10-21 新增LZ UID
  10979. var userIds = new List<int>() { 21 };
  10980. string title = $"费用审核";
  10981. string content = "";
  10982. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10983. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10984. try
  10985. {
  10986. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10987. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  10988. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  10989. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  10990. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  10991. }
  10992. catch (Exception ex )
  10993. {
  10994. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  10995. }
  10996. }
  10997. catch (Exception ex)
  10998. {
  10999. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  11000. }
  11001. try
  11002. {
  11003. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  11004. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  11005. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  11006. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11007. //自动审核
  11008. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  11009. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  11010. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  11011. //2024-10-21 新增LZ UID
  11012. var userIds = new List<int>() { 21 };
  11013. string title = $"系统通知";
  11014. var diId = _dto.DiId;
  11015. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11016. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11017. string content = "";
  11018. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11019. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11020. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11021. }
  11022. catch (Exception ex)
  11023. {
  11024. }
  11025. #endregion
  11026. return Ok(_view);
  11027. }
  11028. /// <summary>
  11029. /// 酒店自动审核测试
  11030. /// Add Or Edit
  11031. /// </summary>
  11032. /// <param name="_dto"></param>
  11033. /// <returns></returns>
  11034. [HttpPost]
  11035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11036. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  11037. {
  11038. #region 应用推送
  11039. try
  11040. {
  11041. //自动审核
  11042. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  11043. }
  11044. catch (Exception ex)
  11045. {
  11046. return Ok(JsonView(false, "操作失败"));
  11047. }
  11048. #endregion
  11049. return Ok(JsonView(false, "操作成功"));
  11050. }
  11051. /// <summary>
  11052. /// 酒店预订
  11053. /// Del
  11054. /// </summary>
  11055. /// <param name="_dto"></param>
  11056. /// <returns></returns>
  11057. [HttpPost]
  11058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11059. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  11060. {
  11061. #region 参数验证
  11062. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11063. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11064. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11065. #region 团组操作权限验证 76 酒店预定模块
  11066. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11067. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11068. #endregion
  11069. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11070. #region 页面操作权限验证
  11071. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11072. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11073. #endregion
  11074. #endregion
  11075. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  11076. #region 操作记录
  11077. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11078. {
  11079. TableName = "Grp_HotelReservations",
  11080. PortType = _dto.PortType,
  11081. OperationItem = OperationEnum.Del,
  11082. DataId = _dto.Id,
  11083. CreateUserId = _dto.UserId
  11084. });
  11085. #endregion
  11086. return Ok(data);
  11087. }
  11088. /// <summary>
  11089. /// 酒店预订
  11090. /// 生成VOUCHER
  11091. /// 2024.05.06 之前版本
  11092. /// </summary>
  11093. /// <param name="_dto"></param>
  11094. /// <returns></returns>
  11095. [HttpPost]
  11096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11097. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11098. {
  11099. try
  11100. {
  11101. #region 参数验证
  11102. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11103. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11104. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11105. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11106. #region 团组操作权限验证 76 酒店预定模块
  11107. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11108. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11109. #endregion
  11110. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11111. #region 页面操作权限验证
  11112. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11113. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11114. #endregion
  11115. #endregion
  11116. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11117. //判断数据是否完整
  11118. if (hr != null)
  11119. {
  11120. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11121. {
  11122. string strFileName = "HotelStatement/";
  11123. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11124. if (dele != null)
  11125. strFileName += dele.TourCode;
  11126. //载入模板
  11127. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11128. Document doc = new Document(sss);
  11129. DocumentBuilder builder = new DocumentBuilder(doc);
  11130. #region 替换Word模板书签内容
  11131. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11132. //入住卷预定号码
  11133. if (doc.Range.Bookmarks["VNO"] != null)
  11134. {
  11135. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11136. mark.Text = hr.CheckNumber;
  11137. }
  11138. //酒店时间
  11139. if (doc.Range.Bookmarks["Date"] != null)
  11140. {
  11141. Bookmark mark = doc.Range.Bookmarks["Date"];
  11142. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11143. }
  11144. //团号
  11145. if (doc.Range.Bookmarks["TNo"] != null)
  11146. {
  11147. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11148. mark.Text = dele.TourCode;
  11149. }
  11150. //预定号码
  11151. if (doc.Range.Bookmarks["BookingId"] != null)
  11152. {
  11153. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11154. mark.Text = hr.ReservationsNo;
  11155. }
  11156. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11157. {
  11158. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11159. mark.Text = hr.DetermineNo;
  11160. }
  11161. //酒店城市
  11162. if (doc.Range.Bookmarks["City"] != null)
  11163. {
  11164. Bookmark mark = doc.Range.Bookmarks["City"];
  11165. mark.Text = hr.City;
  11166. }
  11167. //酒店名称
  11168. if (doc.Range.Bookmarks["HName"] != null)
  11169. {
  11170. Bookmark mark = doc.Range.Bookmarks["HName"];
  11171. mark.Text = hr.HotelName;
  11172. }
  11173. //酒店地址
  11174. if (doc.Range.Bookmarks["Address"] != null)
  11175. {
  11176. Bookmark mark = doc.Range.Bookmarks["Address"];
  11177. mark.Text = hr.HotelAddress;
  11178. }
  11179. //酒店电话
  11180. if (doc.Range.Bookmarks["Tel"] != null)
  11181. {
  11182. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11183. mark.Text = hr.HotelTel;
  11184. }
  11185. //酒店传真
  11186. if (doc.Range.Bookmarks["Fax"] != null)
  11187. {
  11188. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11189. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11190. {
  11191. mark.Text = hr.HotelFax;
  11192. }
  11193. }
  11194. //入住时间
  11195. if (doc.Range.Bookmarks["CIn"] != null)
  11196. {
  11197. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11198. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11199. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11200. }
  11201. //退房时间
  11202. if (doc.Range.Bookmarks["COut"] != null)
  11203. {
  11204. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11205. Bookmark mark = doc.Range.Bookmarks["COut"];
  11206. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11207. }
  11208. //客户名称
  11209. if (doc.Range.Bookmarks["GName"] != null)
  11210. {
  11211. string guestName = "";
  11212. string[] clients = new string[] { };
  11213. if (hr.GuestName.Contains(","))
  11214. {
  11215. clients = hr.GuestName.Split(",");
  11216. }
  11217. else
  11218. {
  11219. clients = new string[] { hr.GuestName };
  11220. }
  11221. List<int> clientIds_int = new List<int>();
  11222. if (clients.Length > 0)
  11223. {
  11224. foreach (var item in clients)
  11225. {
  11226. if (item.IsNumeric())
  11227. {
  11228. clientIds_int.Add(int.Parse(item));
  11229. }
  11230. }
  11231. }
  11232. if (clientIds_int.Count > 0)
  11233. {
  11234. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11235. foreach (var client in _clientDatas)
  11236. {
  11237. //男
  11238. if (client.Sex == 0) guestName += $"Mr.";
  11239. //女
  11240. else if (client.Sex == 1) guestName += $"Ms.";
  11241. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11242. {
  11243. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11244. }
  11245. //guestName += $"{client.Pinyin},";
  11246. }
  11247. if (guestName.Length > 0)
  11248. {
  11249. guestName = guestName.Substring(0, guestName.Length - 1);
  11250. }
  11251. }
  11252. else
  11253. {
  11254. guestName = hr.GuestName;
  11255. }
  11256. Bookmark mark = doc.Range.Bookmarks["GName"];
  11257. mark.Text = guestName;
  11258. }
  11259. //房间介绍
  11260. if (doc.Range.Bookmarks["ROOM"] != null)
  11261. {
  11262. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11263. mark.Text = hr.RoomExplanation;
  11264. }
  11265. //报价描述
  11266. if (doc.Range.Bookmarks["NOTE"] != null)
  11267. {
  11268. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11269. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11270. if (ss != null)
  11271. mark.Text = ss.Name;
  11272. }
  11273. //入住时间
  11274. if (doc.Range.Bookmarks["CheckIn"] != null)
  11275. {
  11276. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11277. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11278. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11279. }
  11280. //退房时间
  11281. if (doc.Range.Bookmarks["CheckOut"] != null)
  11282. {
  11283. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11284. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11285. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11286. }
  11287. //日期
  11288. if (doc.Range.Bookmarks["DT"] != null)
  11289. {
  11290. Bookmark mark = doc.Range.Bookmarks["DT"];
  11291. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11292. }
  11293. //名称
  11294. if (doc.Range.Bookmarks["VName"] != null)
  11295. {
  11296. Bookmark mark = doc.Range.Bookmarks["VName"];
  11297. mark.Text = hr.HotelName;
  11298. }
  11299. //号码
  11300. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11301. {
  11302. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11303. mark.Text = hr.CheckNumber;
  11304. }
  11305. #endregion
  11306. strFileName += "VOUCHER.doc";
  11307. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11308. doc.Save(fileDir);
  11309. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11310. return Ok(JsonView(true, "操作成功!", Url));
  11311. }
  11312. else
  11313. {
  11314. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11315. }
  11316. }
  11317. else
  11318. {
  11319. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11320. }
  11321. }
  11322. catch (Exception ex)
  11323. {
  11324. return Ok(JsonView(false, ex.Message));
  11325. }
  11326. }
  11327. /// <summary>
  11328. /// 酒店预订
  11329. /// 生成VOUCHER
  11330. /// 2024.05.06 之后版本
  11331. /// </summary>
  11332. /// <param name="_dto"></param>
  11333. /// <returns></returns>
  11334. [HttpPost]
  11335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11336. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11337. {
  11338. #region 参数验证
  11339. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11340. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11341. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11342. #region 团组操作权限验证 76 酒店预定模块
  11343. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11344. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11345. #endregion
  11346. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11347. #region 页面操作权限验证
  11348. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11349. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11350. #endregion
  11351. #endregion
  11352. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11353. //判断数据是否完整
  11354. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11355. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11356. string strFileName = "HotelStatement/";
  11357. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11358. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11359. #region 数据处理
  11360. List<int> guestIds = new List<int>();
  11361. int index = 0;
  11362. foreach (var item in hrDtas)
  11363. {
  11364. if (item.GuestName.Contains(","))
  11365. {
  11366. string[] guestIdArr = item.GuestName.Split(',');
  11367. foreach (var guestIdStr in guestIdArr)
  11368. {
  11369. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11370. if (guestBool)
  11371. {
  11372. guestIds.Add(guestId);
  11373. }
  11374. }
  11375. }
  11376. else guestNames += item.GuestName;
  11377. var voucherInfo = new HotelVoucherInfoView()
  11378. {
  11379. HotelName = item.HotelName,
  11380. CheckInDate = item.CheckInDate,
  11381. CheckOutDate = item.CheckOutDate,
  11382. ConfirmationNumber = item.DetermineNo.Trim(),
  11383. RoomType = item.RoomExplanation
  11384. };
  11385. vouchers.Add(voucherInfo);
  11386. }
  11387. if (guestIds.Count > 0)
  11388. {
  11389. guestIds = guestIds.Distinct().ToList();
  11390. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11391. if (guestDatas.Count > 0)
  11392. {
  11393. guestNames = "";
  11394. foreach (var guest in guestDatas)
  11395. {
  11396. string guestName = "";
  11397. if (guest.Sex == 0) guestName += @"MR.";
  11398. else if (guest.Sex == 1) guestName += @"MS.";
  11399. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11400. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11401. guestNames += @$"{guestName.Trim()}、";
  11402. }
  11403. if (guestNames.Length > 0)
  11404. {
  11405. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11406. }
  11407. }
  11408. }
  11409. #endregion
  11410. //载入模板
  11411. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11412. Document doc = new Document(sss);
  11413. DocumentBuilder builder = new DocumentBuilder(doc);
  11414. if (doc.Range.Bookmarks["GuestName"] != null)
  11415. {
  11416. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11417. mark.Text = guestNames;
  11418. }
  11419. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11420. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11421. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11422. for (int i = 1; i <= vouchers.Count; i++)
  11423. {
  11424. HotelVoucherInfoView hviv = vouchers[i - 1];
  11425. builder.MoveToCell(0, i, 0, 0);
  11426. builder.Write(hviv.HotelName);
  11427. builder.MoveToCell(0, i, 1, 0);
  11428. builder.Write(hviv.CheckInDate);
  11429. builder.MoveToCell(0, i, 2, 0);
  11430. builder.Write(hviv.CheckOutDate);
  11431. builder.MoveToCell(0, i, 3, 0);
  11432. builder.Write(hviv.RoomType);
  11433. builder.MoveToCell(0, i, 4, 0);
  11434. builder.Write(hviv.ConfirmationNumber);
  11435. }
  11436. //删除多余行
  11437. int currRowIndex = vouchers.Count + 1;
  11438. int delRows = 21 - currRowIndex;
  11439. if (delRows > 0)
  11440. {
  11441. for (int i = 0; i < delRows; i++)
  11442. {
  11443. table.Rows.RemoveAt(currRowIndex);
  11444. //cultivateRowIndex++;
  11445. }
  11446. }
  11447. strFileName += "VOUCHER.docx";
  11448. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11449. doc.Save(fileDir);
  11450. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11451. return Ok(JsonView(true, "操作成功!", Url));
  11452. }
  11453. /// <summary>
  11454. /// 酒店预订
  11455. /// 生成VOUCHER 批量生成
  11456. /// New
  11457. /// </summary>
  11458. /// <param name="_dto"></param>
  11459. /// <returns></returns>
  11460. [HttpPost]
  11461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11462. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11463. {
  11464. #region 参数验证
  11465. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11466. if (_dto.PageId < 1) _dto.PageId = 28;
  11467. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11468. #region 团组操作权限验证 76 酒店预定模块
  11469. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11470. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11471. #endregion
  11472. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11473. #region 页面操作权限验证
  11474. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11475. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11476. #endregion
  11477. #endregion
  11478. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11479. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11480. .OrderBy(x => x.CheckInDate)
  11481. .ToListAsync();
  11482. //判断数据是否完整
  11483. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11484. string strFileName = "HotelStatement/";
  11485. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11486. if (dele != null)
  11487. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11488. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  11489. for (int i = 0; i < hrDtas.Count; i++)
  11490. {
  11491. string guestNames = string.Empty;
  11492. List<int> guestIds = new List<int>();
  11493. var item = hrDtas[i];
  11494. //处理客户姓名
  11495. if (item.GuestName.Contains(","))
  11496. {
  11497. string[] guestIdArr = item.GuestName.Split(',');
  11498. foreach (var guestIdStr in guestIdArr)
  11499. if (int.TryParse(guestIdStr, out int guestId))
  11500. guestIds.Add(guestId);
  11501. }
  11502. else
  11503. {
  11504. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11505. if (guestIdBool)
  11506. {
  11507. guestIds.Add(guestId);
  11508. }
  11509. //NaN
  11510. if (item.GuestName.Contains("NaN"))
  11511. {
  11512. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11513. }
  11514. }
  11515. if (guestIds.Count > 0)
  11516. {
  11517. guestIds = guestIds.Distinct().ToList();
  11518. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11519. if (guestDatas1.Count > 0)
  11520. {
  11521. guestNames = "";
  11522. foreach (var guest in guestDatas1)
  11523. {
  11524. string guestName = "";
  11525. if (guest.Sex == 0) guestName += @"MR.";
  11526. else if (guest.Sex == 1) guestName += @"MS.";
  11527. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11528. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11529. guestNames += @$"{guestName.Trim()}、";
  11530. }
  11531. if (guestNames.Length > 0)
  11532. {
  11533. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11534. }
  11535. }
  11536. }
  11537. //if (!string.IsNullOrEmpty(guestNames))
  11538. //{
  11539. hrDtas[i].GuestName = guestNames;
  11540. //}
  11541. }
  11542. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11543. Document doc = new Document();
  11544. DocumentBuilder builder = new DocumentBuilder(doc);
  11545. try
  11546. {
  11547. builder.MoveToDocumentStart();
  11548. foreach (var item in hrDtas)
  11549. {
  11550. //标题
  11551. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11552. builder.ParagraphFormat.LineSpacing = 1;
  11553. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11554. builder.ParagraphFormat.Style.Font.Size = 9;
  11555. builder.ParagraphFormat.Style.Font.Bold = true;
  11556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11557. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11558. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11559. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11560. builder.ParagraphFormat.LineSpacing = 1;
  11561. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11562. builder.ParagraphFormat.Style.Font.Size = 9;
  11563. builder.ParagraphFormat.Style.Font.Bold = true;
  11564. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11565. builder.StartTable();
  11566. // 设置边框颜色
  11567. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11568. //设置边框样式
  11569. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11570. //表格
  11571. #region 第一行
  11572. builder.InsertCell();
  11573. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11574. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11575. //builder.CellFormat.AllowAutoFit = false;
  11576. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11577. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11578. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11579. builder.CellFormat.WrapText = true; //自动换行
  11580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11581. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11582. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11583. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11584. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11585. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11586. builder.Write("TOUR NO:");
  11587. builder.InsertCell();
  11588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11589. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11590. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11591. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11592. builder.ParagraphFormat.Style.Font.Bold = false;
  11593. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11594. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11595. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11596. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11597. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11598. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11599. builder.Write($"{dele?.TourCode ?? "-"}");
  11600. builder.InsertCell();
  11601. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11602. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11603. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11604. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11605. builder.ParagraphFormat.Style.Font.Bold = false;
  11606. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11607. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11608. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11609. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11610. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11611. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11612. builder.Write($"CITY:");
  11613. builder.InsertCell();
  11614. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11615. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11617. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11618. builder.ParagraphFormat.Style.Font.Bold = false;
  11619. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11620. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11621. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11622. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11623. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11624. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11625. builder.Write($"{item.City}");
  11626. builder.EndRow();
  11627. #endregion
  11628. #region 第二行
  11629. builder.InsertCell();
  11630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11631. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11632. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11633. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11634. builder.ParagraphFormat.Style.Font.Bold = false;
  11635. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11637. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11638. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11639. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11640. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11641. builder.Write("CONFIRMATION NO:");
  11642. builder.InsertCell();
  11643. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11644. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11645. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11646. builder.ParagraphFormat.Style.Font.Bold = false;
  11647. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11648. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11649. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11650. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11651. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11652. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11653. builder.CellFormat.VerticalMerge = CellMerge.None;
  11654. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11655. builder.Write($"{item.DetermineNo}");
  11656. builder.InsertCell();
  11657. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11658. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11659. builder.InsertCell();
  11660. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11661. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11662. builder.EndRow();
  11663. #endregion
  11664. #region 第三行
  11665. builder.InsertCell();
  11666. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11667. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11668. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11669. builder.ParagraphFormat.Style.Font.Bold = false;
  11670. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11671. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11672. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11673. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11674. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11675. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11676. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11677. builder.Write($"HOTEL NAME:");
  11678. builder.InsertCell();
  11679. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11680. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11681. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11682. builder.ParagraphFormat.Style.Font.Bold = false;
  11683. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11684. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11685. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11686. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11687. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11688. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11689. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11690. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11691. builder.Write($"{item.HotelName}");
  11692. builder.InsertCell();
  11693. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11694. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11695. builder.InsertCell();
  11696. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11697. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11698. builder.EndRow();
  11699. #endregion
  11700. #region 第四行
  11701. builder.InsertCell();
  11702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11703. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11704. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11705. builder.ParagraphFormat.Style.Font.Bold = false;
  11706. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11707. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11708. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11709. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11710. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11711. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11712. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11713. builder.Write($"HOTEL ADDRESS:");
  11714. builder.InsertCell();
  11715. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11716. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11717. builder.ParagraphFormat.Style.Font.Size = 8;
  11718. builder.ParagraphFormat.Style.Font.Bold = false;
  11719. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11720. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11721. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11722. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11723. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11724. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11725. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11726. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11727. builder.Write($"{item.HotelAddress}");
  11728. builder.InsertCell();
  11729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11730. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11731. builder.InsertCell();
  11732. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11733. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11734. builder.EndRow();
  11735. #endregion
  11736. #region 第五行
  11737. builder.InsertCell();
  11738. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11739. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11740. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11741. builder.ParagraphFormat.Style.Font.Bold = false;
  11742. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11743. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11744. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11745. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11746. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11747. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11748. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11749. builder.Write("TEL:");
  11750. builder.InsertCell();
  11751. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11752. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11753. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11754. builder.ParagraphFormat.Style.Font.Bold = false;
  11755. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11756. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11757. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11758. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11759. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11760. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11761. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11762. builder.Write($"{item.HotelTel}");
  11763. builder.InsertCell();
  11764. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11765. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11766. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11767. builder.ParagraphFormat.Style.Font.Bold = false;
  11768. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11769. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11770. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11771. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11772. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11773. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11774. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11775. builder.Write($"FAX:");
  11776. builder.InsertCell();
  11777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11778. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11779. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11780. builder.ParagraphFormat.Style.Font.Bold = false;
  11781. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11782. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11783. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11784. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11785. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11786. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11787. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11788. builder.Write($"{item.HotelFax}");
  11789. builder.EndRow();
  11790. #endregion
  11791. #region 第六行
  11792. builder.InsertCell();
  11793. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11794. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11795. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11796. builder.ParagraphFormat.Style.Font.Bold = false;
  11797. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11798. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11799. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11800. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11801. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11802. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11803. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11804. builder.Write("CHECK IN:");
  11805. builder.InsertCell();
  11806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11807. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11808. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11809. builder.ParagraphFormat.Style.Font.Bold = false;
  11810. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11811. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11812. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11813. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11814. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11815. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11816. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11817. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11818. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11819. builder.Write($"{checkInStr}");
  11820. builder.InsertCell();
  11821. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11822. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11823. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11824. builder.ParagraphFormat.Style.Font.Bold = false;
  11825. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11826. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11827. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11828. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11829. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11830. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11831. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11832. builder.Write($"CHECK OUT:");
  11833. builder.InsertCell();
  11834. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11835. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11836. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11837. builder.ParagraphFormat.Style.Font.Bold = false;
  11838. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11839. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11840. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11841. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11842. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11843. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11844. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11845. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11846. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11847. builder.Write($"{checkOutStr}");
  11848. builder.EndRow();
  11849. #endregion
  11850. #region 第七行
  11851. builder.InsertCell();
  11852. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11853. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11854. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11855. builder.ParagraphFormat.Style.Font.Bold = false;
  11856. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11857. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11858. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11859. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11860. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11861. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11862. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11863. builder.Write($"GUEST NAME:");
  11864. builder.InsertCell();
  11865. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11866. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11867. builder.ParagraphFormat.Style.Font.Size = 8;
  11868. builder.ParagraphFormat.Style.Font.Bold = false;
  11869. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11870. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11871. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11872. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11873. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11874. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11875. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11876. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11877. builder.Write($"{item.GuestName}");
  11878. builder.InsertCell();
  11879. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11880. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11881. builder.InsertCell();
  11882. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11883. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11884. builder.EndRow();
  11885. #endregion
  11886. #region 第八行
  11887. builder.InsertCell();
  11888. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11889. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11890. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11891. builder.ParagraphFormat.Style.Font.Bold = false;
  11892. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11893. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11894. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11895. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11896. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11897. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11898. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11899. builder.Write($"ROOM TYPE:");
  11900. builder.InsertCell();
  11901. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11902. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11903. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11904. builder.ParagraphFormat.Style.Font.Bold = false;
  11905. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11906. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11907. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11908. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11909. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11910. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11911. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11912. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11913. builder.Write($"{item.RoomExplanation}");
  11914. builder.InsertCell();
  11915. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11916. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11917. builder.InsertCell();
  11918. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11919. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11920. builder.EndRow();
  11921. #endregion
  11922. #region 第九行
  11923. builder.InsertCell();
  11924. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11925. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11926. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11927. builder.ParagraphFormat.Style.Font.Bold = false;
  11928. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11929. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11930. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11931. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11932. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11933. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11934. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11935. builder.Write($"NOTE:");
  11936. builder.InsertCell();
  11937. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11938. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11939. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11940. builder.ParagraphFormat.Style.Font.Bold = false;
  11941. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11942. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11943. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11944. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11945. 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.");
  11946. builder.InsertCell();
  11947. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11948. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11949. builder.InsertCell();
  11950. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11951. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11952. builder.EndRow();
  11953. #endregion
  11954. builder.EndTable();
  11955. //换行
  11956. builder.Writeln("");
  11957. builder.Writeln("");
  11958. }
  11959. #region 获取文档中的所有表格 设置文字自适应
  11960. // 获取文档中的所有表格。
  11961. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11962. {
  11963. // 遍历表格中的所有行。
  11964. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11965. {
  11966. foreach (Cell cell in row.Cells)
  11967. {
  11968. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11969. cellFormat.Width = 0;
  11970. }
  11971. }
  11972. }
  11973. #endregion
  11974. #region 设置页眉
  11975. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11976. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11977. if (System.IO.File.Exists(voucherHeaderPath))
  11978. {
  11979. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11980. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11981. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11982. Shape shape = builder.InsertImage(imageBytes);
  11983. // 调整图片位置
  11984. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  11985. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  11986. shape.Top = 50; // 将图片距离页眉上边缘的距离
  11987. shape.Left = 0; // 将图片距离页面左边缘的距离
  11988. shape.Width = 81; // 设置图片宽度
  11989. shape.Height = 36; // 设置图片高度
  11990. }
  11991. //靠右
  11992. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  11993. //// 设置页脚上下边距
  11994. //builder.PageSetup.HeaderDistance = 42;
  11995. // 添加页眉线
  11996. Aspose.Words.Border borderHeader = null;
  11997. try
  11998. {
  11999. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  12000. }
  12001. catch (Exception e)
  12002. {
  12003. // TODO Auto-generated catch block
  12004. //e.printStackTrace();
  12005. }
  12006. borderHeader.Shadow = true;
  12007. borderHeader.DistanceFromText = 2;
  12008. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  12009. #endregion
  12010. }
  12011. catch (Exception ex)
  12012. {
  12013. }
  12014. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12015. doc.Save(fileDir);
  12016. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12017. return Ok(JsonView(true, "操作成功!", Url));
  12018. }
  12019. /// <summary>
  12020. /// 酒店预订
  12021. /// 生成 预定成本 Excel
  12022. /// </summary>
  12023. /// <param name="_dto"></param>
  12024. /// <returns></returns>
  12025. [HttpPost]
  12026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12027. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  12028. {
  12029. #region 参数验证
  12030. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  12031. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  12032. if (!vadalitorRes.IsValid)
  12033. {
  12034. var errors = new StringBuilder();
  12035. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  12036. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  12037. }
  12038. #region 团组操作权限验证 76 酒店预定模块
  12039. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12040. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12041. #endregion
  12042. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12043. #region 页面操作权限验证
  12044. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12045. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12046. #endregion
  12047. #endregion
  12048. decimal _rate = 1.00M;
  12049. string _currency = string.Empty;
  12050. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  12051. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12052. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  12053. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12054. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  12055. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  12056. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  12057. if (_GroupCostParameter == null)
  12058. {
  12059. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  12060. bool isIntType = int.TryParse(_currency, out int currId);
  12061. if (isIntType)
  12062. {
  12063. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12064. }
  12065. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12066. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12067. if (currInfo == null)
  12068. {
  12069. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12070. }
  12071. else _rate = currInfo.Rate;
  12072. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12073. {
  12074. _rate = _GroupCostParameter.Rate;
  12075. }
  12076. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12077. string strFileName = "HotelStatement/";
  12078. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12079. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12080. var rateDatas = new List<dynamic>();
  12081. #region 数据处理
  12082. foreach (var item in hrDtas)
  12083. {
  12084. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12085. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12086. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12087. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12088. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12089. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12090. {
  12091. continue;
  12092. }
  12093. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12094. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12095. string singleRoomFeeStr = string.Empty,
  12096. doubleRoomFeeStr = string.Empty,
  12097. suiteRoomFeeStr = string.Empty,
  12098. otherRoomFeeStr = string.Empty,
  12099. payMoneyStr = string.Empty,
  12100. cardPriceStr = string.Empty;
  12101. if (roomCurr.Equals("CNY"))
  12102. {
  12103. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12104. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12105. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12106. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12107. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12108. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12109. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12110. }
  12111. else
  12112. {
  12113. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12114. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12115. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12116. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12117. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12118. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12119. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12120. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12121. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12122. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12123. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12124. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12125. if (ccpPaymentCurrency.Equals("CNY"))
  12126. {
  12127. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12128. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12129. }
  12130. else
  12131. {
  12132. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12133. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12134. }
  12135. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12136. if (hotelcardPriceCurrency.Equals("CNY"))
  12137. {
  12138. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12139. }
  12140. else
  12141. {
  12142. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12143. }
  12144. }
  12145. string breakfastPriceStr = string.Empty,
  12146. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12147. governmentRentStr = string.Empty,
  12148. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12149. cityTaxStr = string.Empty,
  12150. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12151. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12152. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12153. {
  12154. if (breakfastCurrency1.Equals("CNY"))
  12155. {
  12156. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12157. }
  12158. else
  12159. {
  12160. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12161. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12162. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12163. }
  12164. }
  12165. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12166. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12167. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12168. {
  12169. if (governmentRentCurrency.Equals("CNY"))
  12170. {
  12171. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12172. }
  12173. else
  12174. {
  12175. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12176. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12177. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12178. }
  12179. }
  12180. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12181. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12182. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12183. {
  12184. if (cityTaxStrCurrency1.Equals("CNY"))
  12185. {
  12186. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12187. }
  12188. else
  12189. {
  12190. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12191. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12192. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12193. }
  12194. }
  12195. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12196. int payDId = roomInfo?.PayDId ?? 0;
  12197. pcfds.Add(new HotelReservations_PCFD_View()
  12198. {
  12199. City = item.City,
  12200. HotelName = item.HotelName,
  12201. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12202. // SingleRoomCount = item.SingleRoomCount,
  12203. SingleRoomPrice = singleRoomFeeStr,
  12204. // DoubleRoomCount = item.DoubleRoomCount,
  12205. DoubleRoomPrice = doubleRoomFeeStr,
  12206. //SuiteRoomCount = item.SuiteRoomCount,
  12207. SuiteRoomPrice = suiteRoomFeeStr,
  12208. OtherRoomPrice = otherRoomFeeStr,
  12209. //OtherRoomCount = item.OtherRoomCount,
  12210. BreakfastPrice = breakfastPriceStr,
  12211. GovernmentRent = governmentRentStr,
  12212. CityTax = cityTaxStr,
  12213. RoomExplanation = item.RoomExplanation,
  12214. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12215. PayTime = roomInfo?.ConsumptionDate,
  12216. BankNo = roomInfo?.BankNo,
  12217. PayMoney = payMoneyStr,
  12218. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12219. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12220. CardPrice = cardPriceStr,
  12221. Remark = ccpInfo.Remark
  12222. });
  12223. }
  12224. #endregion
  12225. //载入模板
  12226. WorkbookDesigner designer = new WorkbookDesigner();
  12227. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12228. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12229. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12230. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12231. var rateDatas1 = rateDatas.Distinct();
  12232. var rateStr = string.Empty;
  12233. foreach (var item in rateDatas1)
  12234. {
  12235. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12236. }
  12237. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12238. designer.SetDataSource("Opertor", userInfo.CnName);
  12239. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12240. dt.TableName = "ViewMyHotelReservations";
  12241. designer.SetDataSource(dt);
  12242. designer.Process();
  12243. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12244. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12245. designer.Workbook.Save(serverPath);
  12246. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12247. #region 删除指定行
  12248. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12249. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12250. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12251. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12252. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12253. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12254. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12255. cssIndex = dt.Columns["CityTax"].Ordinal,
  12256. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12257. remarkIndex = dt.Columns["Remark"].Ordinal;
  12258. //删除指定列
  12259. foreach (DataRow item in dt.Rows)
  12260. {
  12261. string singleStr = item["SingleRoomPrice"].ToString();
  12262. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12263. if (containsDigitButNotZero1) singleDel = false;
  12264. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12265. string doubleStr = item["DoubleRoomPrice"].ToString();
  12266. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12267. if (containsDigitButNotZero2) doubleDel = false;
  12268. string suiteStr = item["SuiteRoomPrice"].ToString();
  12269. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12270. if (containsDigitButNotZero3) suiteDel = false;
  12271. string otherStr = item["OtherRoomPrice"].ToString();
  12272. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12273. if (containsDigitButNotZero4) otherDel = false;
  12274. string zcStr = item["BreakfastPrice"].ToString();
  12275. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12276. if (containsDigitButNotZero5) zcDel = false;
  12277. string dsStr = item["GovernmentRent"].ToString();
  12278. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12279. if (containsDigitButNotZero6) dsDel = false;
  12280. string cssStr = item["CityTax"].ToString();
  12281. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12282. if (containsDigitButNotZero7) cssDel = false;
  12283. string cpStr = item["ConsumptionPatterns"].ToString();
  12284. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12285. string remarkStr = item["Remark"].ToString();
  12286. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12287. }
  12288. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12289. DeleteColumn(serverPath, cpIndex, cpDel);
  12290. DeleteColumn(serverPath, dsIndex, dsDel);
  12291. DeleteColumn(serverPath, cssIndex, cssDel);
  12292. DeleteColumn(serverPath, zcIndex, zcDel);
  12293. DeleteColumn(serverPath, otherIndex, otherDel);
  12294. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12295. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12296. DeleteColumn(serverPath, singleIndex, singleDel);
  12297. #endregion
  12298. //只保留第一个表格
  12299. DeleteSheet(serverPath);
  12300. return Ok(JsonView(true, "操作成功", url = rst));
  12301. }
  12302. else
  12303. {
  12304. _currency = _GroupCostParameter.Currency;
  12305. bool isIntType = int.TryParse(_currency, out int currId);
  12306. if (isIntType)
  12307. {
  12308. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12309. }
  12310. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12311. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12312. if (currInfo == null)
  12313. {
  12314. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12315. }
  12316. if (!_currency.ToUpper().Equals("CNY"))
  12317. {
  12318. _rate = _GroupCostParameter.Rate;
  12319. }
  12320. _rate = currInfo.Rate;
  12321. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12322. string strFileName = "HotelStatement/";
  12323. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12324. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12325. #region 数据处理
  12326. foreach (var item in hrDtas)
  12327. {
  12328. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12329. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12330. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12331. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12332. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12333. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12334. string singleRoomFeeStr = string.Empty,
  12335. doubleRoomFeeStr = string.Empty,
  12336. suiteRoomFeeStr = string.Empty,
  12337. otherRoomFeeStr = string.Empty,
  12338. payMoneyStr = string.Empty,
  12339. cardPriceStr = string.Empty;
  12340. if (roomCurr.Equals(_currency))
  12341. {
  12342. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12343. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12344. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12345. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12346. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12347. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12348. }
  12349. else
  12350. {
  12351. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12352. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12353. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12354. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12355. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12356. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12357. }
  12358. string breakfastPriceStr = string.Empty,
  12359. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12360. governmentRentStr = string.Empty,
  12361. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12362. cityTaxStrStr = string.Empty,
  12363. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12364. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12365. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12366. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12367. int payDId = roomInfo?.PayDId ?? 0;
  12368. pcfds.Add(new HotelReservations_PCFD_View()
  12369. {
  12370. City = item.City,
  12371. HotelName = item.HotelName,
  12372. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12373. // SingleRoomCount = item.SingleRoomCount,
  12374. SingleRoomPrice = singleRoomFeeStr,
  12375. // DoubleRoomCount = item.DoubleRoomCount,
  12376. DoubleRoomPrice = doubleRoomFeeStr,
  12377. //SuiteRoomCount = item.SuiteRoomCount,
  12378. SuiteRoomPrice = suiteRoomFeeStr,
  12379. OtherRoomPrice = otherRoomFeeStr,
  12380. //OtherRoomCount = item.OtherRoomCount,
  12381. BreakfastPrice = breakfastPriceStr,
  12382. GovernmentRent = governmentRentStr,
  12383. CityTax = cityTaxStrStr,
  12384. RoomExplanation = item.RoomExplanation,
  12385. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12386. PayTime = roomInfo?.ConsumptionDate,
  12387. BankNo = roomInfo?.BankNo,
  12388. PayMoney = payMoneyStr,
  12389. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12390. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12391. CardPrice = cardPriceStr,
  12392. Remark = ccpInfo.Remark
  12393. });
  12394. }
  12395. #endregion
  12396. //载入模板
  12397. WorkbookDesigner designer = new WorkbookDesigner();
  12398. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12399. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12400. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12401. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12402. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12403. designer.SetDataSource("Opertor", userInfo.CnName);
  12404. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12405. dt.TableName = "ViewMyHotelReservations";
  12406. designer.SetDataSource(dt);
  12407. designer.Process();
  12408. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12409. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12410. designer.Workbook.Save(serverPath);
  12411. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12412. #region 删除指定行
  12413. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12414. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12415. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12416. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12417. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12418. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12419. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12420. cssIndex = dt.Columns["CityTax"].Ordinal,
  12421. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12422. remarkIndex = dt.Columns["Remark"].Ordinal;
  12423. //删除指定列
  12424. foreach (DataRow item in dt.Rows)
  12425. {
  12426. string singleStr = item["SingleRoomPrice"].ToString();
  12427. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12428. if (containsDigitButNotZero1) singleDel = false;
  12429. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12430. string doubleStr = item["DoubleRoomPrice"].ToString();
  12431. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12432. if (containsDigitButNotZero2) doubleDel = false;
  12433. string suiteStr = item["SuiteRoomPrice"].ToString();
  12434. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12435. if (containsDigitButNotZero3) suiteDel = false;
  12436. string otherStr = item["OtherRoomPrice"].ToString();
  12437. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12438. if (containsDigitButNotZero4) otherDel = false;
  12439. string zcStr = item["BreakfastPrice"].ToString();
  12440. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12441. if (containsDigitButNotZero5) zcDel = false;
  12442. string dsStr = item["GovernmentRent"].ToString();
  12443. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12444. if (containsDigitButNotZero6) dsDel = false;
  12445. string cssStr = item["CityTax"].ToString();
  12446. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12447. if (containsDigitButNotZero7) cssDel = false;
  12448. string cpStr = item["ConsumptionPatterns"].ToString();
  12449. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12450. string remarkStr = item["Remark"].ToString();
  12451. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12452. }
  12453. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12454. DeleteColumn(serverPath, cpIndex, cpDel);
  12455. DeleteColumn(serverPath, dsIndex, dsDel);
  12456. DeleteColumn(serverPath, cssIndex, cssDel);
  12457. DeleteColumn(serverPath, zcIndex, zcDel);
  12458. DeleteColumn(serverPath, otherIndex, otherDel);
  12459. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12460. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12461. DeleteColumn(serverPath, singleIndex, singleDel);
  12462. #endregion
  12463. //只保留第一个表格
  12464. DeleteSheet(serverPath);
  12465. return Ok(JsonView(true, "操作成功", url = rst));
  12466. }
  12467. return Ok(JsonView(false));
  12468. }
  12469. /// <summary>
  12470. /// 删除指定列
  12471. /// </summary>
  12472. /// <param name="file"></param>
  12473. /// <param name="columnIndex"></param>
  12474. /// <param name="isDel"></param>
  12475. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12476. {
  12477. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12478. //wb.Save(file);
  12479. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12480. if (sheet1 != null)
  12481. {
  12482. if (isDel)
  12483. {
  12484. Cells cells = sheet1.Cells;
  12485. cells.DeleteColumn(columnIndex);
  12486. }
  12487. }
  12488. wb.Save(file);
  12489. }
  12490. /// <summary>
  12491. /// 删除sheet
  12492. /// </summary>
  12493. /// <param name="file"></param>
  12494. /// <param name="sheetName"></param>
  12495. private void DeleteSheet(string file, string sheetName = "")
  12496. {
  12497. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12498. //wb.Save(file);
  12499. List<string> sheets = new List<string>();
  12500. foreach (var item in wb.Worksheets)
  12501. {
  12502. sheets.Add(item.Name);
  12503. }
  12504. if (sheets.Count > 0)
  12505. {
  12506. sheets.RemoveAt(0);//不删除第一个sheet
  12507. foreach (var item in sheets)
  12508. {
  12509. wb.Worksheets.RemoveAt(item);
  12510. }
  12511. }
  12512. wb.Save(file);
  12513. }
  12514. /// <summary>
  12515. /// 酒店预订
  12516. /// 确认单
  12517. /// </summary>
  12518. /// <param name="_dto"></param>
  12519. /// <returns></returns>
  12520. [HttpPost]
  12521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12522. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12523. {
  12524. try
  12525. {
  12526. #region 参数验证
  12527. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12528. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12529. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12530. #region 团组操作权限验证 76 酒店预定模块
  12531. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12532. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12533. #endregion
  12534. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12535. #region 页面操作权限验证
  12536. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12537. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12538. #endregion
  12539. #endregion
  12540. //团组信息
  12541. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12542. //酒店数据
  12543. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12544. if (listhoteldata.Count < 0)
  12545. {
  12546. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12547. }
  12548. //利datatable存储
  12549. DataTable dt = new DataTable();
  12550. dt.Columns.Add("CheckInDate", typeof(string));
  12551. dt.Columns.Add("City", typeof(string));
  12552. dt.Columns.Add("Hotel", typeof(string));
  12553. dt.Columns.Add("Room", typeof(string));
  12554. for (int i = 0; i < listhoteldata.Count; i++)
  12555. {
  12556. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12557. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12558. while (dayStart < dayEnd)
  12559. {
  12560. string temp = "";
  12561. DataRow row = dt.NewRow();
  12562. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12563. row["City"] = listhoteldata[i].City;
  12564. row["Hotel"] = listhoteldata[i].HotelName;
  12565. if (listhoteldata[i].SingleRoomCount > 0)
  12566. {
  12567. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12568. }
  12569. if (listhoteldata[i].DoubleRoomCount > 0)
  12570. {
  12571. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12572. }
  12573. if (listhoteldata[i].SuiteRoomCount > 0)
  12574. {
  12575. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12576. }
  12577. if (listhoteldata[i].OtherRoomCount > 0)
  12578. {
  12579. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12580. }
  12581. row["Room"] = temp;
  12582. dt.Rows.Add(row);
  12583. dayStart = dayStart.AddDays(1);
  12584. }
  12585. }
  12586. Dictionary<string, string> dic = new Dictionary<string, string>();
  12587. dic.Add("Dele", di.TeamName);
  12588. dic.Add("City", di.VisitCountry);
  12589. //模板路径
  12590. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12591. //载入模板
  12592. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12593. DocumentBuilder builder = new DocumentBuilder(doc);
  12594. foreach (var key in dic.Keys)
  12595. {
  12596. builder.MoveToBookmark(key);
  12597. builder.Write(dic[key]);
  12598. }
  12599. //获取word里所有表格
  12600. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12601. //获取所填表格的序数
  12602. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12603. var rowStart = tableOne.Rows[0]; //获取第1行
  12604. //循环赋值
  12605. for (int i = 0; i < dt.Rows.Count; i++)
  12606. {
  12607. builder.MoveToCell(0, i + 1, 0, 0);
  12608. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12609. builder.MoveToCell(0, i + 1, 1, 0);
  12610. builder.Write(dt.Rows[i]["City"].ToString());
  12611. builder.MoveToCell(0, i + 1, 2, 0);
  12612. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12613. builder.MoveToCell(0, i + 1, 3, 0);
  12614. builder.Write(dt.Rows[i]["Room"].ToString());
  12615. }
  12616. //删除多余行
  12617. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12618. {
  12619. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12620. }
  12621. string strFileName = di.TeamName + "酒店确认单.doc";
  12622. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12623. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12624. return Ok(JsonView(true, "成功", url));
  12625. }
  12626. catch (Exception ex)
  12627. {
  12628. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12629. }
  12630. }
  12631. #endregion
  12632. #region 团组状态
  12633. /// <summary>
  12634. /// 团组状态列表 Page
  12635. /// </summary>
  12636. /// <param name="dto">团组列表请求dto</param>
  12637. /// <returns></returns>
  12638. [HttpPost]
  12639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12640. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12641. {
  12642. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12643. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12644. {
  12645. string sqlWhere = string.Empty;
  12646. if (dto.IsSure == 0) //未完成
  12647. {
  12648. sqlWhere += string.Format(@" And IsSure = 0");
  12649. }
  12650. else if (dto.IsSure == 1) //已完成
  12651. {
  12652. sqlWhere += string.Format(@" And IsSure = 1");
  12653. }
  12654. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12655. {
  12656. string tj = dto.SearchCriteria;
  12657. 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}%')",
  12658. tj, tj, tj, tj, tj);
  12659. }
  12660. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12661. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12662. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12663. From (
  12664. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12665. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12666. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12667. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12668. From Grp_DelegationInfo gdi
  12669. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12670. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12671. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12672. Where gdi.IsDel = 0 {0}
  12673. ) temp ", sqlWhere);
  12674. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12675. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12676. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12677. }
  12678. else
  12679. {
  12680. return Ok(JsonView(false, "查询失败"));
  12681. }
  12682. }
  12683. /// <summary>
  12684. /// 团组状态
  12685. /// 设置操作完成
  12686. /// </summary>
  12687. /// <param name="dto">团组列表请求dto</param>
  12688. /// <returns></returns>
  12689. [HttpPost]
  12690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12691. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12692. {
  12693. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12694. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12695. {
  12696. Id = dto.Id,
  12697. IsSure = 1
  12698. };
  12699. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12700. .UpdateColumns(it => new { it.IsSure })
  12701. .WhereColumns(it => new { it.Id })
  12702. .ExecuteCommandAsync();
  12703. if (result > 0)
  12704. {
  12705. return Ok(JsonView(true, "操作完成!"));
  12706. }
  12707. return Ok(JsonView(false, "操作失败!"));
  12708. }
  12709. #endregion
  12710. #region 保险费用录入
  12711. /// <summary>
  12712. /// 根据团组Id查询保险费用列表
  12713. /// </summary>
  12714. /// <param name="dto"></param>
  12715. /// <returns></returns>
  12716. [HttpPost]
  12717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12718. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12719. {
  12720. Result groupData = await _customersRep.CustomersByDiId(dto);
  12721. if (groupData.Code != 0)
  12722. {
  12723. return Ok(JsonView(false, groupData.Msg));
  12724. }
  12725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12726. }
  12727. /// <summary>
  12728. /// 根据保险费用Id查询保险费用详细
  12729. /// </summary>
  12730. /// <param name="dto"></param>
  12731. /// <returns></returns>
  12732. [HttpPost]
  12733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12734. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12735. {
  12736. try
  12737. {
  12738. Result groupData = await _customersRep.CustomersById(dto);
  12739. if (groupData.Code != 0)
  12740. {
  12741. return Ok(JsonView(false, groupData.Msg));
  12742. }
  12743. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12744. }
  12745. catch (Exception ex)
  12746. {
  12747. return Ok(JsonView(false, ex.Message));
  12748. }
  12749. }
  12750. /// <summary>
  12751. /// 保险费用录入页面初始化绑定
  12752. /// </summary>
  12753. /// <param name="dto"></param>
  12754. /// <returns></returns>
  12755. [HttpPost]
  12756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12757. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12758. {
  12759. try
  12760. {
  12761. Result groupData = await _customersRep.CustomersInitialize(dto);
  12762. if (groupData.Code != 0)
  12763. {
  12764. return Ok(JsonView(false, groupData.Msg));
  12765. }
  12766. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12767. }
  12768. catch (Exception ex)
  12769. {
  12770. return Ok(JsonView(false, ex.Message));
  12771. }
  12772. }
  12773. /// <summary>
  12774. /// 保险费用操作(Status:1.新增,2.修改)
  12775. /// </summary>
  12776. /// <param name="dto"></param>
  12777. /// <returns></returns>
  12778. [HttpPost]
  12779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12780. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12781. {
  12782. Result groupData = await _customersRep.OpCustomers(dto);
  12783. if (groupData.Code != 0)
  12784. {
  12785. return Ok(JsonView(false, groupData.Msg));
  12786. }
  12787. #region 应用推送
  12788. try
  12789. {
  12790. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12791. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12792. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12793. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12794. //自动审核
  12795. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12796. //2024-10-21 新增LZ UID
  12797. var userIds = new List<int>() { 21 };
  12798. string title = $"系统通知";
  12799. var diId = dto.DiId;
  12800. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12801. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12802. string content = "";
  12803. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12804. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12805. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12806. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12807. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12808. }
  12809. catch (Exception ex)
  12810. {
  12811. }
  12812. #endregion
  12813. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12814. }
  12815. /// <summary>
  12816. /// 保险文件上传
  12817. /// </summary>
  12818. /// <param name="file"></param>
  12819. /// <returns></returns>
  12820. [HttpPost]
  12821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12822. public async Task<IActionResult> UploadCus(IFormFile file)
  12823. {
  12824. try
  12825. {
  12826. if (file != null)
  12827. {
  12828. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12829. //文件名称
  12830. string projectFileName = file.FileName;
  12831. //上传的文件的路径
  12832. string filePath = "";
  12833. if (!Directory.Exists(fileDir))
  12834. {
  12835. Directory.CreateDirectory(fileDir);
  12836. }
  12837. //上传的文件的路径
  12838. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12839. using (FileStream fs = System.IO.File.Create(filePath))
  12840. {
  12841. file.CopyTo(fs);
  12842. fs.Flush();
  12843. }
  12844. return Ok(JsonView(true, "上传成功!", projectFileName));
  12845. }
  12846. else
  12847. {
  12848. return Ok(JsonView(false, "上传失败!"));
  12849. }
  12850. }
  12851. catch (Exception ex)
  12852. {
  12853. return Ok(JsonView(false, "程序错误!"));
  12854. throw;
  12855. }
  12856. }
  12857. /// <summary>
  12858. /// 保险删除指定文件
  12859. /// </summary>
  12860. /// <param name="dto"></param>
  12861. /// <returns></returns>
  12862. [HttpPost]
  12863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12864. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12865. {
  12866. try
  12867. {
  12868. string filePath = "";
  12869. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12870. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12871. //int id = 0;
  12872. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12873. // 删除该文件
  12874. try
  12875. {
  12876. System.IO.File.Delete(filePath);
  12877. 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()
  12878. {
  12879. Attachment = "",
  12880. }).ExecuteCommandAsync();
  12881. if (result != 0)
  12882. {
  12883. return Ok(JsonView(true, "成功!"));
  12884. }
  12885. else
  12886. {
  12887. return Ok(JsonView(false, "失败!"));
  12888. }
  12889. }
  12890. catch (Exception)
  12891. {
  12892. 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()
  12893. {
  12894. Attachment = "",
  12895. }).ExecuteCommandAsync();
  12896. if (result != 0)
  12897. {
  12898. return Ok(JsonView(true, "成功!"));
  12899. }
  12900. else
  12901. {
  12902. return Ok(JsonView(false, "失败!"));
  12903. }
  12904. }
  12905. }
  12906. catch (Exception ex)
  12907. {
  12908. return Ok(JsonView(false, "程序错误!"));
  12909. throw;
  12910. }
  12911. }
  12912. /// <summary>
  12913. /// 保险费用操作(删除)
  12914. /// </summary>
  12915. /// <param name="dto"></param>
  12916. /// <returns></returns>
  12917. [HttpPost]
  12918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12919. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12920. {
  12921. try
  12922. {
  12923. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12924. if (!res)
  12925. {
  12926. return Ok(JsonView(false, "删除失败"));
  12927. }
  12928. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12929. {
  12930. IsDel = 1,
  12931. DeleteUserId = dto.DeleteUserId,
  12932. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12933. }).ExecuteCommandAsync();
  12934. return Ok(JsonView(true, "删除成功!"));
  12935. }
  12936. catch (Exception ex)
  12937. {
  12938. return Ok(JsonView(false, "程序错误!"));
  12939. throw;
  12940. }
  12941. }
  12942. #endregion
  12943. #region 接团客户名单 PageId 104
  12944. /// <summary>
  12945. /// 接团客户名单
  12946. /// 迁移数据(慎用!)
  12947. /// </summary>
  12948. /// <param name="dto"></param>
  12949. /// <returns></returns>
  12950. [HttpPost]
  12951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12952. public async Task<IActionResult> PostTourClientListChange()
  12953. {
  12954. try
  12955. {
  12956. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12957. //var groupClinetData1
  12958. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12959. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12960. int updateCount = 0;
  12961. if (oldOAClientList.Count > 0)
  12962. {
  12963. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12964. _sqlSugar.BeginTran();
  12965. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12966. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12967. foreach (var item in oldOAClientList)
  12968. {
  12969. int comId = 0;
  12970. string format = "yyyy-MM-dd HH:mm:ss";
  12971. string data11 = "1990-01-01 00:00";
  12972. var data1 = IsValidDate(item.OPdate, format);
  12973. if (data1) data11 = item.OPdate;
  12974. //客户公司验证
  12975. if (!string.IsNullOrEmpty(item.Company))
  12976. {
  12977. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12978. if (clientComInfo == null) // add
  12979. {
  12980. var addInfo = new Crm_CustomerCompany()
  12981. {
  12982. CompanyAbbreviation = "",
  12983. CompanyFullName = item.Company,
  12984. Address = "",
  12985. PostCodes = "",
  12986. LastedOpUserId = item.OPer,
  12987. LastedOpDt = Convert.ToDateTime(data11),
  12988. CreateUserId = item.OPer,
  12989. CreateTime = Convert.ToDateTime(data11),
  12990. IsDel = 0
  12991. };
  12992. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  12993. if (comId1 > 0) comId = comId1;
  12994. }
  12995. else comId = clientComInfo.Id;
  12996. }
  12997. //客户人员验证
  12998. int clientId = 0;
  12999. string name = item.LastName + item.Name;
  13000. if (!string.IsNullOrEmpty(name))
  13001. {
  13002. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  13003. if (clientInfo == null)
  13004. {
  13005. DateTime? dateTime = null;
  13006. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  13007. if (isDt) dateTime = birthDayDt;
  13008. var addInfo1 = new Crm_DeleClient()
  13009. {
  13010. CrmCompanyId = comId,
  13011. DiId = -1,
  13012. LastName = item.LastName,
  13013. FirstName = item.Name,
  13014. OldName = "",
  13015. Pinyin = item.Pinyin,
  13016. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  13017. Marriage = 0,
  13018. Phone = item.Phone,
  13019. Job = item.Job,
  13020. BirthDay = dateTime
  13021. };
  13022. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  13023. if (clientId1 > 0) clientId = clientId1;
  13024. }
  13025. else clientId = clientInfo.Id;
  13026. }
  13027. if (clientId < 1)
  13028. {
  13029. continue;
  13030. }
  13031. int airType = 0;
  13032. if (item.AirType == "超经舱") airType = 459;
  13033. else if (item.AirType == "公务舱") airType = 458;
  13034. else if (item.AirType == "经济舱") airType = 460;
  13035. else if (item.AirType == "其他") airType = 565;
  13036. else if (item.AirType == "头等舱") airType = 457;
  13037. var _TourClientListEntity = new Grp_TourClientList()
  13038. {
  13039. DiId = item.Diid,
  13040. ClientId = clientId,
  13041. CreateUserId = item.OPer,
  13042. CreateTime = Convert.ToDateTime(data11),
  13043. Remark = item.Remark,
  13044. IsDel = item.Isdel,
  13045. ShippingSpaceTypeId = airType,
  13046. ShippingSpaceSpecialNeeds = item.AirRemark,
  13047. HotelSpecialNeeds = item.RoomType
  13048. };
  13049. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  13050. if (_TourClientList > 0)
  13051. {
  13052. updateCount++;
  13053. }
  13054. }
  13055. _sqlSugar.CommitTran();
  13056. }
  13057. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  13058. }
  13059. catch (Exception ex)
  13060. {
  13061. _sqlSugar.RollbackTran();
  13062. return Ok(JsonView(false, ex.Message));
  13063. }
  13064. return Ok(JsonView(true));
  13065. }
  13066. private bool IsValidDate(string dateString, string format)
  13067. {
  13068. DateTime dateValue;
  13069. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  13070. return valid;
  13071. }
  13072. /// <summary>
  13073. /// 接团客户名单
  13074. /// 根据团组Id查询List
  13075. /// </summary>
  13076. /// <param name="dto"></param>
  13077. /// <returns></returns>
  13078. [HttpPost]
  13079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13080. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13081. {
  13082. #region 参数验证
  13083. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13084. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13085. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13086. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13087. #region 页面操作权限验证
  13088. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13089. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13090. #endregion
  13091. #endregion
  13092. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13093. if (viewData.Code != 0)
  13094. {
  13095. return Ok(JsonView(false, viewData.Msg));
  13096. }
  13097. return Ok(JsonView(viewData.Data));
  13098. }
  13099. /// <summary>
  13100. /// 接团客户名单
  13101. /// 基础数据 Init
  13102. /// </summary>
  13103. /// <param name="_dto"></param>
  13104. /// <returns></returns>
  13105. [HttpPost]
  13106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13107. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13108. {
  13109. #region 参数验证
  13110. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13111. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13112. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13113. #region 页面操作权限验证
  13114. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13115. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13116. #endregion
  13117. #endregion
  13118. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13119. }
  13120. /// <summary>
  13121. /// 接团客户名单
  13122. /// 根据 Id查询 Details
  13123. /// </summary>
  13124. /// <param name="_dto"></param>
  13125. /// <returns></returns>
  13126. [HttpPost]
  13127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13128. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13129. {
  13130. #region 参数验证
  13131. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13132. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13133. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13134. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13135. #region 页面操作权限验证
  13136. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13137. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13138. #endregion
  13139. #endregion
  13140. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13141. if (viewData.Code != 0)
  13142. {
  13143. return Ok(JsonView(false, viewData.Msg));
  13144. }
  13145. return Ok(JsonView(viewData.Data));
  13146. }
  13147. /// <summary>
  13148. /// 接团客户名单
  13149. /// Add Or Edit
  13150. /// </summary>
  13151. /// <param name="_dto"></param>
  13152. /// <returns></returns>
  13153. [HttpPost]
  13154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13155. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13156. {
  13157. #region 参数验证
  13158. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13159. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13160. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13161. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13162. #region 页面操作权限验证
  13163. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13164. if (_dto.Id == 0) //添加
  13165. {
  13166. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13167. }
  13168. else if (_dto.Id >= 0) //修改
  13169. {
  13170. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13171. }
  13172. #endregion
  13173. #endregion
  13174. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13175. if (viewData.Code != 0)
  13176. {
  13177. return Ok(JsonView(false, viewData.Msg));
  13178. }
  13179. return Ok(JsonView(true));
  13180. }
  13181. /// <summary>
  13182. /// 接团客户名单
  13183. /// AddMultiple(添加多个)
  13184. /// </summary>
  13185. /// <param name="_dto"></param>
  13186. /// <returns></returns>
  13187. [HttpPost]
  13188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13189. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13190. {
  13191. #region 参数验证
  13192. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13193. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13194. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13195. #region 页面操作权限验证
  13196. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13197. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13198. #endregion
  13199. #endregion
  13200. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13201. if (viewData.Code != 0)
  13202. {
  13203. return Ok(JsonView(false, viewData.Msg));
  13204. }
  13205. return Ok(JsonView(true));
  13206. }
  13207. /// <summary>
  13208. /// 接团客户名单
  13209. /// Del
  13210. /// </summary>
  13211. /// <param name="_dto"></param>
  13212. /// <returns></returns>
  13213. [HttpPost]
  13214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13215. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13216. {
  13217. #region 参数验证
  13218. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13219. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13221. #region 页面操作权限验证
  13222. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13223. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13224. #endregion
  13225. #endregion
  13226. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13227. if (viewData.Code != 0)
  13228. {
  13229. return Ok(JsonView(false, viewData.Msg));
  13230. }
  13231. return Ok(JsonView(true));
  13232. }
  13233. /// <summary>
  13234. /// 接团客户名单
  13235. /// 文件下载 客户名单
  13236. /// </summary>
  13237. /// <param name="_dto"></param>
  13238. /// <returns></returns>
  13239. [HttpPost]
  13240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13241. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13242. {
  13243. #region 参数验证
  13244. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13245. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13246. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13247. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13248. #region 页面操作权限验证
  13249. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13250. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13251. #endregion
  13252. #endregion
  13253. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13254. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13255. From Grp_TourClientList tcl
  13256. Left Join
  13257. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13258. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13259. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13260. From Crm_DeleClient dc
  13261. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13262. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13263. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13264. Where dc.IsDel = 0) temp
  13265. On temp.DcId =tcl.ClientId
  13266. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13267. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13268. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13269. //载入模板
  13270. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13271. if (_dto.Language == 1)
  13272. {
  13273. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13274. }
  13275. //载入模板
  13276. var doc = new Document(tempPath);
  13277. DocumentBuilder builder = new DocumentBuilder(doc);
  13278. //获取word里所有表格
  13279. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13280. //获取所填表格的序数
  13281. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13282. var rowStart = tableOne.Rows[0]; //获取第1行
  13283. if (_dto.Language == 0)
  13284. {
  13285. //循环赋值
  13286. for (int i = 0; i < DcList.Count; i++)
  13287. {
  13288. builder.MoveToCell(0, i + 1, 0, 0);
  13289. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13290. builder.MoveToCell(0, i + 1, 1, 0);
  13291. int sex = DcList[i].Sex;
  13292. string sexStr = string.Empty;
  13293. if (sex == 0) sexStr = "男";
  13294. else if (sex == 1) sexStr = "女";
  13295. else sexStr = "未设置";
  13296. builder.Write(sexStr);
  13297. builder.MoveToCell(0, i + 1, 2, 0);
  13298. string birthDay = DcList[i].BirthDay;
  13299. string birthDayStr = string.Empty;
  13300. if (!string.IsNullOrEmpty(birthDay))
  13301. {
  13302. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13303. }
  13304. builder.Write(birthDayStr);
  13305. builder.MoveToCell(0, i + 1, 3, 0);
  13306. string company = "";
  13307. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13308. {
  13309. company = DcList[i].CompanyFullName.ToString();
  13310. }
  13311. builder.Write(company);
  13312. builder.MoveToCell(0, i + 1, 4, 0);
  13313. builder.Write(DcList[i].Job);
  13314. }
  13315. }
  13316. else if (_dto.Language == 1)
  13317. {
  13318. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13319. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13320. List<string> transArrayStr = new List<string>();
  13321. string transStrRes1 = "";
  13322. for (int i = 0; i < DcList.Count; i++)
  13323. {
  13324. var dc = DcList[i];
  13325. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13326. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13327. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13328. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13329. else transStrRes1 += $"{str1}|";
  13330. }
  13331. //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";
  13332. string transStrRes = "";
  13333. if (transStrRes1.Length > 0)
  13334. {
  13335. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13336. }
  13337. //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
  13338. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13339. //List<string> transArray = new List<string> { };
  13340. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13341. if (transStrRes.Contains("|"))
  13342. {
  13343. string[] transArray1 = transStrRes.Split('|');
  13344. if (transArray1.Length > 0)
  13345. {
  13346. foreach (var item in transArray1)
  13347. {
  13348. if (item.Contains("&"))
  13349. {
  13350. string[] transArray2 = item.Split('&');
  13351. int index = 0;
  13352. string companyName = "", job = "";
  13353. if (transArray2.Length > 0)
  13354. {
  13355. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13356. if (1 < transArray2.Length) companyName = transArray2[1];
  13357. if (2 < transArray2.Length) job = transArray2[2];
  13358. }
  13359. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13360. }
  13361. }
  13362. }
  13363. }
  13364. //循环赋值
  13365. for (int i = 0; i < DcList.Count; i++)
  13366. {
  13367. string PYName = "";
  13368. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13369. {
  13370. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13371. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13372. PYName = PY_First + " " + PY_Last;
  13373. }
  13374. else
  13375. {
  13376. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13377. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13378. PYName = PY_First + " " + PY_Last;
  13379. }
  13380. builder.MoveToCell(0, i + 1, 0, 0);
  13381. builder.Write(PYName);
  13382. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13383. builder.MoveToCell(0, i + 1, 1, 0);
  13384. builder.Write(sex);
  13385. DateTime birthDt;
  13386. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13387. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13388. builder.MoveToCell(0, i + 1, 2, 0);
  13389. builder.Write(birthday);
  13390. string company = string.Empty, job = string.Empty;
  13391. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13392. if (dcTransInfo != null)
  13393. {
  13394. company = dcTransInfo.CompanyName;
  13395. job = dcTransInfo.Job;
  13396. }
  13397. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13398. {
  13399. //查询对照表
  13400. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13401. if (tempCec != null)
  13402. {
  13403. company = tempCec.enName;
  13404. }
  13405. //翻译
  13406. else
  13407. {
  13408. }
  13409. }
  13410. builder.MoveToCell(0, i + 1, 3, 0);
  13411. builder.Write(company);
  13412. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13413. {
  13414. //查询对照表
  13415. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13416. if (tempPec != null)
  13417. {
  13418. job = tempPec.enName;
  13419. }
  13420. //翻译
  13421. else
  13422. {
  13423. }
  13424. }
  13425. builder.MoveToCell(0, i + 1, 4, 0);
  13426. builder.Write(job);
  13427. }
  13428. }
  13429. //删除多余行
  13430. while (tableOne.Rows.Count > DcList.Count + 1)
  13431. {
  13432. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13433. }
  13434. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13435. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13436. doc.Save(fileDir);
  13437. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13438. return Ok(JsonView(true, "操作成功!", Url));
  13439. }
  13440. private class TranslateInfo
  13441. {
  13442. public int Index { get; set; }
  13443. public string CompanyName { get; set; }
  13444. public string Job { get; set; }
  13445. }
  13446. #endregion
  13447. #region 团组倒推表
  13448. /// <summary>
  13449. /// 倒推表基础数据
  13450. /// Init
  13451. /// </summary>
  13452. /// <param name="dto"></param>
  13453. /// <returns></returns>
  13454. [HttpPost]
  13455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13456. public async Task<IActionResult> PostInvertedListInit()
  13457. {
  13458. var viewData = await _invertedListRep._Init();
  13459. if (viewData.Code != 0)
  13460. {
  13461. return Ok(JsonView(false, viewData.Msg));
  13462. }
  13463. return Ok(JsonView(viewData.Data));
  13464. }
  13465. /// <summary>
  13466. /// 倒推表
  13467. /// Info
  13468. /// </summary>
  13469. /// <param name="dto"></param>
  13470. /// <returns></returns>
  13471. [HttpPost]
  13472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13473. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13474. {
  13475. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13476. if (viewData.Code != 0)
  13477. {
  13478. return Ok(JsonView(false, viewData.Msg));
  13479. }
  13480. return Ok(JsonView(viewData.Data));
  13481. }
  13482. /// <summary>
  13483. /// 倒推表
  13484. /// Create
  13485. /// </summary>
  13486. /// <param name="dto"></param>
  13487. /// <returns></returns>
  13488. [HttpPost]
  13489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13490. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13491. {
  13492. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13493. if (viewData.Code != 0)
  13494. {
  13495. return Ok(JsonView(false, viewData.Msg));
  13496. }
  13497. return Ok(JsonView(viewData.Data));
  13498. }
  13499. /// <summary>
  13500. /// 倒推表
  13501. /// Update
  13502. /// </summary>
  13503. /// <param name="dto"></param>
  13504. /// <returns></returns>
  13505. [HttpPost]
  13506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13507. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13508. {
  13509. var viewData = await _invertedListRep._Update(dto);
  13510. if (viewData.Code != 0)
  13511. {
  13512. return Ok(JsonView(false, viewData.Msg));
  13513. }
  13514. return Ok(JsonView(viewData.Data));
  13515. }
  13516. /// <summary>
  13517. /// 倒推表
  13518. /// File Download
  13519. /// </summary>
  13520. /// <param name="dto"></param>
  13521. /// <returns></returns>
  13522. [HttpPost]
  13523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13524. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13525. {
  13526. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13527. if (info2.Code != 0)
  13528. {
  13529. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13530. }
  13531. var info1 = info2.Data as InvertedListInfoView;
  13532. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13533. string teamName = "";
  13534. if (info != null) teamName = info.TeamName;
  13535. //载入模板
  13536. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13537. DocumentBuilder builder = new DocumentBuilder(doc);
  13538. //利用键值对存放数据
  13539. Dictionary<string, string> dic = new Dictionary<string, string>();
  13540. dic.Add("TeamName", teamName);
  13541. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13542. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13543. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13544. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13545. dic.Add("SQRemark", info1.ApprovalRemark);
  13546. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13547. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13548. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13549. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13550. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13551. dic.Add("QZRemark", info1.VisaInformationRemark);
  13552. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13553. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13554. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13555. dic.Add("CQRemark", info1.IssueVisaRemark);
  13556. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13557. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13558. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13559. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13560. #region 填充word模板书签内容
  13561. foreach (var key in dic.Keys)
  13562. {
  13563. builder.MoveToBookmark(key);
  13564. builder.Write(dic[key]);
  13565. }
  13566. #endregion
  13567. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13568. string fileName = $"{teamName}团出行准备流程表.doc";
  13569. string filePath = fileDir + $@"InvertedList/{fileName}";
  13570. doc.Save(filePath);
  13571. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13572. return Ok(JsonView(true, "操作成功!", Url));
  13573. }
  13574. #endregion
  13575. #region 三公签证费用(签证费、代办费)
  13576. /// <summary>
  13577. /// 三公签证费用(签证费、代办费)
  13578. /// List
  13579. /// </summary>
  13580. /// <returns></returns>
  13581. [HttpPost]
  13582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13583. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13584. {
  13585. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13586. if (_view.Code != 0)
  13587. {
  13588. return Ok(JsonView(false, _view.Msg));
  13589. }
  13590. return Ok(JsonView(true, "操作成功!", _view.Data));
  13591. }
  13592. /// <summary>
  13593. /// 三公签证费用(签证费、代办费)
  13594. /// Add Or Update
  13595. /// </summary>
  13596. /// <returns></returns>
  13597. [HttpPost]
  13598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13599. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13600. {
  13601. var _view = await _visaFeeInfoRep._Update(_dto);
  13602. if (_view.Code != 0)
  13603. {
  13604. return Ok(JsonView(false, _view.Msg));
  13605. }
  13606. return Ok(JsonView(true, _view.Msg));
  13607. }
  13608. #endregion
  13609. #region 酒店询价
  13610. /// <summary>
  13611. /// 酒店询价
  13612. /// Init
  13613. /// </summary>
  13614. /// <param name="dto"></param>
  13615. /// <returns></returns>
  13616. [HttpPost]
  13617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13618. public async Task<IActionResult> PostHotelInquiryInit()
  13619. {
  13620. var res = await _hotelInquiryRep._Init();
  13621. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13622. return Ok(JsonView(true, res.Msg, res.Data));
  13623. }
  13624. /// <summary>
  13625. /// 酒店询价
  13626. /// page Item
  13627. /// </summary>
  13628. /// <param name="_dto"></param>
  13629. /// <returns></returns>
  13630. [HttpPost]
  13631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13632. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13633. {
  13634. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13635. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13636. var view = res.Data as PageDataViewBase;
  13637. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13638. }
  13639. /// <summary>
  13640. /// 酒店询价
  13641. /// info
  13642. /// </summary>
  13643. /// <param name="_dto"></param>
  13644. /// <returns></returns>
  13645. [HttpPost]
  13646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13647. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13648. {
  13649. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13650. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13651. return Ok(JsonView(true, res.Msg, res.Data));
  13652. }
  13653. /// <summary>
  13654. /// 酒店询价
  13655. /// Add Or Edit
  13656. /// </summary>
  13657. /// <param name="_dto"></param>
  13658. /// <returns></returns>
  13659. [HttpPost]
  13660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13661. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13662. {
  13663. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13664. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13665. return Ok(JsonView(true, res.Msg, res.Data));
  13666. }
  13667. /// <summary>
  13668. /// 酒店询价
  13669. /// Del
  13670. /// </summary>
  13671. /// <param name="_dto"></param>
  13672. /// <returns></returns>
  13673. [HttpPost]
  13674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13675. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13676. {
  13677. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13678. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13679. return Ok(JsonView(true, res.Msg, res.Data));
  13680. }
  13681. #endregion
  13682. #region 下载匹配op行程单
  13683. /// <summary>
  13684. /// 匹配op行程单
  13685. /// Init
  13686. /// </summary>
  13687. /// <param name="dto">团组列表请求dto</param>
  13688. /// <returns></returns>
  13689. [HttpPost]
  13690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13691. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13692. {
  13693. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13694. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13695. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13696. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13697. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13698. .Where(it => it.IsDel == 0)
  13699. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13700. .OrderByDescending(it => it.CreateUserId)
  13701. .ToList();
  13702. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13703. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13704. var diids = groupInfos.Select(it => it.Id).ToList();
  13705. List<string> countrys = new List<string>();
  13706. foreach (var item in country)
  13707. {
  13708. var data = _groupRepository.FormartTeamName(item);
  13709. var dataArray = _groupRepository.GroupSplitCountry(data);
  13710. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13711. }
  13712. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13713. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13714. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13715. foreach (var item in areaItem)
  13716. {
  13717. string areaStr = item.Value;
  13718. if (!string.IsNullOrEmpty(areaStr))
  13719. {
  13720. string[] str1 = areaStr.Split("-");
  13721. if (str1.Length > 0)
  13722. {
  13723. areaArray.AddRange(str1);
  13724. }
  13725. }
  13726. }
  13727. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13728. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13729. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13730. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13731. .ToList();
  13732. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13733. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13734. .Where(it => countriesIds.Contains(it.Id))
  13735. .Select(it => new { it.Id, Name = it.Name_CN })
  13736. .ToList();
  13737. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13738. .Select(it => it.TeamName).ToList();
  13739. stopwatch.Stop();
  13740. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13741. }
  13742. ///// <summary>
  13743. ///// 匹配op行程单
  13744. ///// Init 查询区域数据
  13745. ///// </summary>
  13746. ///// <param name="dto">团组列表请求dto</param>
  13747. ///// <returns></returns>
  13748. //[HttpPost]
  13749. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13750. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13751. //{
  13752. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13753. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13754. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13755. // if (string.IsNullOrEmpty(countriesDataStr))
  13756. // {
  13757. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13758. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13759. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13760. // }
  13761. // else
  13762. // {
  13763. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13764. // }
  13765. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13766. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13767. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13768. // List<dynamic> childList = new List<dynamic>();
  13769. // int parentId = dto.CountriesId;
  13770. // if (provinceData.Count > 1)
  13771. // {
  13772. // foreach (var item1 in provinceData)
  13773. // {
  13774. // List<dynamic> childList1 = new List<dynamic>();
  13775. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13776. // foreach (var item2 in citiesData1)
  13777. // {
  13778. // List<dynamic> childList2 = new List<dynamic>();
  13779. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13780. // foreach (var item3 in countiesData1)
  13781. // {
  13782. // childList2.Add(new
  13783. // {
  13784. // id = item3.Id,
  13785. // parentId = item2.Id,
  13786. // level = "district",
  13787. // name = item3.Name_CN,
  13788. // });
  13789. // }
  13790. // childList1.Add(new
  13791. // {
  13792. // id = item2.Id,
  13793. // parentId = item1.Id,
  13794. // level = "city",
  13795. // name = item2.Name_CN,
  13796. // childList = childList2
  13797. // });
  13798. // }
  13799. // childList.Add(new
  13800. // {
  13801. // id = item1.Id,
  13802. // parentId = parentId,
  13803. // level = "province",
  13804. // name = item1.Name_CN,
  13805. // childList = childList1
  13806. // });
  13807. // }
  13808. // //城市
  13809. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13810. // foreach (var item2 in citiesData2)
  13811. // {
  13812. // List<dynamic> childList22 = new List<dynamic>();
  13813. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13814. // foreach (var item3 in countiesData1)
  13815. // {
  13816. // childList22.Add(new
  13817. // {
  13818. // id = item3.Id,
  13819. // parentId = item2.Id,
  13820. // level = "district",
  13821. // name = item3.Name_CN,
  13822. // });
  13823. // }
  13824. // childList.Add(new
  13825. // {
  13826. // id = item2.Id,
  13827. // parentId = parentId,
  13828. // level = "city",
  13829. // name = item2.Name_CN,
  13830. // childList = childList22
  13831. // });
  13832. // }
  13833. // }
  13834. // else
  13835. // {
  13836. // foreach (var item2 in citiesData)
  13837. // {
  13838. // string cname = item2.Name_CN;
  13839. // List<dynamic> childList1 = new List<dynamic>();
  13840. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13841. // foreach (var item3 in countiesData1)
  13842. // {
  13843. // childList1.Add(new
  13844. // {
  13845. // Id = item3.Id,
  13846. // parentId = item2.Id,
  13847. // level = "district",
  13848. // name = item3.Name_CN
  13849. // });
  13850. // }
  13851. // childList.Add(new
  13852. // {
  13853. // id = item2.Id,
  13854. // parentId = parentId,
  13855. // level = "city",
  13856. // name = item2.Name_CN,
  13857. // childList = childList1
  13858. // });
  13859. // }
  13860. // }
  13861. // stopwatch.Stop();
  13862. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13863. //}
  13864. /// <summary>
  13865. /// 匹配op行程单
  13866. /// 接团信息列表 Page
  13867. /// </summary>
  13868. /// <param name="dto">团组列表请求dto</param>
  13869. /// <returns></returns>
  13870. [HttpPost]
  13871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13872. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13873. {
  13874. var swatch = new Stopwatch();
  13875. swatch.Start();
  13876. #region 参数验证
  13877. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13878. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13880. #region 页面操作权限验证
  13881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13882. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13883. #endregion
  13884. #endregion
  13885. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13886. {
  13887. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13888. string sqlWhere = "";
  13889. if (!string.IsNullOrEmpty(dto.Country))
  13890. {
  13891. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13892. }
  13893. if (!string.IsNullOrEmpty(dto.Area))
  13894. {
  13895. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13896. }
  13897. if (!string.IsNullOrEmpty(dto.TeamName))
  13898. {
  13899. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13900. }
  13901. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13902. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13903. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13904. swatch.Stop();
  13905. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13906. }
  13907. else
  13908. {
  13909. return Ok(JsonView(false, "查询失败"));
  13910. }
  13911. }
  13912. /// <summary>
  13913. /// 匹配op行程单
  13914. /// 行程单下载
  13915. /// </summary>
  13916. /// <param name="dto">团组列表请求dto</param>
  13917. /// <returns></returns>
  13918. [HttpPost]
  13919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13920. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13921. {
  13922. #region 参数验证
  13923. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13924. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13925. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13926. #region 页面操作权限验证
  13927. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13928. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13929. #endregion
  13930. #endregion
  13931. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13932. {
  13933. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13934. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13935. }
  13936. else
  13937. {
  13938. return Ok(JsonView(false, "下载失败!"));
  13939. }
  13940. }
  13941. #endregion
  13942. #region 国家信息 数据 注释
  13943. //[HttpPost]
  13944. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13945. //{
  13946. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13947. // foreach (var item in dto)
  13948. // {
  13949. // infos.Add(new Grp_GroupsTaskAssignment()
  13950. // {
  13951. // DIId = item,
  13952. // CTId = 82,
  13953. // UId = 248,
  13954. // IsEnable = 1,
  13955. // CreateUserId = 233,
  13956. // CreateTime = DateTime.Now,
  13957. // IsDel = 0
  13958. // });
  13959. // infos.Add(new Grp_GroupsTaskAssignment()
  13960. // {
  13961. // DIId = item,
  13962. // CTId = 82,
  13963. // UId = 286,
  13964. // IsEnable = 1,
  13965. // CreateUserId = 233,
  13966. // CreateTime = DateTime.Now,
  13967. // IsDel = 0
  13968. // });
  13969. // }
  13970. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13971. // return Ok("操作成功");
  13972. //}
  13973. //public class paramJsonDto
  13974. //{
  13975. // public List<CountriesInfo> str { get; set; }
  13976. //}
  13977. //[HttpPost]
  13978. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13979. //{
  13980. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13981. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  13982. // List<Sys_Cities> cities = new List<Sys_Cities>();
  13983. // List<Sys_Cities> districts = new List<Sys_Cities>();
  13984. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13985. // _sqlSugar.BeginTran();
  13986. // int countitiesIndex = 0;
  13987. // foreach (var item in dto.str)
  13988. // {
  13989. // dynamic data = item.c;
  13990. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  13991. // if (data != null)
  13992. // {
  13993. // countitiesIndex++;
  13994. // foreach (var item1 in data)
  13995. // {
  13996. // string cnname = item1.cn;
  13997. // string enname = item1.en;
  13998. // Sys_Cities provinceInfo = new Sys_Cities()
  13999. // {
  14000. // CountriesId = countriesId,
  14001. // Name_CN = cnname,
  14002. // Name_EN = enname,
  14003. // ParentId = 0,
  14004. // IsCapital = 1,
  14005. // CreateUserId = 208,
  14006. // CreateTime = DateTime.Now,
  14007. // IsDel = 0
  14008. // };
  14009. // if (item1.lv == "province") //省份
  14010. // {
  14011. // provinceInfo.Level = 1;
  14012. // int provinceId = 0;
  14013. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  14014. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  14015. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14016. // var data1 = item1.c;
  14017. // foreach (var item2 in data1)
  14018. // {
  14019. // if (item2.lv == "city")
  14020. // {
  14021. // string citycnname = item2.cn;
  14022. // string cityenname = item2.en;
  14023. // Sys_Cities cityInfo = new Sys_Cities()
  14024. // {
  14025. // CountriesId = countriesId,
  14026. // ParentId = provinceId,
  14027. // Level = 2,
  14028. // Name_CN = citycnname,
  14029. // Name_EN = cityenname,
  14030. // IsCapital = 1,
  14031. // CreateUserId = 208,
  14032. // CreateTime = DateTime.Now,
  14033. // IsDel = 0
  14034. // };
  14035. // if (item2.c != null)
  14036. // {
  14037. // int cityId = 0;
  14038. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  14039. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14040. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  14041. // foreach (var item3 in item2.c)
  14042. // {
  14043. // if (item3.lv == "district")
  14044. // {
  14045. // var districtInfo = new Sys_Cities()
  14046. // {
  14047. // CountriesId = countriesId,
  14048. // Name_CN = item3.cn,
  14049. // Name_EN = item3.en,
  14050. // Level = 3,
  14051. // ParentId = cityId,
  14052. // IsCapital = 1,
  14053. // CreateUserId = 208,
  14054. // CreateTime = DateTime.Now,
  14055. // IsDel = 0
  14056. // };
  14057. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14058. // //{
  14059. // districts.Add(districtInfo);
  14060. // //}
  14061. // }
  14062. // }
  14063. // }
  14064. // else
  14065. // {
  14066. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  14067. // //{
  14068. // cities.Add(cityInfo);
  14069. // //}
  14070. // }
  14071. // }
  14072. // }
  14073. // }
  14074. // else if (item1.lv == "city")//城市
  14075. // {
  14076. // provinceInfo.Level = 2;
  14077. // if (item1.c != null)
  14078. // {
  14079. // int cityId = 0;
  14080. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14081. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14082. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14083. // foreach (var item3 in item1.c)
  14084. // {
  14085. // if (item3.lv == "district")
  14086. // {
  14087. // var districtInfo = new Sys_Cities()
  14088. // {
  14089. // CountriesId = countriesId,
  14090. // Name_CN = item3.cn,
  14091. // Name_EN = item3.en,
  14092. // Level = 3,
  14093. // ParentId = cityId,
  14094. // IsCapital = 1,
  14095. // CreateUserId = 208,
  14096. // CreateTime = DateTime.Now,
  14097. // IsDel = 0
  14098. // };
  14099. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14100. // //{
  14101. // districts.Add(districtInfo);
  14102. // //}
  14103. // }
  14104. // }
  14105. // }
  14106. // else
  14107. // {
  14108. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14109. // //{
  14110. // cities.Add(provinceInfo);
  14111. // //}
  14112. // }
  14113. // }
  14114. // }
  14115. // }
  14116. // }
  14117. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14118. // cities = cities.Distinct().ToList();
  14119. // districts = districts.Distinct().ToList();
  14120. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14121. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14122. // cities.AddRange(districts);
  14123. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14124. // //_sqlSugar.RollbackTran();
  14125. // _sqlSugar.CommitTran();
  14126. // return Ok(JsonView(false, "操作成功!"));
  14127. //}
  14128. //[HttpPost]
  14129. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14130. //{
  14131. // List<CountitiesInfo> infos = dto.MyProperty;
  14132. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14133. // _sqlSugar.BeginTran();
  14134. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14135. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14136. // foreach (var item in infos)
  14137. // {
  14138. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14139. // if (countryInfo != null)
  14140. // {
  14141. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14142. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14143. // if (cityInfo1 != null)
  14144. // {
  14145. // cityInfo1.IsCapital = 0;
  14146. // cityInfos.Add(cityInfo1);
  14147. // }
  14148. // }
  14149. // }
  14150. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14151. // .UpdateColumns(it => it.IsCapital)
  14152. // .WhereColumns(it => it.Id)
  14153. // .ExecuteCommand();
  14154. // //_sqlSugar.RollbackTran();
  14155. // _sqlSugar.CommitTran();
  14156. // return Ok(JsonView(false, "操作成功!"));
  14157. //}
  14158. //public class CounrtiesDto
  14159. //{
  14160. // public List<CountitiesInfo> MyProperty { get; set; }
  14161. //}
  14162. //public class CountitiesInfo
  14163. //{
  14164. // /// <summary>
  14165. // /// 圣约翰
  14166. // /// </summary>
  14167. // public string capital_name_chinese { get; set; }
  14168. // /// <summary>
  14169. // ///
  14170. // /// </summary>
  14171. // public string capital_name { get; set; }
  14172. // /// <summary>
  14173. // ///
  14174. // /// </summary>
  14175. // public string country_type { get; set; }
  14176. // /// <summary>
  14177. // /// 安提瓜和巴布达
  14178. // /// </summary>
  14179. // public string country_name_chinese { get; set; }
  14180. // /// <summary>
  14181. // /// 安提瓜和巴布达
  14182. // /// </summary>
  14183. // public string country_name_chinese_short { get; set; }
  14184. // /// <summary>
  14185. // /// 安提瓜和巴布达
  14186. // /// </summary>
  14187. // public string country_name_chinese_UN { get; set; }
  14188. // /// <summary>
  14189. // ///
  14190. // /// </summary>
  14191. // public string country_name_english_abbreviation { get; set; }
  14192. // /// <summary>
  14193. // ///
  14194. // /// </summary>
  14195. // public string country_name_english_formal { get; set; }
  14196. // /// <summary>
  14197. // ///
  14198. // /// </summary>
  14199. // public string country_name_english_UN { get; set; }
  14200. // /// <summary>
  14201. // ///
  14202. // /// </summary>
  14203. // public string continent_name { get; set; }
  14204. // /// <summary>
  14205. // ///
  14206. // /// </summary>
  14207. // public string subregion_name { get; set; }
  14208. // /// <summary>
  14209. // ///
  14210. // /// </summary>
  14211. // public string country_code2 { get; set; }
  14212. // /// <summary>
  14213. // ///
  14214. // /// </summary>
  14215. // public string country_code3 { get; set; }
  14216. // /// <summary>
  14217. // ///
  14218. // /// </summary>
  14219. // public string phone_code { get; set; }
  14220. //}
  14221. //public class CountriesInfo : BasicInfo
  14222. //{
  14223. // public List<CitiesInfo> c { get; set; }
  14224. //}
  14225. //public class CitiesInfo : BasicInfo
  14226. //{
  14227. // public List<AreaInfo> c { get; set; }
  14228. //}
  14229. //public class AreaInfo : BasicInfo
  14230. //{
  14231. // public List<AreaInfo> c { get; set; }
  14232. //}
  14233. //public class BasicInfo
  14234. //{
  14235. // public string code { get; set; }
  14236. // public string cn { get; set; }
  14237. // public string lv { get; set; }
  14238. // public string en { get; set; }
  14239. //}
  14240. #endregion
  14241. #region 查看邀请方
  14242. /// <summary>
  14243. /// 查看邀请方
  14244. /// 邀请方信息 Init
  14245. /// </summary>
  14246. /// <param name="dto"></param>
  14247. /// <returns></returns>
  14248. [HttpPost]
  14249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14250. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14251. {
  14252. string sqlWhere = string.Empty;
  14253. if (!string.IsNullOrEmpty(dto.Search))
  14254. {
  14255. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14256. }
  14257. string sql = string.Format($@"Select
  14258. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14259. Id,
  14260. UnitName
  14261. From Res_InvitationOfficialActivityData
  14262. Where IsDel = 0
  14263. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14264. RefAsync<int> total = 0;
  14265. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14266. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14267. }
  14268. /// <summary>
  14269. /// 查看邀请方
  14270. /// 国家信息 Init
  14271. /// </summary>
  14272. /// <param name="dto"></param>
  14273. /// <returns></returns>
  14274. [HttpPost]
  14275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14276. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14277. {
  14278. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14279. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14280. var diids = groupInfos.Select(it => it.Id).ToList();
  14281. List<string> countrys = new List<string>();
  14282. foreach (var item in country)
  14283. {
  14284. var data = _groupRepository.FormartTeamName(item);
  14285. var dataArray = _groupRepository.GroupSplitCountry(data);
  14286. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14287. }
  14288. countrys = countrys.Distinct().ToList();
  14289. for (int i = 0; i < countrys.Count; i++)
  14290. {
  14291. string item = countrys[i];
  14292. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14293. {
  14294. countrys.Remove(item);
  14295. i--;
  14296. }
  14297. }
  14298. RefAsync<int> total = 0;
  14299. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14300. .Where(it => countrys.Contains(it.Name_CN))
  14301. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14302. .Select(it => new { id = it.Id, name = it.Name_CN })
  14303. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14304. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14305. }
  14306. /// <summary>
  14307. /// 查看邀请方
  14308. /// 城市信息 Init
  14309. /// </summary>
  14310. /// <param name="dto"></param>
  14311. /// <returns></returns>
  14312. [HttpPost]
  14313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14314. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14315. {
  14316. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14317. RefAsync<int> total = 0;
  14318. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14319. .Where(it => it.CountriesId == dto.CountiesId)
  14320. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14321. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14322. .Select(it => new { id = it.Id, name = it.Name_CN })
  14323. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14324. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14325. }
  14326. /// <summary>
  14327. /// 查看邀请方
  14328. /// 团组名称 Init
  14329. /// </summary>
  14330. /// <param name="dto"></param>
  14331. /// <returns></returns>
  14332. [HttpPost]
  14333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14334. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14335. {
  14336. var watch = new Stopwatch();
  14337. watch.Start();
  14338. RefAsync<int> total = 0;
  14339. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14340. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14341. .Where((oa, di) => oa.IsDel == 0)
  14342. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14343. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14344. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14345. .Distinct()
  14346. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14347. watch.Stop();
  14348. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14349. }
  14350. /// <summary>
  14351. /// 查看邀请方
  14352. /// 团组 & 邀请方信息
  14353. /// </summary>
  14354. /// <param name="dto"></param>
  14355. /// <returns></returns>
  14356. [HttpPost]
  14357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14358. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14359. {
  14360. var watch = new Stopwatch();
  14361. watch.Start();
  14362. RefAsync<int> total = 0;
  14363. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14364. .AS("Grp_DelegationInfo")
  14365. .Includes(x => x.InvitingInfos)
  14366. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14367. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14368. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14369. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14370. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14371. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14372. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14373. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14374. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14375. infos.ForEach(x =>
  14376. {
  14377. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14378. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14379. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14380. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14381. });
  14382. watch.Stop();
  14383. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14384. }
  14385. #endregion
  14386. #region 报批行程
  14387. /// <summary>
  14388. /// 报批行程初始化
  14389. /// </summary>
  14390. /// <param name="dto"></param>
  14391. /// <returns></returns>
  14392. [HttpPost]
  14393. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14394. {
  14395. const int chiNumber = 5;
  14396. var jw = JsonView(false);
  14397. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14398. var group = groupList.First();
  14399. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14400. group = groupList.First(x => x.Id == diid);
  14401. if (group == null)
  14402. {
  14403. jw.Msg = "暂无团组!";
  14404. return Ok(jw);
  14405. }
  14406. var data = new
  14407. {
  14408. groupList = groupList.Select(x => new
  14409. {
  14410. x.TeamName,
  14411. x.Id
  14412. }),
  14413. content = new ArrayList(),
  14414. groupInfo = new
  14415. {
  14416. group.VisitDays,
  14417. group.TourCode,
  14418. group.VisitPNumber,
  14419. group.TeamName,
  14420. group.Id,
  14421. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14422. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14423. },
  14424. };
  14425. var resultArr = new ArrayList();
  14426. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14427. if (content.Count == 0)
  14428. {
  14429. var stay = "-";
  14430. var cityPath = "-";
  14431. //添加城市路径以及住宿地
  14432. //黑屏代码数据
  14433. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14434. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14435. {
  14436. jw = JsonView(true, "黑屏代码有误!", data);
  14437. return Ok(jw);
  14438. }
  14439. foreach (DataRow row in dtBlack.Rows)
  14440. {
  14441. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14442. {
  14443. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14444. return Ok(jw);
  14445. }
  14446. }
  14447. //黑屏代码获取时间区间
  14448. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14449. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14450. _sqlSugar.BeginTran();
  14451. for (int i = 0; i < timeArr.Count; i++)
  14452. {
  14453. stay = "-";
  14454. cityPath = "-";
  14455. DateTime NewData = DateTime.Parse(timeArr[i]);
  14456. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14457. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14458. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14459. if (tbSelect.Length > 0)
  14460. {
  14461. List<string> threeCodeStr = new List<string>();
  14462. foreach (var item in tbSelect)
  14463. {
  14464. var threeCode = item["Three"].ToString() ?? "";
  14465. if (threeCode.Length == 6)
  14466. {
  14467. var start = threeCode.Substring(0, 3);
  14468. var end = threeCode.Substring(3, 3);
  14469. if (threeCodeStr.Count == 0)
  14470. {
  14471. threeCodeStr.Add(start);
  14472. threeCodeStr.Add(end);
  14473. }
  14474. else
  14475. {
  14476. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14477. {
  14478. threeCodeStr.Add(end);
  14479. }
  14480. else
  14481. {
  14482. threeCodeStr.Add(start);
  14483. threeCodeStr.Add(end);
  14484. }
  14485. }
  14486. }
  14487. }
  14488. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14489. var last = threeCodeStr.Last();
  14490. foreach (var item in threeCodeStr)
  14491. {
  14492. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14493. if (item.Equals(last))
  14494. {
  14495. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14496. }
  14497. }
  14498. cityPath = cityPath.Trim('-');
  14499. }
  14500. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14501. appro.Diid = diid ?? -1;
  14502. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14503. appro.Id = thisId;
  14504. appro.CreateUserId = dto.UserId;
  14505. appro.CreateTime = DateTime.Now;
  14506. content.Add(appro);
  14507. }
  14508. _sqlSugar.CommitTran();
  14509. }
  14510. foreach (var x in content)
  14511. {
  14512. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14513. if (chiList.Count < chiNumber)
  14514. {
  14515. for (int i = chiList.Count; i < chiNumber; i++)
  14516. {
  14517. chiList.Add(new Grp_ApprovalTravelDetails());
  14518. }
  14519. }
  14520. resultArr.Add(new
  14521. {
  14522. x.Id,
  14523. x.Date,
  14524. x.Diid,
  14525. chiList = chiList.Select(x1 => new
  14526. {
  14527. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14528. x1.Details,
  14529. x1.ParentId,
  14530. x1.Id
  14531. })
  14532. });
  14533. }
  14534. data = data with
  14535. {
  14536. content = resultArr,
  14537. };
  14538. jw = JsonView(true, "获取成功!", data);
  14539. return Ok(jw);
  14540. }
  14541. /// <summary>
  14542. /// 报批行程删除
  14543. /// </summary>
  14544. /// <param name="dto"></param>
  14545. /// <returns></returns>
  14546. [HttpPost]
  14547. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14548. {
  14549. var jw = JsonView(false);
  14550. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14551. if (group == null)
  14552. {
  14553. jw.Msg = "团组参数有误!";
  14554. return Ok(jw);
  14555. }
  14556. try
  14557. {
  14558. _sqlSugar.BeginTran();
  14559. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14560. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14561. {
  14562. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14563. DeleteUserId = dto.uesrId,
  14564. IsDel = 1
  14565. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14566. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14567. {
  14568. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14569. DeleteUserId = dto.uesrId,
  14570. IsDel = 1
  14571. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14572. _sqlSugar.CommitTran();
  14573. jw = JsonView(true, "删除成功");
  14574. }
  14575. catch (Exception ex)
  14576. {
  14577. jw = JsonView(false, ex.Message);
  14578. }
  14579. return Ok(jw);
  14580. }
  14581. /// <summary>
  14582. /// 报批行程保存
  14583. /// </summary>
  14584. /// <param name="dto"></param>
  14585. /// <returns></returns>
  14586. [HttpPost]
  14587. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14588. {
  14589. var jw = JsonView(false);
  14590. var Find = dto.Arr.Find(x => x.id == 0);
  14591. if (Find != null)
  14592. {
  14593. jw.Msg = "生成的ID为0!";
  14594. return Ok(jw);
  14595. }
  14596. foreach (var item in dto.Arr)
  14597. {
  14598. foreach (var chi in item.chiList)
  14599. {
  14600. if (chi.parentId == 0)
  14601. {
  14602. chi.parentId = item.id;
  14603. }
  14604. }
  14605. }
  14606. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14607. _sqlSugar.BeginTran();
  14608. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14609. {
  14610. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14611. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14612. {
  14613. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14614. DeleteUserId = dto.UserId,
  14615. IsDel = 1
  14616. }).ExecuteCommand();
  14617. }
  14618. try
  14619. {
  14620. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14621. {
  14622. CreateTime = DateTime.Now,
  14623. CreateUserId = dto.UserId,
  14624. Details = x.details,
  14625. ParentId = x.parentId,
  14626. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14627. Remark = "",
  14628. IsDel = 0
  14629. }).ToList()).ExecuteCommand();
  14630. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14631. {
  14632. Id = x.id,
  14633. Details = x.details,
  14634. ParentId = x.parentId,
  14635. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14636. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14637. {
  14638. Details = x.Details,
  14639. ParentId = x.ParentId,
  14640. Time = x.Time
  14641. }).ExecuteCommand();
  14642. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14643. {
  14644. Id = x.id,
  14645. Date = x.date,
  14646. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14647. {
  14648. Date = x.Date
  14649. }).ExecuteCommand();
  14650. _sqlSugar.CommitTran();
  14651. jw = JsonView(true, "保存成功!");
  14652. }
  14653. catch (Exception ex)
  14654. {
  14655. _sqlSugar.RollbackTran();
  14656. jw = JsonView(false, "保存失败!" + ex.Message);
  14657. }
  14658. return Ok(jw);
  14659. }
  14660. /// <summary>
  14661. /// 报批行程生成
  14662. /// </summary>
  14663. /// <param name="dto"></param>
  14664. /// <returns></returns>
  14665. [HttpPost]
  14666. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14667. {
  14668. var jw = JsonView(false);
  14669. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14670. if (group == null)
  14671. {
  14672. jw.Msg = "暂无该团组!";
  14673. return Ok(jw);
  14674. }
  14675. //黑屏代码数据
  14676. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14677. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14678. {
  14679. jw.Msg = "黑屏代码有误!";
  14680. return Ok(jw);
  14681. }
  14682. foreach (DataRow row in dtBlack.Rows)
  14683. {
  14684. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14685. {
  14686. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14687. return Ok(jw);
  14688. }
  14689. }
  14690. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14691. var resultArr = new ArrayList();
  14692. if (officialActivitiesArr.Count == 0)
  14693. {
  14694. jw.Msg = "暂无公务出访信息!";
  14695. return Ok(jw);
  14696. }
  14697. try
  14698. {
  14699. _sqlSugar.BeginTran();
  14700. DeleteApprovalJourney(new
  14701. Domain.Dtos.Groups.DeleteApprovalJourney
  14702. {
  14703. Diid = dto.Diid,
  14704. uesrId = dto.Userid
  14705. });
  14706. var stay = "-";
  14707. var cityPath = "-";
  14708. //添加城市路径以及住宿地
  14709. //黑屏代码获取时间区间
  14710. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14711. var empty = "【未收入该三字码!请机票同事录入】";
  14712. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14713. for (int i = 0; i < timeArr.Count; i++)
  14714. {
  14715. stay = "-";
  14716. cityPath = "-";
  14717. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14718. DateTime NewData = DateTime.Parse(timeArr[i]);
  14719. 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();
  14720. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14721. if (tbSelect.Length > 0)
  14722. {
  14723. List<string> threeCodeStr = new List<string>();
  14724. bool isTrade = false;
  14725. string trip = string.Empty;
  14726. var rowLast = tbSelect.Last();
  14727. var rowFirst = tbSelect.First();
  14728. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14729. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14730. var takeOffTime = DateTime.Parse(timeArr[i]);
  14731. var fallToTime = DateTime.Parse(timeArr[i]);
  14732. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14733. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14734. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14735. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14736. foreach (var item in tbSelect)
  14737. {
  14738. var start = string.Empty;
  14739. var end = string.Empty;
  14740. var threeCode = item["Three"].ToString() ?? "";
  14741. if (threeCode.Length == 6)
  14742. {
  14743. start = threeCode.Substring(0, 3);
  14744. end = threeCode.Substring(3, 3);
  14745. if (threeCodeStr.Count == 0)
  14746. {
  14747. threeCodeStr.Add(start);
  14748. threeCodeStr.Add(end);
  14749. }
  14750. else
  14751. {
  14752. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14753. {
  14754. threeCodeStr.Add(end);
  14755. }
  14756. else
  14757. {
  14758. threeCodeStr.Add(start);
  14759. threeCodeStr.Add(end);
  14760. }
  14761. }
  14762. }
  14763. //处理机票信息
  14764. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14765. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14766. if (start_Object == null)
  14767. {
  14768. start_Object = new Res_ThreeCode()
  14769. {
  14770. AirPort = empty,
  14771. AirPort_En = empty,
  14772. City = empty,
  14773. Country = empty,
  14774. Four = empty,
  14775. Three = empty,
  14776. };
  14777. }
  14778. if (end_Object == null)
  14779. {
  14780. end_Object = new Res_ThreeCode()
  14781. {
  14782. AirPort = empty,
  14783. AirPort_En = empty,
  14784. City = empty,
  14785. Country = empty,
  14786. Four = empty,
  14787. Three = empty,
  14788. };
  14789. }
  14790. //机型判断
  14791. string airModel = item["AirModel"].ToString();
  14792. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14793. string flightTime = item["FlightTime"].ToString();
  14794. if (flightTime!.Contains(":"))
  14795. {
  14796. flightTime = flightTime.Replace(":", "小时");
  14797. flightTime += "分钟";
  14798. }
  14799. if (flightTime.Contains("H"))
  14800. {
  14801. flightTime = flightTime.Replace("H", "小时");
  14802. }
  14803. if (flightTime.Contains("M"))
  14804. {
  14805. flightTime = flightTime.Replace("M", "分钟");
  14806. }
  14807. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14808. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14809. {
  14810. flightTime = flightDataTime.Hour > 0
  14811. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14812. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14813. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14814. }
  14815. //航班号
  14816. string flightcode = item["Fliagtcode"].ToString();
  14817. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14818. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14819. if (aircompany == null)
  14820. {
  14821. aircompany = new Res_AirCompany
  14822. {
  14823. CnName = hsEmpty,
  14824. EnName = hsEmpty,
  14825. ShortCode = hsEmpty,
  14826. };
  14827. }
  14828. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14829. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14830. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14831. if (isTrade)
  14832. {
  14833. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14834. }
  14835. else
  14836. {
  14837. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14838. }
  14839. }
  14840. chiarr.Add(new Grp_ApprovalTravelDetails
  14841. {
  14842. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14843. CreateTime = DateTime.Now,
  14844. CreateUserId = dto.Userid,
  14845. ParentId = 0,
  14846. Details = trip
  14847. });
  14848. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14849. var last = threeCodeStr.Last();
  14850. foreach (var item in threeCodeStr)
  14851. {
  14852. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14853. if (item.Equals(last))
  14854. {
  14855. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14856. }
  14857. }
  14858. cityPath = cityPath.Trim('-');
  14859. }
  14860. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14861. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14862. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14863. appro.Diid = dto.Diid;
  14864. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14865. appro.Id = thisId;
  14866. appro.CreateUserId = dto.Userid;
  14867. appro.CreateTime = DateTime.Now;
  14868. foreach (var item in gwinfo)
  14869. {
  14870. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14871. chi.Details = "拜访" + item.Client;
  14872. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14873. {
  14874. chi.Details += "," + item.ReqSample;
  14875. }
  14876. chi.ParentId = thisId;
  14877. chi.Time = item.Time;
  14878. chiarr.Add(chi);
  14879. }
  14880. if (chiarr.Count < 5)
  14881. {
  14882. for (int j = chiarr.Count; j < 5; j++)
  14883. {
  14884. chiarr.Add(new
  14885. Grp_ApprovalTravelDetails());
  14886. }
  14887. }
  14888. resultArr.Add(new
  14889. {
  14890. appro.Id,
  14891. appro.Date,
  14892. appro.Diid,
  14893. chiList = chiarr.Select(x1 => new
  14894. {
  14895. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14896. x1.Details,
  14897. x1.ParentId,
  14898. x1.Id
  14899. })
  14900. });
  14901. }
  14902. _sqlSugar.CommitTran();
  14903. jw = JsonView(true, "生成成功!", resultArr);
  14904. }
  14905. catch (Exception ex)
  14906. {
  14907. jw.Code = 400;
  14908. jw.Msg = "生成失败!" + ex.Message;
  14909. }
  14910. return Ok(jw);
  14911. }
  14912. /// <summary>
  14913. /// 报批行程word导出
  14914. /// </summary>
  14915. /// <param name="dto"></param>
  14916. /// <returns></returns>
  14917. [HttpPost]
  14918. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14919. {
  14920. var jw = JsonView(false);
  14921. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14922. if (group == null)
  14923. {
  14924. jw.Msg = "暂无该团组!";
  14925. return Ok(jw);
  14926. }
  14927. //模板路径
  14928. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14929. //载入模板
  14930. Document doc = new Document(tempPath);
  14931. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14932. //获取所填表格的序数
  14933. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14934. Aspose.Words.Tables.Row titleRowClone = null;
  14935. Aspose.Words.Tables.Row CenterRowClone = null;
  14936. int index = 0;
  14937. int indexChi = 0;
  14938. int SetIndex = 0;
  14939. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14940. //获取数据,放到datatable
  14941. foreach (var item in ApprovalTravelArr)
  14942. {
  14943. if (index > 0)
  14944. {
  14945. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14946. tableOne.AppendChild(titleRowClone);
  14947. }
  14948. var textTime = item.Date;
  14949. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14950. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14951. SetIndex++;
  14952. if (ChiRep.Count > 0)
  14953. {
  14954. foreach (var itemChi in ChiRep)
  14955. {
  14956. var txtTime = itemChi.Time;
  14957. var txtDetail = itemChi.Details;
  14958. if (indexChi > 0)
  14959. {
  14960. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14961. tableOne.AppendChild(CenterRowClone);
  14962. }
  14963. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14964. {
  14965. SetCells(tableOne, doc, SetIndex, 0, "");
  14966. SetCells(tableOne, doc, SetIndex, 1, "");
  14967. indexChi++;
  14968. SetIndex++;
  14969. break;
  14970. }
  14971. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14972. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14973. indexChi++;
  14974. SetIndex++;
  14975. }
  14976. }
  14977. else
  14978. {
  14979. if (indexChi > 0)
  14980. {
  14981. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14982. tableOne.AppendChild(CenterRowClone);
  14983. }
  14984. SetCells(tableOne, doc, SetIndex, 0, "");
  14985. SetCells(tableOne, doc, SetIndex, 1, "");
  14986. indexChi++;
  14987. SetIndex++;
  14988. }
  14989. index++;
  14990. }
  14991. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  14992. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14993. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14994. jw.Code = 200;
  14995. jw.Msg = "";
  14996. return Ok(jw);
  14997. }
  14998. private string intToString(int numberVal)
  14999. {
  15000. string numberval = numberVal.ToString();
  15001. Dictionary<char, string> Number = new Dictionary<char, string>();
  15002. Number.Add('1', "一");
  15003. Number.Add('2', "二");
  15004. Number.Add('3', "三");
  15005. Number.Add('4', "四");
  15006. Number.Add('5', "五");
  15007. Number.Add('6', "六");
  15008. Number.Add('7', "七");
  15009. Number.Add('8', "八");
  15010. Number.Add('9', "九");
  15011. string stringNumberVal = string.Empty;
  15012. for (int i = 0; i < numberval.Length; i++)
  15013. {
  15014. if (i == 0)
  15015. {
  15016. stringNumberVal += Number[numberval[i]];
  15017. }
  15018. else if (i >= 1)
  15019. {
  15020. if (numberval[i] == '0')
  15021. {
  15022. stringNumberVal = "十";
  15023. }
  15024. else
  15025. {
  15026. stringNumberVal += "十" + Number[numberval[i]];
  15027. }
  15028. }
  15029. }
  15030. return stringNumberVal;
  15031. }
  15032. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  15033. {
  15034. //获取table中的某个单元格,从0开始
  15035. Cell lshCell = table.Rows[rows].Cells[cells];
  15036. //将单元格中段落移除
  15037. foreach (Node item in lshCell.Paragraphs)
  15038. {
  15039. lshCell.Paragraphs.Remove(item);
  15040. }
  15041. if (val.Contains("\r\n"))
  15042. {
  15043. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  15044. foreach (var item in spArr)
  15045. {
  15046. //新建一个段落
  15047. Paragraph p = new Paragraph(doc);
  15048. var r = new Run(doc, item);
  15049. //把设置的值赋给之前新建的段落
  15050. p.AppendChild(r);
  15051. //将此段落加到单元格内
  15052. lshCell.AppendChild(p);
  15053. }
  15054. }
  15055. else
  15056. {
  15057. //新建一个段落
  15058. Paragraph p = new Paragraph(doc);
  15059. var r = new Run(doc, val);
  15060. //把设置的值赋给之前新建的段落
  15061. p.AppendChild(r);
  15062. //将此段落加到单元格内
  15063. lshCell.AppendChild(p);
  15064. }
  15065. }
  15066. [HttpPost]
  15067. public async Task<IActionResult> ServerHttp(string paramStr)
  15068. {
  15069. paramStr = paramStr.TrimEnd('\'');
  15070. paramStr = paramStr.TrimStart('\'');
  15071. JsonView jw = JsonView(false);
  15072. JObject param = JObject.Parse(paramStr);
  15073. if (!param.ContainsKey("url"))
  15074. {
  15075. jw.Msg = "url null";
  15076. return Ok(jw);
  15077. }
  15078. string url = param["url"]!.ToString();
  15079. var methon = "get";
  15080. Dictionary<string, string> headValues = null;
  15081. string bodyStr = string.Empty;
  15082. if (param.ContainsKey("methon"))
  15083. {
  15084. methon = param["methon"]!.ToString().ToLower();
  15085. }
  15086. if (param.ContainsKey("header"))
  15087. {
  15088. var header = param["header"]!.ToString();
  15089. JObject headerJobject = JObject.Parse(header);
  15090. headValues = new Dictionary<string, string>();
  15091. foreach (JProperty item in headerJobject.Properties())
  15092. {
  15093. var value = item.Value.ToString();
  15094. var head = item.Path;
  15095. headValues.Add(head, value);
  15096. }
  15097. }
  15098. HttpClient client = new HttpClient();
  15099. string responseString = string.Empty;
  15100. StringContent content = null;
  15101. if (headValues != null)
  15102. {
  15103. foreach (var item in headValues.Keys)
  15104. {
  15105. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15106. {
  15107. if (param.ContainsKey("body"))
  15108. {
  15109. bodyStr = param["body"]!.ToString();
  15110. }
  15111. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15112. }
  15113. else
  15114. {
  15115. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15116. }
  15117. }
  15118. }
  15119. try
  15120. {
  15121. if (methon == "get")
  15122. {
  15123. responseString = await client.GetStringAsync(url);
  15124. }
  15125. else if (methon == "post")
  15126. {
  15127. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15128. {
  15129. Content = content
  15130. };
  15131. var response = await client.SendAsync(request);
  15132. try
  15133. {
  15134. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15135. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15136. {
  15137. using (StreamReader reader = new StreamReader(gzipStream))
  15138. {
  15139. responseString = await reader.ReadToEndAsync();
  15140. }
  15141. }
  15142. }
  15143. catch (Exception)
  15144. {
  15145. responseString = await response.Content.ReadAsStringAsync();
  15146. }
  15147. }
  15148. else
  15149. {
  15150. responseString = "methon error";
  15151. }
  15152. jw = JsonView(true, "success", responseString);
  15153. }
  15154. catch (Exception ex)
  15155. {
  15156. jw.Msg = "error " + ex.Message;
  15157. jw.Data = ex.StackTrace;
  15158. }
  15159. finally
  15160. {
  15161. client.Dispose();
  15162. }
  15163. return Ok(jw);
  15164. }
  15165. #endregion
  15166. #region 团组接待意见调查
  15167. /// <summary>
  15168. /// 团组接待意见调查 - 信息管理
  15169. /// 基础数据(团组)
  15170. /// </summary>
  15171. /// <param name="dto"></param>
  15172. /// <returns></returns>
  15173. [HttpGet]
  15174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15175. public async Task<IActionResult> OpinionaireInit()
  15176. {
  15177. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15178. .Select(x => new
  15179. {
  15180. x.Id,
  15181. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15182. })
  15183. .OrderByDescending(x => x.Id)
  15184. .ToListAsync();
  15185. return Ok(JsonView(groupData, groupData.Count));
  15186. }
  15187. /// <summary>
  15188. /// 团组接待意见调查 - 信息管理
  15189. /// 列表
  15190. /// </summary>
  15191. /// <param name="groupId"></param>
  15192. /// <returns></returns>
  15193. [HttpGet("{groupId}")]
  15194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15195. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15196. {
  15197. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15198. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15199. .Select(x => new
  15200. {
  15201. x.Id,
  15202. x.TourGuideName,
  15203. x.CityName,
  15204. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15205. x.CreateTime
  15206. })
  15207. .OrderBy(x => x.Id)
  15208. .ToListAsync();
  15209. return Ok(JsonView(data));
  15210. }
  15211. /// <summary>
  15212. /// 团组接待意见调查 - 信息管理
  15213. /// 保存
  15214. /// </summary>
  15215. /// <param name="dto"></param>
  15216. /// <returns></returns>
  15217. [HttpPost]
  15218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15219. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15220. {
  15221. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15222. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15223. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15224. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15225. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15226. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15227. _opinionaireRep.BeginTran();
  15228. if (addData != null && addData.Count > 0)
  15229. {
  15230. foreach (var item in addData)
  15231. {
  15232. item.CreateUserId = currUserInfo.UserId;
  15233. item.DiId = dto.DiId;
  15234. }
  15235. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15236. }
  15237. if (updData != null && updData.Count > 0)
  15238. {
  15239. var upd = await _opinionaireRep._sqlSugar
  15240. .Updateable(updData)
  15241. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15242. .WhereColumns(x => new { x.Id })
  15243. .ExecuteCommandAsync();
  15244. }
  15245. _opinionaireRep.CommitTran();
  15246. return Ok(JsonView("操作成功!"));
  15247. }
  15248. /// <summary>
  15249. /// 团组接待意见调查 - 信息管理
  15250. /// 删除
  15251. /// </summary>
  15252. /// <param name="id"></param>
  15253. /// <returns></returns>
  15254. [HttpDelete("{id}")]
  15255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15256. public async Task<IActionResult> OpinionaireManageDel(int id)
  15257. {
  15258. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15259. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15260. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15261. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15262. if (!del) return Ok(JsonView("操作失败!"));
  15263. return Ok(JsonView("操作成功!"));
  15264. }
  15265. /// <summary>
  15266. /// 团组接待意见调查 - 用户
  15267. /// 列表
  15268. /// </summary>
  15269. /// <param name="id"></param>
  15270. /// <returns></returns>
  15271. [HttpGet("{diId}")]
  15272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15273. public async Task<IActionResult> OpinionaireUserList(int diId)
  15274. {
  15275. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15276. var sql = string.Format(@"
  15277. SELECT
  15278. o.Id,
  15279. o.DiId,
  15280. di.TeamName AS 'GroupName',
  15281. di.VisitPNumber AS 'PeopleNumber',
  15282. di.ClientName AS 'LeadGroup',
  15283. di.VisitCountry AS 'Travel',
  15284. di.VisitDays AS 'Days',
  15285. o.CityName,
  15286. o.TourGuideName,
  15287. o.Catering,
  15288. o.CateringReason,
  15289. o.Stay,
  15290. o.StayReason,
  15291. o.[Route],
  15292. o.RouteReason,
  15293. o.OfficialActivity,
  15294. o.OfficialActivityReason,
  15295. o.TourGuide,
  15296. o.TourGuideReason,
  15297. o.[Translate],
  15298. o.TranslateReason,
  15299. o.Trip,
  15300. o.TripReason,
  15301. o.ESFileName,
  15302. o.SignatureDate,
  15303. o.Remark
  15304. FROM
  15305. Grp_Opinionaire o
  15306. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15307. WHERE
  15308. o.IsDel = 0
  15309. AND o.DiId = {0}
  15310. ORDER BY
  15311. o.Id ASC", diId);
  15312. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15313. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15314. return Ok(JsonView(data));
  15315. }
  15316. /// <summary>
  15317. /// 团组接待意见调查 - 用户
  15318. /// 保存
  15319. /// </summary>
  15320. /// <param name="id"></param>
  15321. /// <returns></returns>
  15322. [HttpPost]
  15323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15324. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15325. {
  15326. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15327. foreach (var item in dto)
  15328. {
  15329. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15330. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15331. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15332. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15333. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15334. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15335. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15336. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15337. }
  15338. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15339. if (!Directory.Exists(filePathBase))
  15340. {
  15341. Directory.CreateDirectory(filePathBase);
  15342. }
  15343. #region 上传文件
  15344. var filePaths = new List<string>();
  15345. foreach (var item in dto)
  15346. {
  15347. var file = item.File;
  15348. // 将文件保存到指定位置
  15349. var filePath = Path.Combine(filePathBase, file.FileName);
  15350. using (var stream = new FileStream(filePath, FileMode.Create))
  15351. {
  15352. await file.CopyToAsync(stream);
  15353. }
  15354. //验证文件是否上传成功
  15355. if (!System.IO.File.Exists(filePath))
  15356. {
  15357. foreach (var filePathStr in filePaths)
  15358. {
  15359. System.IO.File.Delete(filePathStr);
  15360. }
  15361. return Ok(JsonView(false, "文件上传失败!"));
  15362. }
  15363. item.ESFileName = file.FileName;
  15364. }
  15365. #endregion
  15366. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15367. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15368. .UpdateColumns(x => new
  15369. {
  15370. x.Catering,
  15371. x.CateringReason,
  15372. x.Stay,
  15373. x.StayReason,
  15374. x.Route,
  15375. x.RouteReason,
  15376. x.OfficialActivity,
  15377. x.OfficialActivityReason,
  15378. x.TourGuide,
  15379. x.TourGuideReason,
  15380. x.Translate,
  15381. x.TranslateReason,
  15382. x.Trip,
  15383. x.TripReason,
  15384. x.ESFileName,
  15385. x.SignatureDate,
  15386. x.Remark
  15387. })
  15388. .WhereColumns(x => new { x.Id })
  15389. .ExecuteCommandAsync();
  15390. if (upd < 1)
  15391. {
  15392. foreach (var filePathStr in filePaths)
  15393. {
  15394. System.IO.File.Delete(filePathStr);
  15395. }
  15396. return Ok(JsonView(false));
  15397. }
  15398. return Ok(JsonView(true));
  15399. }
  15400. #endregion
  15401. // /// <summary>
  15402. // ///
  15403. // /// </summary>
  15404. // /// <param name="_dto"></param>
  15405. // /// <returns></returns>
  15406. // [HttpPost]
  15407. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15408. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15409. // {
  15410. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15411. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15412. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15413. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15414. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15415. // dic_psg.Add("客人", 974);
  15416. // dic_psg.Add("司机", 975);
  15417. // dic_psg.Add("导游", 976);
  15418. // dic_psg.Add("公司内部人员", 977);
  15419. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15420. // foreach (var item in list_visa)
  15421. // {
  15422. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15423. // temp.Id = item.Id;
  15424. // temp.DIId = item.DIId;
  15425. // temp.VisaClient = item.VisaClient;
  15426. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15427. // temp.VisaCurrency = item.VisaCurrency;
  15428. // temp.IsThird = item.IsThird;
  15429. // if (dic_psg.ContainsKey(item.PassengerType))
  15430. // {
  15431. // temp.PassengerType = dic_psg[item.PassengerType];
  15432. // }
  15433. // else {
  15434. // temp.PassengerType = -1;
  15435. // }
  15436. // temp.VisaNumber = item.VisaNumber;
  15437. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15438. // temp.CreateUserId = item.Operators;
  15439. // DateTime dt_ct;
  15440. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15441. // if (b_ct)
  15442. // {
  15443. // temp.CreateTime = dt_ct;
  15444. // }
  15445. // else
  15446. // {
  15447. // temp.CreateTime = DateTime.Now;
  15448. // }
  15449. // temp.DeleteTime = "";
  15450. // temp.DeleteUserId = 0;
  15451. // temp.Remark = item.Remark;
  15452. // if (string.IsNullOrEmpty(temp.Remark)) {
  15453. // temp.Remark = "";
  15454. // }
  15455. // temp.IsDel = item.IsDel;
  15456. // temp.VisaDescription = item.VisaAttachment;
  15457. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15458. //([Id]
  15459. // ,[DIId]
  15460. // ,[VisaClient]
  15461. // ,[VisaPrice]
  15462. // ,[VisaCurrency]
  15463. // ,[IsThird]
  15464. // ,[PassengerType]
  15465. // ,[VisaNumber]
  15466. // ,[VisaFreeNumber]
  15467. // ,[CreateUserId]
  15468. // ,[CreateTime]
  15469. // ,[DeleteTime]
  15470. // ,[DeleteUserId]
  15471. // ,[Remark]
  15472. // ,[IsDel]
  15473. // ,[visaDescription])
  15474. // VALUES
  15475. // ({0},{1},'{2}',{3},{4}
  15476. //,{5},{6},{7},{8},{9}
  15477. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15478. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15479. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15480. //);
  15481. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15482. // }
  15483. // return Ok(JsonView(true, "操作成功!"));
  15484. // }
  15485. /// <summary>
  15486. /// 123132123
  15487. /// </summary>
  15488. /// <param name="_dto"></param>
  15489. /// <returns></returns>
  15490. [HttpPost]
  15491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15492. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15493. {
  15494. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15495. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15496. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15497. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15498. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15499. dicDetail.Add(789, 1034);
  15500. dicDetail.Add(790, 1035);
  15501. dicDetail.Add(791, 1036);
  15502. dicDetail.Add(792, 1037);
  15503. dicDetail.Add(793, 1038);
  15504. dicDetail.Add(794, 1039);
  15505. dicDetail.Add(795, 1040);
  15506. dicDetail.Add(796, 1041);
  15507. dicDetail.Add(797, 1042);
  15508. dicDetail.Add(798, 1043);
  15509. dicDetail.Add(801, 1044);
  15510. dicDetail.Add(802, 1045);
  15511. dicDetail.Add(803, 1046);
  15512. Dictionary<int, int> dic = new Dictionary<int, int>();
  15513. dic.Add(806, 1027);
  15514. dic.Add(807, 1028);
  15515. dic.Add(808, 1029);
  15516. dic.Add(809, 1030);
  15517. dic.Add(810, 1031);
  15518. dic.Add(811, 1032);
  15519. dic.Add(812, 1033);
  15520. foreach (var item in list_visa)
  15521. {
  15522. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15523. temp.Coefficient = item.coefficient;
  15524. DateTime dtCrt;
  15525. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15526. if (b1)
  15527. {
  15528. temp.CreateTime = dtCrt;
  15529. }
  15530. else
  15531. {
  15532. temp.CreateTime = DateTime.Now;
  15533. }
  15534. temp.CreateUserId = item.Operators;
  15535. temp.DeleteTime = "";
  15536. temp.DeleteUserId = 0;
  15537. temp.DiId = int.Parse(item.DIID);
  15538. temp.FilePath = item.FilePath;
  15539. temp.IsDel = item.IsDel;
  15540. temp.Price = item.Price;
  15541. temp.PriceCount = 1;
  15542. temp.PriceCurrency = item.Currency;
  15543. int detailId = 0;
  15544. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15545. {
  15546. detailId = dicDetail[item.PriceTypeDetail];
  15547. }
  15548. temp.PriceDetailType = detailId;
  15549. temp.PriceDt = DateTime.Now;
  15550. temp.PriceName = item.PriceName;
  15551. temp.PriceSum = item.Price;
  15552. int tid = 0;
  15553. if (dic.ContainsKey(item.PriceType))
  15554. {
  15555. tid = dic[item.PriceType];
  15556. }
  15557. temp.PriceType = tid;
  15558. temp.Remark = item.Remark;
  15559. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15560. }
  15561. return Ok(JsonView(true, "操作成功!"));
  15562. }
  15563. }
  15564. }