GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.KiMiApi;
  18. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  19. using OASystem.Domain.AesEncryption;
  20. using OASystem.Domain.Attributes;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels.CRM;
  29. using OASystem.Domain.ViewModels.Financial;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Domain.ViewModels.OCR;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using Quartz.Util;
  36. using SqlSugar.Extensions;
  37. using System.Collections;
  38. using System.Data;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO.Compression;
  42. using System.Text.Json;
  43. using System.Web;
  44. using static OASystem.API.OAMethodLib.JWTHelper;
  45. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  46. using Bookmark = Aspose.Words.Bookmark;
  47. using Cell = Aspose.Words.Tables.Cell;
  48. using Table = Aspose.Words.Tables.Table;
  49. namespace OASystem.API.Controllers
  50. {
  51. /// <summary>
  52. /// 团组相关
  53. /// </summary>
  54. //[Authorize]
  55. [Route("api/[controller]/[action]")]
  56. public class GroupsController : ControllerBase
  57. {
  58. private readonly ILogger<GroupsController> _logger;
  59. private readonly GrpScheduleRepository _grpScheduleRep;
  60. private readonly IMapper _mapper;
  61. private readonly DelegationInfoRepository _groupRepository;
  62. private readonly TaskAssignmentRepository _taskAssignmentRep;
  63. private readonly AirTicketResRepository _airTicketResRep;
  64. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  65. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  66. private readonly DelegationEnDataRepository _delegationEnDataRep;
  67. private readonly DelegationVisaRepository _delegationVisaRep;
  68. private readonly VisaPriceRepository _visaPriceRep;
  69. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  70. private readonly HotelPriceRepository _hotelPriceRep;
  71. private readonly CustomersRepository _customersRep;
  72. private readonly MessageRepository _message;
  73. private readonly SqlSugarClient _sqlSugar;
  74. private readonly TourClientListRepository _tourClientListRep;
  75. private readonly TeamRateRepository _teamRateRep;
  76. #region 成本相关
  77. private readonly CheckBoxsRepository _checkBoxs;
  78. private readonly GroupCostRepository _GroupCostRepository;
  79. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  80. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  81. #endregion
  82. private readonly SetDataRepository _setDataRep;
  83. private string url;
  84. private string path;
  85. private readonly EnterExitCostRepository _enterExitCostRep;
  86. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  87. private readonly UsersRepository _usersRep;
  88. private readonly IJuHeApiService _juHeApi;
  89. private readonly InvertedListRepository _invertedListRep;
  90. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  91. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  92. private readonly ThreeCodeRepository _threeCodeRepository;
  93. private readonly HotelInquiryRepository _hotelInquiryRep;
  94. private readonly FeeAuditRepository _feeAuditRep;
  95. private readonly VisaCommissionRepository _visaCommissionRep;
  96. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  97. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  98. private readonly List<CurrencyInfo> _currencyInit;
  99. private readonly List<int> _portTypeData;
  100. private readonly TableOperationRecordRepository _tableorRep;
  101. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  102. private readonly RestaurantRepository _restaurantRep;
  103. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  104. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  105. /// <summary>
  106. /// 构造函数
  107. /// </summary>
  108. /// <param name="logger"></param>
  109. /// <param name="mapper"></param>
  110. /// <param name="hubContext"></param>
  111. /// <param name="sqlSugar"></param>
  112. /// <param name="grpScheduleRep"></param>
  113. /// <param name="groupRepository"></param>
  114. /// <param name="taskAssignmentRep"></param>
  115. /// <param name="airTicketResRep"></param>
  116. /// <param name="decreasePaymentsRep"></param>
  117. /// <param name="InvitationOfficialActivitiesRep"></param>
  118. /// <param name="delegationEnDataRep"></param>
  119. /// <param name="enterExitCostRep"></param>
  120. /// <param name="delegationVisaRep"></param>
  121. /// <param name="message"></param>
  122. /// <param name="visaPriceRep"></param>
  123. /// <param name="carTouristGuideGroundRep"></param>
  124. /// <param name="checkBoxs"></param>
  125. /// <param name="GroupCostRepository"></param>
  126. /// <param name="CostTypeHotelNumberRepository"></param>
  127. /// <param name="GroupCostParameterRepository"></param>
  128. /// <param name="hotelPriceRep"></param>
  129. /// <param name="customersRep"></param>
  130. /// <param name="setDataRep"></param>
  131. /// <param name="tourClientListRep"></param>
  132. /// <param name="teamRateRep"></param>
  133. /// <param name="usersRep"></param>
  134. /// <param name="juHeApi"></param>
  135. /// <param name="invertedListRep"></param>
  136. /// <param name="visaFeeInfoRep"></param>
  137. /// <param name="ticketBlackCodeRep"></param>
  138. /// <param name="hotelInquiryRep"></param>
  139. /// <param name="threeCodeRepository"></param>
  140. /// <param name="feeAuditRep"></param>
  141. /// <param name="visaCommissionRep"></param>
  142. /// <param name="ffrRep"></param>
  143. /// <param name="opinionaireRep"></param>
  144. /// <param name="tableorRep"></param>
  145. /// <param name="enterExitCostDraftRep"></param>
  146. /// <param name="restaurantRep"></param>
  147. /// <param name="enterExitCostQuoteRep"></param>
  148. /// <param name="grpOrderPreInfoRep"></param>
  149. public GroupsController(
  150. ILogger<GroupsController> logger,
  151. IMapper mapper,
  152. IHubContext<ChatHub, IChatClient> hubContext,
  153. SqlSugarClient sqlSugar,
  154. GrpScheduleRepository grpScheduleRep,
  155. DelegationInfoRepository groupRepository,
  156. TaskAssignmentRepository taskAssignmentRep,
  157. AirTicketResRepository airTicketResRep,
  158. DecreasePaymentsRepository decreasePaymentsRep,
  159. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  160. DelegationEnDataRepository delegationEnDataRep,
  161. EnterExitCostRepository enterExitCostRep,
  162. DelegationVisaRepository delegationVisaRep,
  163. MessageRepository message,
  164. VisaPriceRepository visaPriceRep,
  165. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  166. CheckBoxsRepository checkBoxs,
  167. GroupCostRepository GroupCostRepository,
  168. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  169. GroupCostParameterRepository GroupCostParameterRepository,
  170. HotelPriceRepository hotelPriceRep,
  171. CustomersRepository customersRep,
  172. SetDataRepository setDataRep,
  173. TourClientListRepository tourClientListRep,
  174. TeamRateRepository teamRateRep,
  175. UsersRepository usersRep,
  176. IJuHeApiService juHeApi,
  177. InvertedListRepository invertedListRep,
  178. VisaFeeInfoRepository visaFeeInfoRep,
  179. TicketBlackCodeRepository ticketBlackCodeRep,
  180. HotelInquiryRepository hotelInquiryRep,
  181. ThreeCodeRepository threeCodeRepository,
  182. FeeAuditRepository feeAuditRep,
  183. VisaCommissionRepository visaCommissionRep,
  184. ForeignReceivablesRepository ffrRep,
  185. OpinionaireRepository opinionaireRep,
  186. TableOperationRecordRepository tableorRep,
  187. EnterExitCostDraftRepository enterExitCostDraftRep,
  188. RestaurantRepository restaurantRep,
  189. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  190. GroupOrderPreInfoRepository grpOrderPreInfoRep
  191. )
  192. {
  193. _logger = logger;
  194. _mapper = mapper;
  195. _grpScheduleRep = grpScheduleRep;
  196. _groupRepository = groupRepository;
  197. _taskAssignmentRep = taskAssignmentRep;
  198. _airTicketResRep = airTicketResRep;
  199. _sqlSugar = sqlSugar;
  200. url = AppSettingsHelper.Get("ExcelBaseUrl");
  201. path = AppSettingsHelper.Get("ExcelBasePath");
  202. if (!System.IO.Directory.Exists(path))
  203. {
  204. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  205. }
  206. _decreasePaymentsRep = decreasePaymentsRep;
  207. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  208. _delegationEnDataRep = delegationEnDataRep;
  209. _enterExitCostRep = enterExitCostRep;
  210. _delegationVisaRep = delegationVisaRep;
  211. _message = message;
  212. _visaPriceRep = visaPriceRep;
  213. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  214. _checkBoxs = checkBoxs;
  215. _GroupCostRepository = GroupCostRepository;
  216. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  217. _GroupCostParameterRepository = GroupCostParameterRepository;
  218. _hotelPriceRep = hotelPriceRep;
  219. _customersRep = customersRep;
  220. _setDataRep = setDataRep;
  221. _tourClientListRep = tourClientListRep;
  222. _teamRateRep = teamRateRep;
  223. _hubContext = hubContext;
  224. _usersRep = usersRep;
  225. _juHeApi = juHeApi;
  226. _invertedListRep = invertedListRep;
  227. _visaFeeInfoRep = visaFeeInfoRep;
  228. _ticketBlackCodeRep = ticketBlackCodeRep;
  229. _hotelInquiryRep = hotelInquiryRep;
  230. _threeCodeRepository = threeCodeRepository;
  231. _feeAuditRep = feeAuditRep;
  232. _visaCommissionRep = visaCommissionRep;
  233. _ffrRep = ffrRep;
  234. _opinionaireRep = opinionaireRep;
  235. _currencyInit = new List<CurrencyInfo>()
  236. {
  237. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  238. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  239. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  240. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  241. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  242. };
  243. _portTypeData = new List<int>() { 2, 3 };
  244. _tableorRep = tableorRep;
  245. _enterExitCostDraftRep = enterExitCostDraftRep;
  246. _restaurantRep = restaurantRep;
  247. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  248. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  249. }
  250. #region 流程管控
  251. /// <summary>
  252. /// 获取团组流程管控信息
  253. /// </summary>
  254. /// <param name="_jsonDto">查询参数</param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  259. {
  260. if (string.IsNullOrEmpty(_jsonDto.Paras))
  261. {
  262. return Ok(JsonView(false, "参数为空"));
  263. }
  264. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  265. if (_ScheduleDto != null)
  266. {
  267. if (_ScheduleDto.SearchType == 2)//获取列表
  268. {
  269. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  270. return Ok(JsonView(_grpScheduleViewList));
  271. }
  272. else//获取对象
  273. {
  274. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  275. if (_grpScheduleView != null)
  276. {
  277. return Ok(JsonView(_grpScheduleView));
  278. }
  279. }
  280. }
  281. else
  282. {
  283. return Ok(JsonView(false, "参数反序列化失败"));
  284. }
  285. return Ok(JsonView(false, "暂无数据!"));
  286. }
  287. /// <summary>
  288. /// 修改团组流程管控详细表数据
  289. /// </summary>
  290. /// <param name="dto"></param>
  291. /// <returns></returns>
  292. [HttpPost]
  293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  294. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  295. {
  296. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  297. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  298. .SetColumns(it => it.Duty == _detail.Duty)
  299. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  300. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  301. .SetColumns(it => it.JobContent == _detail.JobContent)
  302. .SetColumns(it => it.Remark == _detail.Remark)
  303. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  304. .Where(s => s.Id == dto.Id)
  305. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  306. .ExecuteCommandAsync();
  307. if (result > 0)
  308. {
  309. return Ok(JsonView(true, "保存成功!"));
  310. }
  311. return Ok(JsonView(false, "保存失败!"));
  312. }
  313. /// <summary>
  314. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  321. {
  322. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  323. _detail.IsDel = 1;
  324. _detail.DeleteUserId = dto.Duty;
  325. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  326. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  327. .SetColumns(it => it.IsDel == _detail.IsDel)
  328. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  329. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  330. .Where(it => it.Id == dto.Id)
  331. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  332. //.WhereColumns(s => s.Id == dto.Id)
  333. .ExecuteCommandAsync();
  334. if (result > 0)
  335. {
  336. return Ok(JsonView(true, "删除成功!"));
  337. }
  338. return Ok(JsonView(false, "删除失败!"));
  339. }
  340. /// <summary>
  341. /// 增加团组流程管控详细表数据
  342. /// </summary>
  343. /// <param name="dto"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  348. {
  349. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  350. if (DateTime.Now < _detail.ExpectBeginDt)
  351. {
  352. _detail.StepStatus = 0;
  353. }
  354. else
  355. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  356. _detail.StepStatus = 1;
  357. }
  358. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  359. if (result > 0)
  360. {
  361. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  362. return Ok(JsonView(true, "添加成功!", _result));
  363. }
  364. return Ok(JsonView(false, "添加失败!"));
  365. }
  366. #endregion
  367. #region 团组前期信息
  368. /// <summary>
  369. /// 团组前期信息H5-URL(员工对应地址)
  370. /// </summary>
  371. /// <param name="name">用户名称</param>
  372. /// <returns></returns>
  373. [HttpGet]
  374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  375. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  376. {
  377. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  378. .Where(x => x.IsDel == 0)
  379. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  380. .OrderBy(x => x.Id)
  381. .Select(x => new
  382. {
  383. name = x.CnName,
  384. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  385. })
  386. .ToListAsync();
  387. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  388. }
  389. /// <summary>
  390. /// 团组前期信息 List
  391. /// </summary>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  396. {
  397. var search = dto.Search;
  398. int[] nameTempIds = new int[] { 1, 12, 28 },
  399. countryTempIds = new int[] { 2, 13, 29 },
  400. daysTempIds = new int[] { 4, 15, 31 },
  401. ppNumTempIds = new int[] { 6 };
  402. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  403. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  404. .Where((opi, u) => opi.IsDel == 0)
  405. .OrderByDescending((opi, u) => opi.CreateTime)
  406. .Select((opi, u) => new GroupOrderPreInfoListView()
  407. {
  408. Id = opi.Id,
  409. Name = opi.Name,
  410. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  411. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. Operator = u.CnName,
  415. OperationTime = opi.CreateTime
  416. })
  417. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  418. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  419. .ToListAsync();
  420. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  421. int total = list.Count;
  422. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  423. var listPageData1 = listPageData
  424. .Skip((dto.PageIndex - 1) * dto.PageSize)
  425. .Take(dto.PageSize)
  426. .ToList();
  427. var infoIds = listPageData1.Select(x => x.Id).ToList();
  428. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  429. .Where(x => x.IsDel == 0 && x.STid == 109)
  430. .ToArrayAsync();
  431. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  432. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  433. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  434. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  435. .ToListAsync();
  436. foreach (var item in listPageData1)
  437. {
  438. var typeDatas1 = typeDatas.Select(x => new
  439. {
  440. x.Id,
  441. x.Name,
  442. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  443. }).ToArray();
  444. item.VersionDetails = typeDatas1;
  445. }
  446. return Ok(JsonView(listPageData1, listPageData1.Count));
  447. }
  448. /// <summary>
  449. /// 团组前期信息 Init
  450. /// </summary>
  451. /// <returns></returns>
  452. [HttpGet("{userId}")]
  453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  454. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  455. {
  456. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  457. }
  458. /// <summary>
  459. /// 国家数据源
  460. /// </summary>
  461. /// <param name="pageIndex">当前页码</param>
  462. /// <param name="pageSize">每页条数</param>
  463. /// <param name="search">查询条件</param>
  464. /// <returns></returns>
  465. [HttpGet]
  466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  467. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  468. {
  469. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  470. if (pageIndex == 0 && pageSize == 0)
  471. {
  472. //所有数据
  473. return Ok(JsonView(countrys, countrys.Count));
  474. }
  475. //分页
  476. int skip = (pageIndex - 1) * pageSize;
  477. int take = pageSize;
  478. if (!string.IsNullOrEmpty(search))
  479. {
  480. IEnumerable<char> charSequence = search.Select(c => c);
  481. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  482. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  483. return Ok(JsonView(pageData, pageResult1.Count));
  484. }
  485. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  486. return Ok(JsonView(pageResult2, countrys.Count));
  487. }
  488. /// <summary>
  489. /// 城市数据源
  490. /// </summary>
  491. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  492. /// <param name="pageIndex">当前页码</param>
  493. /// <param name="pageSize">每页条数</param>
  494. /// <param name="search">查询条件</param>
  495. /// <returns></returns>
  496. [HttpGet("{countryLabel}")]
  497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  498. public async Task<IActionResult> CityByCountry(
  499. string countryLabel,
  500. [FromQuery] int pageIndex,
  501. [FromQuery] int pageSize,
  502. [FromQuery] string search)
  503. {
  504. countryLabel = HttpUtility.UrlDecode(countryLabel);
  505. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  506. var citys = Array.Empty<string?>();
  507. if (countryList.Any())
  508. {
  509. var cityDatas = await _sqlSugar
  510. .Queryable<Grp_NationalTravelFee>()
  511. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  512. .ToArrayAsync();
  513. foreach (var item in cityDatas)
  514. {
  515. if (item.City.Contains("城市"))
  516. {
  517. item.City = item.Country + "-所有城市";
  518. }
  519. }
  520. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  521. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  522. }
  523. if (pageIndex == 0 && pageSize == 0)
  524. {
  525. //所有数据
  526. return Ok(JsonView(citys, citys?.Length ?? 0));
  527. }
  528. //分页
  529. int skip = (pageIndex - 1) * pageSize;
  530. int take = pageSize;
  531. if (!string.IsNullOrEmpty(search))
  532. {
  533. IEnumerable<char> charSequence = search.Select(c => c);
  534. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  535. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  536. return Ok(JsonView(pageData, pageResult1.Count));
  537. }
  538. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  539. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  540. }
  541. /// <summary>
  542. /// 团组前期信息 Info
  543. /// </summary>
  544. /// <param name="dto">Id</param>
  545. /// <returns></returns>
  546. [HttpGet("{Id}/{TempId}")]
  547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  548. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  549. {
  550. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  551. }
  552. /// <summary>
  553. /// 团组前期信息 移动端 Info
  554. /// </summary>
  555. /// <param name="dto">Id</param>
  556. /// <returns></returns>
  557. [HttpGet("{Id}/{TempId}")]
  558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  559. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  560. {
  561. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  562. }
  563. /// <summary>
  564. /// 团组前期信息 Save
  565. /// </summary>
  566. /// <param name="dto">Id</param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  570. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  571. {
  572. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  573. }
  574. /// <summary>
  575. /// 团组前期信息 Del
  576. /// </summary>
  577. /// <param name="dto">Id</param>
  578. /// <returns></returns>
  579. [HttpPost]
  580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  581. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  582. {
  583. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  584. }
  585. /// <summary>
  586. /// 团组前期信息 文件下载
  587. /// </summary>
  588. /// <param name="dto">Id</param>
  589. /// <returns></returns>
  590. [HttpGet("{Id}/{TempId}")]
  591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  592. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  593. {
  594. int id = dto.Id, tempId = dto.TempId;
  595. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  596. var data = view.Data as GrpOrderPreInfoView;
  597. #region Excel
  598. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  599. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  600. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  601. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  602. var fileNamePrefix = string.Empty;
  603. if (tempId == 1405)
  604. {
  605. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  606. fileNamePrefix = $"{data.Name}_无商邀版";
  607. }
  608. else if (tempId == 1406)
  609. {
  610. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  611. fileNamePrefix = $"{data.Name}_有商邀版";
  612. }
  613. else
  614. {
  615. //tempId == 1404 默认下载
  616. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  617. fileNamePrefix = $"{data.Name}_单接送机";
  618. }
  619. foreach (var item in data.Items)
  620. {
  621. var obj = item.NewValue;
  622. if (obj == null) item.OriginVal = "";
  623. else if (obj.Equals("有") || obj.Equals("无"))
  624. {
  625. item.OriginVal = obj.ToString();
  626. }
  627. else if (obj is object[] objArray)
  628. {
  629. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  630. item.OriginVal = string.Join("、", stringArray);
  631. }
  632. else if (obj is string[] stringArray)
  633. {
  634. item.OriginVal = string.Join("、", stringArray);
  635. }
  636. else if (obj.Equals("-"))
  637. {
  638. item.OriginVal = "";
  639. }
  640. }
  641. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  642. fileName = CommonFun.ValidFileName(fileName);
  643. //载入模板
  644. var designer = new WorkbookDesigner
  645. {
  646. Workbook = new Workbook(tempPath)
  647. };
  648. if (tempId == 1406)
  649. {
  650. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  651. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  652. for (int i = 1; i <= view2.Length; i++)
  653. {
  654. view2[i - 1].Index = i;
  655. }
  656. designer.SetDataSource("View1", view1);
  657. designer.SetDataSource("View2", view2);
  658. }
  659. else
  660. {
  661. designer.SetDataSource("View", data.Items);
  662. }
  663. designer.Process();
  664. if (!Directory.Exists(savePath))
  665. {
  666. Directory.CreateDirectory(savePath);
  667. }
  668. string serverPath = $"{savePath}{fileName}";
  669. designer.Workbook.Save(serverPath);
  670. string rst = $"{servicePath}{ftpPath}{fileName}";
  671. #endregion
  672. return Ok(JsonView(new { url = rst }));
  673. }
  674. #endregion
  675. #region 团组基本信息
  676. /// <summary>
  677. /// 接团信息列表
  678. /// </summary>
  679. /// <param name="dto">团组列表请求dto</param>
  680. /// <returns></returns>
  681. [HttpPost]
  682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  683. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  684. {
  685. var groupData = await _groupRepository.GetGroupList(dto);
  686. if (groupData.Code != 0)
  687. {
  688. return Ok(JsonView(false, groupData.Msg));
  689. }
  690. return Ok(JsonView(groupData.Data));
  691. }
  692. /// <summary>
  693. /// 分页查询团组列表
  694. /// </summary>
  695. /// <param name="dto"></param>
  696. /// <returns></returns>
  697. [HttpPost]
  698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  699. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  700. {
  701. var watch = new Stopwatch();
  702. watch.Start();
  703. RefAsync<int> total = 0;
  704. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  705. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  706. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  707. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  708. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  709. .Distinct()
  710. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  711. watch.Stop();
  712. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  713. }
  714. /// <summary>
  715. /// 接团信息列表 Page Init
  716. /// </summary>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> PostGroupPageListInit()
  721. {
  722. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  723. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  724. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  725. var _view = new
  726. {
  727. depData = depDatas,
  728. rankData = rankDatas
  729. };
  730. return Ok(JsonView(true, "查询成功!", _view));
  731. }
  732. /// <summary>
  733. /// 接团信息列表 Page
  734. /// </summary>
  735. /// <param name="dto">团组列表请求dto</param>
  736. /// <returns></returns>
  737. [HttpPost]
  738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  739. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  740. {
  741. #region 参数验证
  742. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  743. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  744. #region 页面操作权限验证
  745. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  746. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  747. #endregion
  748. #endregion
  749. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  750. {
  751. string sqlWhere = string.Empty;
  752. if (dto.IsSure == 0) //未完成
  753. {
  754. sqlWhere += string.Format(@" And IsSure = 0");
  755. }
  756. else if (dto.IsSure == 1) //已完成
  757. {
  758. sqlWhere += string.Format(@" And IsSure = 1");
  759. }
  760. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  761. {
  762. string tj = dto.SearchCriteria;
  763. 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}%')",
  764. tj, tj, tj, tj, tj);
  765. }
  766. if (int.TryParse(dto.Rank, out int rankId))
  767. {
  768. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  769. }
  770. string sqlWhere1 = string.Empty;
  771. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  772. {
  773. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  774. }
  775. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  776. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  777. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  778. JietuanOperator,IsSure,CreateTime,IsBid
  779. From (
  780. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  781. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  782. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  783. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  784. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  785. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  786. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  787. From Grp_DelegationInfo gdi
  788. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  789. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  790. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  791. Where gdi.IsDel = 0 {0}
  792. ) temp {1}", sqlWhere, sqlWhere1);
  793. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  794. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  795. //处理 团组模块实际操作人
  796. _DelegationList.ForEach(async x =>
  797. {
  798. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  799. var operatorNames = new StringBuilder();
  800. //operatorNames.AppendLine("各模块实际操作人:");
  801. if (operators.Any())
  802. {
  803. operators.ForEach(y =>
  804. {
  805. string label = string.Empty;
  806. if (y.OperationUsers.Any())
  807. {
  808. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  809. label = string.Join('、', users);
  810. }
  811. else label = "暂未指定";
  812. operatorNames.AppendLine($"{y.CTableName}:{label}");
  813. operatorNames.AppendLine();
  814. });
  815. }
  816. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  817. });
  818. var _view = new
  819. {
  820. PageFuncAuth = pageFunAuthView,
  821. Data = _DelegationList
  822. };
  823. return Ok(JsonView(true, "查询成功!", _view, total));
  824. }
  825. else
  826. {
  827. return Ok(JsonView(false, "查询失败"));
  828. }
  829. }
  830. /// <summary>
  831. /// 团组列表
  832. /// </summary>
  833. /// <returns></returns>
  834. [HttpPost]
  835. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  836. {
  837. #region 参数验证
  838. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  839. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  840. #region 页面操作权限验证
  841. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  842. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  843. #endregion
  844. #endregion
  845. if (dto.PortType != 1 && dto.PortType != 2)
  846. {
  847. return Ok(JsonView(false, "查询失败!"));
  848. }
  849. string orderbyStr = "order by gdi.CreateTime Desc";
  850. string sqlWhere = string.Empty;
  851. if (dto.IsSure == 0) //未完成
  852. {
  853. sqlWhere += string.Format(@" And IsSure = 0");
  854. }
  855. else if (dto.IsSure == 1) //已完成
  856. {
  857. sqlWhere += string.Format(@" And IsSure = 1");
  858. }
  859. //团组类型
  860. if (dto.TeamDid > 0)
  861. {
  862. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  863. }
  864. //团组名称
  865. if (!string.IsNullOrEmpty(dto.TeamName))
  866. {
  867. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  868. }
  869. //客户名称
  870. if (!string.IsNullOrEmpty(dto.ClientName))
  871. {
  872. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  873. }
  874. //客户单位
  875. if (!string.IsNullOrEmpty(dto.ClientUnit))
  876. {
  877. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  878. }
  879. //出访时间
  880. if (!string.IsNullOrEmpty(dto.visitDataTime))
  881. {
  882. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  883. orderbyStr = "order by gdi.VisitDate";
  884. }
  885. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  886. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  887. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  888. JietuanOperator,IsSure,CreateTime
  889. From (
  890. Select row_number() over({0}) as Row_Number,
  891. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  892. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  893. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  894. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  895. From Grp_DelegationInfo gdi
  896. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  897. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  898. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  899. Where gdi.IsDel = 0 {1}
  900. ) temp ", orderbyStr, sqlWhere);
  901. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  902. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  903. #region 处理所属部门
  904. /*
  905. * 1.sq 和 gyy 等显示 市场部
  906. * 2.王鸽和主管及张总还有管理员号统一国交部
  907. * 2-1. 4 管理员 ,21 张海麟
  908. */
  909. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  910. var userIds1 = new List<int>() { 4, 21 };
  911. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  912. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  913. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  914. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  915. .ToList();
  916. foreach (var item in _DelegationList)
  917. {
  918. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  919. }
  920. #endregion
  921. var _view = new
  922. {
  923. PageFuncAuth = pageFunAuthView,
  924. Data = _DelegationList
  925. };
  926. return Ok(JsonView(true, "查询成功!", _view, total));
  927. }
  928. /// <summary>
  929. /// 接团信息详情
  930. /// </summary>
  931. /// <param name="dto">团组info请求dto</param>
  932. /// <returns></returns>
  933. [HttpPost]
  934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  935. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  936. {
  937. var groupData = await _groupRepository.GetGroupInfo(dto);
  938. if (groupData.Code != 0)
  939. {
  940. return Ok(JsonView(false, groupData.Msg));
  941. }
  942. return Ok(JsonView(groupData.Data));
  943. }
  944. /// <summary>
  945. /// 接团信息 编辑添加
  946. /// 基础信息数据源
  947. /// </summary>
  948. /// <param name="dto"></param>
  949. /// <returns></returns>
  950. [HttpPost]
  951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  952. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  953. {
  954. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  955. if (groupData.Code != 0)
  956. {
  957. return Ok(JsonView(false, groupData.Msg));
  958. }
  959. return Ok(JsonView(groupData.Data));
  960. }
  961. /// <summary>
  962. /// 成本修改团组信息
  963. /// </summary>
  964. /// <param name="dto"></param>
  965. /// <returns></returns>
  966. [HttpPost]
  967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  968. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  969. {
  970. var jw = JsonView(false, "操作失败");
  971. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  972. if (di == null)
  973. {
  974. jw.Msg = "参数有误!";
  975. return Ok(jw);
  976. }
  977. #region 添加出访起止时间
  978. var startTime = new DateTime();
  979. var endTime = new DateTime();
  980. if (DateTime.TryParse(dto.VisitDate, out startTime))
  981. {
  982. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  983. }
  984. else
  985. {
  986. jw.Msg = "参数有误!";
  987. return Ok(jw);
  988. }
  989. #endregion
  990. di.VisitDate = startTime;
  991. di.VisitPNumber = dto.VisitPNumber;
  992. di.VisitDays = dto.VisitDays;
  993. di.VisitStartDate = startTime;
  994. di.VisitEndDate = endTime;
  995. var count = _sqlSugar.Updateable(di)
  996. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  997. .ExecuteCommand();
  998. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  999. }
  1000. /// <summary>
  1001. /// 接团信息 编辑添加
  1002. /// 省份-城市 基础信息数据源
  1003. /// </summary>
  1004. /// <param name="dto"></param>
  1005. /// <returns></returns>
  1006. [HttpPost]
  1007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1008. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1009. {
  1010. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1011. string search = dto.Search;
  1012. var data = await _groupRepository.CityBasicSource();
  1013. int total = data.Length;
  1014. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1015. .Skip((pageIndex - 1) * pageSize)
  1016. .Take(pageSize)
  1017. .ToArray();
  1018. return Ok(JsonView(data, total));
  1019. }
  1020. /// <summary>
  1021. /// 接团信息 操作(增改)
  1022. /// </summary>
  1023. /// <param name="dto"></param>
  1024. /// <returns></returns>
  1025. [HttpPost]
  1026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1027. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1028. {
  1029. // 创建 Stopwatch 实例
  1030. Stopwatch stopwatch = Stopwatch.StartNew();
  1031. decimal ffrPrice = 0.00M;
  1032. DateTime? visitDt = null;
  1033. if (dto.Status == 2)
  1034. {
  1035. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1036. if (groupInfo != null)
  1037. {
  1038. ffrPrice = groupInfo.PaymentMoney;
  1039. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1040. }
  1041. }
  1042. var groupData = await _groupRepository.GroupOperation(dto);
  1043. if (groupData.Code != 0)
  1044. {
  1045. return Ok(JsonView(false, groupData.Msg));
  1046. }
  1047. int diId = 0;
  1048. try
  1049. {
  1050. //添加时 默认加入团组汇率
  1051. if (dto.Status == 1) //添加
  1052. {
  1053. diId = groupData.Data;
  1054. //添加默认币种
  1055. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1056. //默认分配权限
  1057. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1058. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1059. var _managerIds = new List<int>() { 22, 32, 21 };
  1060. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1061. if (userIds.Count > 0)
  1062. {
  1063. userIds.Add(208);
  1064. //创建团组管控
  1065. GroupStepForDelegation.CreateWorkStep(diId);
  1066. //发送消息
  1067. string groupName = dto.TeamName;
  1068. string createGroupUser = string.Empty;
  1069. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1070. if (userInfo != null) createGroupUser = userInfo.CnName;
  1071. string title = $"系统通知";
  1072. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1073. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1074. }
  1075. //默认创建倒推表
  1076. await _invertedListRep._Create(dto.UserId, diId);
  1077. }
  1078. else if (dto.Status == 2)
  1079. {
  1080. diId = dto.Id;
  1081. }
  1082. #region 签证人员团组时间通知
  1083. #region 计算出访起止时间
  1084. var startTime = new DateTime();
  1085. var endTime = new DateTime();
  1086. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1087. {
  1088. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1089. }
  1090. #endregion
  1091. #endregion
  1092. #region 团组操作默认添加/修改收款账单
  1093. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1094. {
  1095. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1096. .Where(x => x.IsDel == 0 &&
  1097. x.Diid == diId &&
  1098. x.Remark.Equals("预付款")
  1099. )
  1100. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1101. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1102. .FirstAsync();
  1103. ffrInfo = new Fin_ForeignReceivables()
  1104. {
  1105. Diid = diId,
  1106. PriceName = dto.ClientUnit,
  1107. Price = dto.PaymentMoney,
  1108. Count = 1,
  1109. Unit = $"元",
  1110. ItemSumPrice = dto.PaymentMoney,
  1111. Rate = 1.0000M,
  1112. Currency = 836,
  1113. AddingWay = 0,
  1114. CreateUserId = dto.UserId,
  1115. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1116. Remark = $"预付款"
  1117. };
  1118. if (ffrInfo == null) //Add
  1119. {
  1120. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1121. }
  1122. else //修改
  1123. {
  1124. await _sqlSugar.Updateable(ffrInfo)
  1125. .UpdateColumns(x => new
  1126. {
  1127. x.PriceName,
  1128. x.Price,
  1129. x.ItemSumPrice,
  1130. x.CreateTime,
  1131. x.CreateUserId
  1132. })
  1133. .WhereColumns(x => x.Id)
  1134. .ExecuteCommandAsync();
  1135. }
  1136. }
  1137. #endregion
  1138. if (diId > 0)
  1139. {
  1140. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1141. }
  1142. // 停止计时
  1143. stopwatch.Stop();
  1144. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1145. }
  1146. catch (Exception ex)
  1147. {
  1148. // 停止计时
  1149. stopwatch.Stop();
  1150. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1151. Logs(ex.Message);
  1152. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1153. }
  1154. // 停止计时
  1155. stopwatch.Stop();
  1156. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1157. }
  1158. /// <summary>
  1159. /// 接团流程操作(增改)
  1160. /// 安卓端使用 建团时添加客户名单
  1161. /// </summary>
  1162. /// <param name="dto"></param>
  1163. /// <returns></returns>
  1164. [HttpPost]
  1165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1166. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1167. {
  1168. #region 参数验证
  1169. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1170. #region 页面操作权限验证
  1171. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1172. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1173. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1174. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1175. #endregion
  1176. #endregion
  1177. try
  1178. {
  1179. //_sqlSugar.BeginTran();
  1180. decimal ffrPrice = 0.00M;
  1181. DateTime? visitDt = null;
  1182. if (dto.Status == 2)
  1183. {
  1184. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1185. if (groupInfo != null)
  1186. {
  1187. ffrPrice = groupInfo.PaymentMoney;
  1188. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1189. }
  1190. }
  1191. var _dto = new GroupOperationDto();
  1192. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1193. var groupData = await _groupRepository.GroupOperation(_dto);
  1194. if (groupData.Code != 0)
  1195. {
  1196. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1197. }
  1198. int diId = 0;
  1199. //添加时 默认加入团组汇率
  1200. if (dto.Status == 1) //添加
  1201. {
  1202. diId = groupData.Data;
  1203. //添加默认币种
  1204. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1205. //默认分配权限
  1206. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1207. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1208. var _managerIds = new List<int>() { 21, 22, 32 };
  1209. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1210. if (userIds.Count > 0)
  1211. {
  1212. userIds.Add(208);
  1213. //创建团组管控
  1214. GroupStepForDelegation.CreateWorkStep(diId);
  1215. //发送消息
  1216. string groupName = dto.TeamName;
  1217. string createGroupUser = string.Empty;
  1218. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1219. if (userInfo != null) createGroupUser = userInfo.CnName;
  1220. string title = $"系统通知";
  1221. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1222. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1223. }
  1224. #region 应用推送
  1225. try
  1226. {
  1227. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1228. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1229. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1230. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1231. {
  1232. var userList = new List<string>() { users.QiyeChatUserId };
  1233. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1234. }
  1235. }
  1236. catch (Exception ex)
  1237. {
  1238. }
  1239. #endregion
  1240. //默认创建倒推表
  1241. await _invertedListRep._Create(dto.UserId, diId);
  1242. }
  1243. if (dto.Status == 2)
  1244. {
  1245. diId = dto.Id;
  1246. if (diId == 0)
  1247. {
  1248. //_sqlSugar.RollbackTran();
  1249. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1250. }
  1251. }
  1252. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1253. if (viewData.Code != 0)
  1254. {
  1255. //_sqlSugar.RollbackTran();
  1256. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1257. }
  1258. #region 团组操作默认添加/修改收款账单
  1259. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1260. {
  1261. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1262. .Where(x => x.IsDel == 0 &&
  1263. x.Diid == diId &&
  1264. x.Remark.Equals("预付款")
  1265. )
  1266. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1267. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1268. .FirstAsync();
  1269. ffrInfo = new Fin_ForeignReceivables()
  1270. {
  1271. Diid = diId,
  1272. PriceName = dto.ClientUnit,
  1273. Price = dto.PaymentMoney,
  1274. Count = 1,
  1275. Unit = $"元",
  1276. ItemSumPrice = dto.PaymentMoney,
  1277. Rate = 1.0000M,
  1278. Currency = 836,
  1279. AddingWay = 0,
  1280. CreateUserId = dto.UserId,
  1281. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1282. Remark = $"预付款"
  1283. };
  1284. if (ffrInfo == null) //Add
  1285. {
  1286. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1287. }
  1288. else //修改
  1289. {
  1290. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1291. .UpdateColumns(x => new
  1292. {
  1293. x.PriceName,
  1294. x.Price,
  1295. x.ItemSumPrice,
  1296. x.CreateTime,
  1297. x.CreateUserId
  1298. })
  1299. .WhereColumns(x => x.Id)
  1300. .ExecuteCommandAsync();
  1301. }
  1302. }
  1303. #endregion
  1304. #region 签证人员团组时间通知
  1305. #region 计算出访起止时间
  1306. var startTime = new DateTime();
  1307. var endTime = new DateTime();
  1308. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1309. {
  1310. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1311. }
  1312. #endregion
  1313. if (diId > 0)
  1314. {
  1315. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1316. }
  1317. #endregion
  1318. //_sqlSugar.CommitTran();
  1319. return Ok(JsonView(true, "添加成功"));
  1320. }
  1321. catch (Exception ex)
  1322. {
  1323. _sqlSugar.RollbackTran();
  1324. return Ok(JsonView(false, ex.Message));
  1325. }
  1326. }
  1327. /// <summary>
  1328. /// 接团流程操作(增改)
  1329. /// 安卓端使用 建团时添加客户名单
  1330. /// </summary>
  1331. /// <param name="dto"></param>
  1332. /// <returns></returns>
  1333. [HttpPost]
  1334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1335. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1336. {
  1337. #region 参数验证
  1338. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1339. #region 页面操作权限验证
  1340. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1341. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1342. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1343. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1344. #endregion
  1345. #endregion
  1346. _sqlSugar.BeginTran();
  1347. decimal ffrPrice = 0.00M;
  1348. DateTime? visitDt = null;
  1349. if (dto.Status == 2)
  1350. {
  1351. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1352. if (groupInfo != null)
  1353. {
  1354. ffrPrice = groupInfo.PaymentMoney;
  1355. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1356. }
  1357. }
  1358. var _dto = new GroupOperationDto();
  1359. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1360. var groupData = await _groupRepository.GroupOperation(_dto);
  1361. if (groupData.Code != 0)
  1362. {
  1363. _sqlSugar.RollbackTran();
  1364. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1365. }
  1366. try
  1367. {
  1368. int diId = 0;
  1369. //添加时 默认加入团组汇率
  1370. if (dto.Status == 1) //添加
  1371. {
  1372. diId = groupData.Data;
  1373. //添加默认币种
  1374. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1375. //默认分配权限
  1376. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1377. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1378. var _managerIds = new List<int>() { 21, 22, 32 };
  1379. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1380. if (userIds.Count > 0)
  1381. {
  1382. userIds.Add(208);
  1383. //创建团组管控
  1384. GroupStepForDelegation.CreateWorkStep(diId);
  1385. //发送消息
  1386. string groupName = dto.TeamName;
  1387. string createGroupUser = string.Empty;
  1388. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1389. if (userInfo != null) createGroupUser = userInfo.CnName;
  1390. string title = $"系统通知";
  1391. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1392. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1393. }
  1394. #region 应用推送
  1395. try
  1396. {
  1397. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1398. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1399. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1400. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1401. {
  1402. var userList = new List<string>() { users.QiyeChatUserId };
  1403. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1404. }
  1405. }
  1406. catch (Exception ex)
  1407. {
  1408. _sqlSugar.CommitTran();
  1409. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1410. }
  1411. #endregion
  1412. //默认创建倒推表
  1413. await _invertedListRep._Create(dto.UserId, diId);
  1414. }
  1415. else if (dto.Status == 2)
  1416. {
  1417. diId = dto.Id;
  1418. if (diId == 0)
  1419. {
  1420. _sqlSugar.RollbackTran();
  1421. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1422. }
  1423. }
  1424. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1425. if (viewData.Code != 0)
  1426. {
  1427. _sqlSugar.RollbackTran();
  1428. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1429. }
  1430. #region 团组操作默认添加/修改收款账单
  1431. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1432. {
  1433. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1434. .Where(x => x.IsDel == 0 &&
  1435. x.Diid == diId &&
  1436. x.Remark.Equals("预付款")
  1437. )
  1438. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1439. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1440. .FirstAsync();
  1441. ffrInfo = new Fin_ForeignReceivables()
  1442. {
  1443. Diid = diId,
  1444. PriceName = dto.ClientUnit,
  1445. Price = dto.PaymentMoney,
  1446. Count = 1,
  1447. Unit = $"元",
  1448. ItemSumPrice = dto.PaymentMoney,
  1449. Rate = 1.0000M,
  1450. Currency = 836,
  1451. AddingWay = 0,
  1452. CreateUserId = dto.UserId,
  1453. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1454. Remark = $"预付款"
  1455. };
  1456. if (ffrInfo == null) //Add
  1457. {
  1458. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1459. }
  1460. else //修改
  1461. {
  1462. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1463. .UpdateColumns(x => new
  1464. {
  1465. x.PriceName,
  1466. x.Price,
  1467. x.ItemSumPrice,
  1468. x.CreateTime,
  1469. x.CreateUserId
  1470. })
  1471. .WhereColumns(x => x.Id)
  1472. .ExecuteCommandAsync();
  1473. }
  1474. }
  1475. #endregion
  1476. #region 签证人员团组时间通知
  1477. #region 计算出访起止时间
  1478. var startTime = new DateTime();
  1479. var endTime = new DateTime();
  1480. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1481. {
  1482. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1483. }
  1484. #endregion
  1485. if (diId > 0)
  1486. {
  1487. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1488. }
  1489. #endregion
  1490. _sqlSugar.CommitTran();
  1491. return Ok(JsonView(true));
  1492. }
  1493. catch (Exception ex)
  1494. {
  1495. _sqlSugar.RollbackTran();
  1496. return Ok(JsonView(false, ex.Message));
  1497. }
  1498. }
  1499. /// <summary>
  1500. /// 接团信息 操作(删除)
  1501. /// </summary>
  1502. /// <param name="dto"></param>
  1503. /// <returns></returns>
  1504. [HttpPost]
  1505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1506. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1507. {
  1508. var diId = dto.Id;
  1509. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1510. #region 删除 验证
  1511. /*
  1512. * 1、收款账单数据:0 条
  1513. * 2、收款退还数据:0 条
  1514. * 3、机票费用数据:0 条
  1515. * 4、签证费用数据:0 条
  1516. * 5、保险费用数据:0 条
  1517. * 6、酒店费用数据:0 条
  1518. * 7、公务出访数据:1 条
  1519. * 8、邀请公务活动费用数据:1 条
  1520. * 9、OP费用数据:5 条
  1521. * 10、其他费用数据:0 条
  1522. * 11、团组日付报销费用数据:0 条
  1523. *
  1524. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1525. */
  1526. //收款账单
  1527. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1528. //收款退还
  1529. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1530. //机票费用
  1531. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1532. //签证费用
  1533. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1534. //保险费用
  1535. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1536. //酒店费用
  1537. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1538. //公务出访
  1539. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1540. //邀请公务活动费用
  1541. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1542. //OP费用
  1543. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1544. //其他费用
  1545. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1546. //团组日付报销费用
  1547. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1548. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1549. if (feeCount > 0)
  1550. {
  1551. var delMsgTips = new StringBuilder();
  1552. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1553. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1554. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1555. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1556. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1557. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1558. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1559. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1560. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1561. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1562. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1563. delMsgTips.AppendLine($"");
  1564. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1565. return Ok(JsonView(false, delMsgTips.ToString()));
  1566. }
  1567. #endregion
  1568. var groupData = await _groupRepository.GroupDel(dto);
  1569. if (groupData.Code != 0)
  1570. {
  1571. return Ok(JsonView(false, groupData.Msg));
  1572. }
  1573. return Ok(JsonView(true));
  1574. }
  1575. /// <summary>
  1576. /// 获取团组销售报价号
  1577. /// 团组添加时 使用
  1578. /// </summary>
  1579. /// <returns></returns>
  1580. [HttpPost]
  1581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1582. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1583. {
  1584. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1585. if (groupData.Code != 0)
  1586. {
  1587. return Ok(JsonView(false, groupData.Msg));
  1588. }
  1589. object salesQuoteNo = new
  1590. {
  1591. SalesQuoteNo = groupData.Data
  1592. };
  1593. return Ok(JsonView(salesQuoteNo));
  1594. }
  1595. /// <summary>
  1596. /// 设置确认出团
  1597. /// </summary>
  1598. /// <param name="dto"></param>
  1599. /// <returns></returns>
  1600. [HttpPost]
  1601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1602. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1603. {
  1604. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1605. if (groupData.Code != 0)
  1606. {
  1607. return Ok(JsonView(false, groupData.Msg));
  1608. }
  1609. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1610. #region OA消息推送
  1611. try
  1612. {
  1613. string groupName = groupInfo.TeamName;
  1614. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1615. string title = $"系统通知";
  1616. string content = $"团组[{groupName}]已确认出团!";
  1617. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1618. }
  1619. catch (Exception ex)
  1620. {
  1621. }
  1622. #endregion
  1623. #region 应用推送
  1624. try
  1625. {
  1626. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1627. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1628. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1629. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1630. {
  1631. var userList = new List<string>() { users.QiyeChatUserId };
  1632. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1633. }
  1634. }
  1635. catch (Exception ex)
  1636. {
  1637. }
  1638. #endregion
  1639. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1640. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1641. }
  1642. /// <summary>
  1643. /// 获取团组名称data And 签证国别Data
  1644. /// </summary>
  1645. /// <param name="dto"></param>
  1646. /// <returns></returns>
  1647. [HttpPost]
  1648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1649. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1650. {
  1651. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1652. if (groupData.Code != 0)
  1653. {
  1654. return Ok(JsonView(false, groupData.Msg));
  1655. }
  1656. return Ok(JsonView(groupData.Data));
  1657. }
  1658. /// <summary>
  1659. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1660. /// </summary>
  1661. /// <returns></returns>
  1662. [HttpPost]
  1663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1664. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1665. {
  1666. try
  1667. {
  1668. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1669. if (groupData.Code != 0)
  1670. {
  1671. return Ok(JsonView(false, groupData.Msg));
  1672. }
  1673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1674. }
  1675. catch (Exception ex)
  1676. {
  1677. return Ok(JsonView(false, ex.Message));
  1678. throw;
  1679. }
  1680. }
  1681. /// <summary>
  1682. /// 团组清单 Excel
  1683. /// </summary>
  1684. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1685. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1686. /// <returns></returns>
  1687. [HttpGet]
  1688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1689. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1690. {
  1691. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1692. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1693. if (!beginBool && !endBool)
  1694. {
  1695. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1696. }
  1697. string sql = string.Format(@"
  1698. SELECT
  1699. ROW_NUMBER,
  1700. Id,
  1701. SalesQuoteNo,
  1702. TourCode,
  1703. TeamTypeId,
  1704. TeamType,
  1705. TeamLevId,
  1706. TeamLev,
  1707. TeamName,
  1708. ClientName,
  1709. ClientUnit,
  1710. VisitDate,
  1711. VisitDays,
  1712. VisitPNumber,
  1713. JietuanOperatorId,
  1714. JietuanOperator,
  1715. IsSure,
  1716. CreateUserName,
  1717. IsBid
  1718. FROM
  1719. (
  1720. SELECT
  1721. ROW_NUMBER() OVER(
  1722. ORDER BY
  1723. gdi.VisitDate Desc
  1724. ) AS ROW_NUMBER,
  1725. gdi.Id,
  1726. SalesQuoteNo,
  1727. TourCode,
  1728. ssd.Id TeamTypeId,
  1729. ssd.Name TeamType,
  1730. ssd1.Id TeamLevId,
  1731. ssd1.Name TeamLev,
  1732. TeamName,
  1733. ClientName,
  1734. ClientUnit,
  1735. VisitDate,
  1736. VisitDays,
  1737. VisitPNumber,
  1738. JietuanOperator JietuanOperatorId,
  1739. su.CnName JietuanOperator,
  1740. IsSure,
  1741. gdi.CreateTime,
  1742. su1.CnName As CreateUserName,
  1743. gdi.IsBid
  1744. FROM
  1745. Grp_DelegationInfo gdi
  1746. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1747. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1748. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1749. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1750. WHERE
  1751. gdi.IsDel = 0
  1752. AND gdi.IsBid = 0
  1753. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1754. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1755. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1756. #region 处理所属部门
  1757. /*
  1758. * 1.sq 和 gyy 等显示 市场部
  1759. * 2.王鸽和主管及张总还有管理员号统一国交部
  1760. * 2-1. 4 管理员 ,21 张海麟
  1761. */
  1762. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1763. var userIds1 = new List<int>() { 4, 21 };
  1764. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1765. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1766. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1767. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1768. .ToListAsync();
  1769. var droupIds = groupList.Select(it => it.Id).ToList();
  1770. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1771. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1772. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1773. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1774. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1775. {
  1776. DiId = tcl.DiId,
  1777. LastName = dc.LastName,
  1778. FirstName = dc.FirstName,
  1779. Sex = dc.Sex,
  1780. Birthday = dc.BirthDay,
  1781. Company = cc.CompanyFullName,
  1782. Job = dc.Job,
  1783. CreateTime = tcl.CreateTime,
  1784. })
  1785. .ToList();
  1786. foreach (var item in groupList)
  1787. {
  1788. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1789. string groupFirstName = "";
  1790. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1791. if (currDatas.Any())
  1792. {
  1793. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1794. }
  1795. item.GroupFirst = groupFirstName;
  1796. }
  1797. #endregion
  1798. #region Excel
  1799. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1800. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1801. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1802. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1803. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1804. //载入模板
  1805. var designer = new WorkbookDesigner
  1806. {
  1807. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1808. };
  1809. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1810. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1811. dt.TableName = "GroupList";
  1812. designer.SetDataSource(dt);
  1813. designer.Process();
  1814. if (!Directory.Exists(savePath))
  1815. {
  1816. Directory.CreateDirectory(savePath);
  1817. }
  1818. string serverPath = $"{savePath}{fileName}";
  1819. designer.Workbook.Save(serverPath);
  1820. string rst = $"{servicePath}{ftpPath}{fileName}";
  1821. #endregion
  1822. return Ok(JsonView(true, "操作成功!", rst));
  1823. }
  1824. /// <summary>
  1825. /// 团组合同下载(1.付款80% 2.付全款)
  1826. /// </summary>
  1827. /// <param name="dto"></param>
  1828. /// <returns></returns>
  1829. /// <exception cref="Exception"></exception>
  1830. [HttpPost]
  1831. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1832. {
  1833. var jw = JsonView(false);
  1834. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1835. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1836. if (di == null)
  1837. {
  1838. jw.Msg = "团组Id有误!";
  1839. return Ok(jw);
  1840. }
  1841. #region 权限校验
  1842. var allDownFile = new List<int>() { 21 };
  1843. try
  1844. {
  1845. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1846. .First(x => x.Id == 1418 && x.IsDel == 0);
  1847. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1848. }
  1849. catch (Exception)
  1850. { }
  1851. var guojiaoDownFile = new List<int>() { 330 };
  1852. var shichangDownFile = new List<int>() { 95 };
  1853. if (allDownFile.Contains(dto.UserId))
  1854. {
  1855. }
  1856. else if (guojiaoDownFile.Contains(dto.UserId))
  1857. {
  1858. var guojiaobuDi = new List<int>() { 4, 21 };
  1859. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1860. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1861. .Where((d, u) => u.Id == di.JietuanOperator)
  1862. .Select((d, u) => d.DepName)
  1863. .First();
  1864. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1865. {
  1866. jw.Msg = "暂无下载权限!";
  1867. return Ok(jw);
  1868. }
  1869. }
  1870. else if (shichangDownFile.Contains(dto.UserId))
  1871. {
  1872. var dic = new Dictionary<int, int[]>()
  1873. {
  1874. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1875. };
  1876. try
  1877. {
  1878. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1879. if (sqSetting != null)
  1880. {
  1881. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1882. foreach (var item in result.Keys)
  1883. {
  1884. if (dic.ContainsKey(item))
  1885. {
  1886. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1887. Array.Copy(dic[item], dilatation, dic[item].Length);
  1888. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1889. dic[item] = dilatation;
  1890. }
  1891. else
  1892. {
  1893. dic.Add(item, result[item]);
  1894. }
  1895. }
  1896. }
  1897. if (!dic[95].Contains(di.CreateUserId))
  1898. {
  1899. jw.Msg = "暂无下载权限!";
  1900. return Ok(jw);
  1901. }
  1902. }
  1903. catch (Exception)
  1904. { }
  1905. }
  1906. else if (dto.UserId == di.CreateUserId)
  1907. {
  1908. }
  1909. else
  1910. {
  1911. jw.Msg = "暂无下载权限!";
  1912. return Ok(jw);
  1913. }
  1914. #endregion
  1915. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1916. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1917. .ToListAsync();
  1918. if (!blackCodeList.Any())
  1919. {
  1920. jw.Msg = "该团无机票行程代码!";
  1921. return Ok(jw);
  1922. }
  1923. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1924. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1925. if (groupEnterExitCost == null)
  1926. {
  1927. jw.Msg = "暂无三公费用信息!";
  1928. return Ok(jw);
  1929. }
  1930. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1931. rateList ??= new List<CurrencyInfo>();
  1932. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1933. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1934. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1935. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1936. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1937. .Select((x, a, b) => new
  1938. {
  1939. x.Index,
  1940. itemName = a.Name,
  1941. CurrencyStr = b.Name,
  1942. x.Cost,
  1943. x.SubTotal,
  1944. x.Remark
  1945. })
  1946. .OrderBy((x) => x.Index)
  1947. .ToList();
  1948. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1949. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1950. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1951. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1952. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1953. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1954. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1955. decimal subJJC = 0.00M,
  1956. subGWC = 0.00M,
  1957. subTDC = 0.00M;
  1958. //经济舱
  1959. if (groupEnterExitCost.SumJJC == 1)
  1960. {
  1961. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1962. }
  1963. //公务舱
  1964. if (groupEnterExitCost.SumGWC == 1)
  1965. {
  1966. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1967. }
  1968. //头等舱
  1969. if (groupEnterExitCost.SumTDC == 1)
  1970. {
  1971. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1972. }
  1973. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1974. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1975. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1976. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1977. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1978. .Select((x, s, dc, cc) => new GroupClints
  1979. {
  1980. Id = x.Id,
  1981. Name = s.Name,
  1982. IsAccompany = x.IsAccompany,
  1983. CompanyFullName = cc.CompanyFullName
  1984. })
  1985. .ToListAsync();
  1986. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1987. //获取舱位人数
  1988. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1989. .GroupBy(x => x.Name)
  1990. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1991. .ToList();
  1992. string cityPath = string.Empty;
  1993. string startCity = string.Empty;
  1994. string endCity = string.Empty;
  1995. foreach (var item in blackCodeList)
  1996. {
  1997. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1998. cityPath += city + "\r\n";
  1999. if (item.Equals(blackCodeList.First()))
  2000. {
  2001. var sp = city.Split('-');
  2002. startCity = sp[0];
  2003. endCity = sp[^1];
  2004. }
  2005. }
  2006. var bookMarkDic = new Dictionary<string, string>
  2007. {
  2008. { "ClientUnit", di.ClientUnit },
  2009. { "VisitCountry", di.VisitCountry },
  2010. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2011. { "VisitPNumber", di.VisitPNumber.ToString() },
  2012. { "CityPath", cityPath },
  2013. { "StartCity", startCity },
  2014. { "EndCity", endCity },
  2015. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2016. };
  2017. Document doc = null;
  2018. var percentage = 0.8M;
  2019. var fileNameadd = "预付";
  2020. if (dto.FileType == 1)
  2021. {
  2022. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2023. }
  2024. else if (dto.FileType == 2)
  2025. {
  2026. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2027. percentage = 1;
  2028. fileNameadd = "全款";
  2029. }
  2030. else
  2031. {
  2032. throw new Exception("FileType有误!");
  2033. }
  2034. var builder = new DocumentBuilder(doc);
  2035. decimal totalPrice = 0.00M;
  2036. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2037. if (firstTable != null)
  2038. {
  2039. // 遍历表格的行和单元格
  2040. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2041. {
  2042. for (int i = 0; i < row.Cells.Count; i++)
  2043. {
  2044. var cell = row.Cells[i];
  2045. // 读取单元格内容
  2046. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2047. if (cellTextFirst.Contains("舱位"))
  2048. {
  2049. break;
  2050. }
  2051. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2052. {
  2053. if (i == 2)
  2054. {
  2055. if (cellTextFirst == "经济舱")
  2056. {
  2057. // 设置单元格内容
  2058. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2059. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2060. }
  2061. else
  2062. {
  2063. // 设置单元格内容
  2064. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2065. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2066. }
  2067. }
  2068. if (i == 3)
  2069. {
  2070. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2071. if (count != null)
  2072. {
  2073. // 设置单元格内容
  2074. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2075. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2076. }
  2077. }
  2078. if (i == 4)
  2079. {
  2080. var rowPrice = 0.00M;
  2081. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2082. count ??= 0;
  2083. if (cellTextFirst == "经济舱")
  2084. {
  2085. rowPrice = subJJC * (int)count;
  2086. }
  2087. else
  2088. {
  2089. rowPrice = subGWC * (int)count;
  2090. }
  2091. totalPrice += rowPrice;
  2092. // 设置单元格内容
  2093. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2094. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2095. }
  2096. }
  2097. }
  2098. }
  2099. }
  2100. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2101. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2102. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2103. //--合同表格部分
  2104. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2105. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2106. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2107. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2108. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2109. bookMarkDic.Add("CityPath1", cityPath);
  2110. bookMarkDic.Add("CityPath2", cityPath);
  2111. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2112. if (contractTable != null)
  2113. {
  2114. //数据源
  2115. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2116. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2117. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2118. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2119. .Select((it, y, s) => new
  2120. {
  2121. it.Cost,
  2122. it.SubTotal,
  2123. it.Type,
  2124. y.Id,
  2125. y.City,
  2126. s.Name,
  2127. CurrencyCodeCn = s.Remark
  2128. })
  2129. .ToList()
  2130. .Select(x => new
  2131. {
  2132. CurrencyCode = x.Name,
  2133. CityId = x.Id,
  2134. x.City,
  2135. di.VisitPNumber,
  2136. x.Type,
  2137. x.Cost,
  2138. x.SubTotal,
  2139. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2140. x.CurrencyCodeCn,
  2141. });
  2142. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2143. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2144. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2145. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2146. var tableSettings = new List<tableSetting>()
  2147. {
  2148. new(){ Index = 1 , Property = "City"},
  2149. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2150. new(){ Index = 3 , Property = "Cost"},
  2151. new(){ Index = 4 , Property = "VisitPNumber"},
  2152. //new tableSetting{ Index = 5 , Property = ""},
  2153. //new tableSetting{ Index = 6 , Property = ""},
  2154. new(){ Index = 7 , Property = "Rate"},
  2155. //new tableSetting{ Index = 8 , Property = ""},
  2156. };
  2157. //1.住宿费
  2158. int cloneRow = 8;
  2159. int startDayPrice = 8; //写入index
  2160. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2161. foreach (var dac in dac1)
  2162. {
  2163. var first = dac.First();
  2164. var dayCount = dac.Count();
  2165. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2166. for (int i = 1; i < row.Cells.Count; i++)
  2167. {
  2168. var cell = row.Cells[i];
  2169. var findProperty = tableSettings.Find(x => x.Index == i);
  2170. if (findProperty != null)
  2171. {
  2172. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2173. // 设置单元格内容
  2174. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2175. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2176. }
  2177. else
  2178. {
  2179. switch (i)
  2180. {
  2181. case 5:
  2182. cell.FirstParagraph.Runs.Clear();
  2183. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2184. break;
  2185. case 6:
  2186. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2187. cell.FirstParagraph.Runs.Clear();
  2188. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2189. break;
  2190. case 8:
  2191. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2192. cell.FirstParagraph.Runs.Clear();
  2193. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2194. ZSPriceSum += xiaojiRMB;
  2195. break;
  2196. default:
  2197. break;
  2198. }
  2199. }
  2200. }
  2201. startDayPrice++;
  2202. if (!dac1.Last().Equals(dac))
  2203. {
  2204. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2205. // 将克隆的行追加到原行后面
  2206. contractTable.Rows.Insert(startDayPrice, newRow);
  2207. }
  2208. else
  2209. {
  2210. cloneRow += dac1.Count + 1;
  2211. startDayPrice = cloneRow;
  2212. }
  2213. }
  2214. //2.伙食费
  2215. foreach (var dac in dac2)
  2216. {
  2217. var first = dac.First();
  2218. var dayCount = dac.Count();
  2219. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2220. for (int i = 1; i < row.Cells.Count; i++)
  2221. {
  2222. var cell = row.Cells[i];
  2223. var findProperty = tableSettings.Find(x => x.Index == i);
  2224. if (findProperty != null)
  2225. {
  2226. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2227. // 设置单元格内容
  2228. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2229. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2230. }
  2231. else
  2232. {
  2233. switch (i)
  2234. {
  2235. case 5:
  2236. cell.FirstParagraph.Runs.Clear();
  2237. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2238. break;
  2239. case 6:
  2240. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2241. cell.FirstParagraph.Runs.Clear();
  2242. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2243. break;
  2244. case 8:
  2245. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2246. cell.FirstParagraph.Runs.Clear();
  2247. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2248. HSPriceSum += xiaojiRMB;
  2249. break;
  2250. default:
  2251. break;
  2252. }
  2253. }
  2254. }
  2255. startDayPrice++;
  2256. if (!dac2.Last().Equals(dac))
  2257. {
  2258. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2259. // 将克隆的行追加到原行后面
  2260. contractTable.Rows.Insert(startDayPrice, newRow);
  2261. }
  2262. else
  2263. {
  2264. cloneRow += dac2.Count + 1;
  2265. startDayPrice = cloneRow;
  2266. }
  2267. }
  2268. //3.公杂费
  2269. foreach (var dac in dac3)
  2270. {
  2271. var first = dac.First();
  2272. var dayCount = dac.Count();
  2273. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2274. for (int i = 1; i < row.Cells.Count; i++)
  2275. {
  2276. var cell = row.Cells[i];
  2277. var findProperty = tableSettings.Find(x => x.Index == i);
  2278. if (findProperty != null)
  2279. {
  2280. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2281. // 设置单元格内容
  2282. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2283. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2284. }
  2285. else
  2286. {
  2287. switch (i)
  2288. {
  2289. case 5:
  2290. cell.FirstParagraph.Runs.Clear();
  2291. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2292. break;
  2293. case 6:
  2294. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2295. cell.FirstParagraph.Runs.Clear();
  2296. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2297. break;
  2298. case 8:
  2299. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2300. cell.FirstParagraph.Runs.Clear();
  2301. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2302. GZPriceSum += xiaojiRMB;
  2303. break;
  2304. default:
  2305. break;
  2306. }
  2307. }
  2308. }
  2309. startDayPrice++;
  2310. if (!dac3.Last().Equals(dac))
  2311. {
  2312. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2313. // 将克隆的行追加到原行后面
  2314. contractTable.Rows.Insert(startDayPrice, newRow);
  2315. }
  2316. else
  2317. {
  2318. cloneRow += dac3.Count + 1;
  2319. startDayPrice = cloneRow;
  2320. }
  2321. }
  2322. //合并单元格
  2323. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2324. {
  2325. var currentRow = contractTable.Rows[i];
  2326. var nextRow = contractTable.Rows[i + 1];
  2327. // 获取当前行和下一行的第一个单元格
  2328. Cell currentCell = currentRow.Cells[0];
  2329. Cell nextCell = nextRow.Cells[0];
  2330. // 检查单元格内容是否一致(去除尾部的换行符)
  2331. string currentText = currentCell.GetText().Trim();
  2332. string nextText = nextCell.GetText().Trim();
  2333. if (currentText == nextText)
  2334. {
  2335. // 如果当前单元格已经被合并,找到合并的起始单元格
  2336. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2337. {
  2338. // 找到合并的起始单元格
  2339. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2340. // 将下一行的单元格设置为合并的后续单元格
  2341. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2342. }
  2343. else
  2344. {
  2345. // 如果当前单元格是合并的起始单元格
  2346. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2347. // 将下一行的单元格设置为合并的后续单元格
  2348. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2349. }
  2350. }
  2351. else
  2352. {
  2353. // 如果内容不一致,重置当前单元格的合并属性
  2354. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2355. {
  2356. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2357. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2358. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2359. }
  2360. else
  2361. {
  2362. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2363. }
  2364. }
  2365. }
  2366. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2367. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2368. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2369. }
  2370. foreach (var bookmarkName in bookMarkDic.Keys)
  2371. {
  2372. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2373. if (bookmark != null)
  2374. {
  2375. if (bookmarkName == "ClientUnit")
  2376. {
  2377. // 移动到书签位置
  2378. builder.MoveTo(bookmark.BookmarkStart);
  2379. // 设置字体样式为下划线
  2380. builder.Font.Underline = Aspose.Words.Underline.Single;
  2381. // 插入书签值
  2382. builder.Write(bookMarkDic[bookmarkName]);
  2383. // 清除字体格式,避免影响后续文本
  2384. builder.Font.ClearFormatting();
  2385. }
  2386. else
  2387. {
  2388. builder.MoveToBookmark(bookmarkName);
  2389. builder.Write(bookMarkDic[bookmarkName]);
  2390. }
  2391. }
  2392. }
  2393. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2394. doc.Save(savePaht);
  2395. jw.Msg = "生成成功!";
  2396. jw.Code = 200;
  2397. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2398. return Ok(jw);
  2399. }
  2400. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2401. {
  2402. int index = rowIndex;
  2403. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2404. {
  2405. index--;
  2406. }
  2407. return index;
  2408. }
  2409. #endregion
  2410. #region 团组&签证
  2411. #region 团组&签证 New
  2412. /// <summary>
  2413. /// 团组&签证 New
  2414. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2415. /// </summary>
  2416. /// <param name="file">请求dto</param>
  2417. /// <returns></returns>
  2418. [HttpPost]
  2419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2420. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file, int fileTypeId)
  2421. {
  2422. //文件验证
  2423. if (file.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2424. //var visaFiles = new VisaUploadFileTypeView();
  2425. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2426. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2427. //服务器存储文件
  2428. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2429. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2430. var filePath = Path.Combine(fileServerPath, file.FileName);
  2431. using (var stream = new FileStream(filePath, FileMode.Create))
  2432. {
  2433. await file.CopyToAsync(stream);
  2434. }
  2435. //日志记录-上传文件
  2436. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
  2437. //kimi AI 识别文档返回json结果
  2438. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2439. var KiMiApi = new KiMiApiClient();
  2440. var files = new List<IFormFile>() { file };
  2441. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2442. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2443. var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2444. var messages = new List<SeedMessages>
  2445. {
  2446. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2447. new() { Role = KimiRole.user, Content = seedMessage }
  2448. };
  2449. messages.InsertRange(1, seedConter);
  2450. string jsonString = string.Empty;
  2451. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2452. while (!isJson)
  2453. {
  2454. kimiAI_API_Index++;
  2455. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2456. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2457. jsonString += kimiApiResult_JObject["content"].ToString();
  2458. string startStr = "```json", endStr = "```";
  2459. // 判断并清除开头部分
  2460. if (jsonString.StartsWith(startStr))
  2461. {
  2462. jsonString = jsonString.Replace(startStr, "");
  2463. }
  2464. // 判断并清除结尾部分
  2465. if (jsonString.EndsWith(endStr))
  2466. {
  2467. jsonString = jsonString.Replace(endStr, "");
  2468. }
  2469. //验证json格式是否正确
  2470. try
  2471. {
  2472. JsonDocument.Parse(jsonString);
  2473. isJson = true; // 如果解析成功,则是json格式
  2474. }
  2475. catch (Exception)
  2476. {
  2477. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2478. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2479. }
  2480. }
  2481. var clientInfo = new Crm_DeleClient(); //客户资料表
  2482. var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2483. var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2484. var clientCert = new Crm_CustomerCert(); //客户证件表
  2485. var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2486. //按照表格类型分别进行参数处理
  2487. switch (fileTypeId)
  2488. {
  2489. //澳新签证个人申请表
  2490. case 1:
  2491. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2492. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2493. break;
  2494. default:
  2495. break;
  2496. }
  2497. return Ok(JsonView(true, jsonString));
  2498. }
  2499. #endregion
  2500. /// <summary>
  2501. /// 根据团组Id获取签证客户信息List
  2502. /// </summary>
  2503. /// <param name="dto">请求dto</param>
  2504. /// <returns></returns>
  2505. [HttpPost]
  2506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2507. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2508. {
  2509. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2510. if (groupData.Code != 0)
  2511. {
  2512. return Ok(JsonView(false, groupData.Msg));
  2513. }
  2514. return Ok(JsonView(groupData.Data));
  2515. }
  2516. /// <summary>
  2517. /// IOS获取团组签证拍照上传进度01(团组列表)
  2518. /// </summary>
  2519. /// <param name="dto">请求dto</param>
  2520. /// <returns></returns>
  2521. [HttpPost]
  2522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2523. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2524. {
  2525. if (dto == null)
  2526. {
  2527. return Ok(JsonView(false, "参数为空"));
  2528. }
  2529. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2530. return Ok(JsonView(visaList));
  2531. }
  2532. /// <summary>
  2533. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2534. /// </summary>
  2535. /// <returns></returns>
  2536. [HttpPost]
  2537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2538. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2539. {
  2540. if (dto == null)
  2541. {
  2542. return Ok(JsonView(false, "请求错误:"));
  2543. }
  2544. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2545. return Ok(JsonView(list));
  2546. }
  2547. /// <summary>
  2548. /// IOS获取团组签证拍照上传进度03(相册)
  2549. /// </summary>
  2550. /// <returns></returns>
  2551. [HttpPost]
  2552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2553. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2554. {
  2555. if (dto == null)
  2556. {
  2557. return Ok(JsonView(false, "请求错误:"));
  2558. }
  2559. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2560. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2561. list.ForEach(s => s.url = url);
  2562. return Ok(JsonView(list));
  2563. }
  2564. /// <summary>
  2565. /// IOS获取团组签证拍照上传进度04(图片上传)
  2566. /// </summary>
  2567. /// <param name="dto"></param>
  2568. /// <returns></returns>
  2569. [HttpPost]
  2570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2571. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2572. {
  2573. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2574. //if (!string.IsNullOrEmpty(result))
  2575. //{
  2576. //}
  2577. //else {
  2578. // return Ok(JsonView(false, "上传失败"));
  2579. //}
  2580. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2581. int sucNum = 0;
  2582. try
  2583. {
  2584. foreach (var item in dto.base64DataList)
  2585. {
  2586. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2587. string result = DecodeBase64ToImage(item, imageName);
  2588. if (!string.IsNullOrEmpty(result))
  2589. {
  2590. var pic = new Grp_VisaProgressCustomerPicture
  2591. {
  2592. CreateUserId = dto.CreateUserId,
  2593. PicName = imageName,
  2594. PicPath = result,
  2595. VisaProgressCustomerId = dto.visaProgressCustomerId
  2596. };
  2597. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2598. if (insertResult > 0)
  2599. {
  2600. sucNum++;
  2601. }
  2602. }
  2603. }
  2604. }
  2605. catch (Exception ex)
  2606. {
  2607. return Ok(JsonView(false, ex.Message));
  2608. }
  2609. string msg = string.Format(@"成功上传{0}张", sucNum);
  2610. return Ok(JsonView(true, msg));
  2611. }
  2612. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2613. {
  2614. string filename = "";//声明一个string类型的相对路径
  2615. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2616. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2617. try//会有异常抛出,try,catch一下
  2618. {
  2619. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2620. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2621. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2622. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2623. //文件名称
  2624. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2625. //上传的文件的路径
  2626. string filePath = "";
  2627. if (!Directory.Exists(fileDir))
  2628. {
  2629. Directory.CreateDirectory(fileDir);
  2630. }
  2631. //上传的文件的路径
  2632. filePath = fileDir + filename;
  2633. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2634. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2635. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2636. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2637. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2638. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2639. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2640. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2641. bitmap.Dispose();
  2642. }
  2643. catch (Exception e)
  2644. {
  2645. string massage = e.Message;
  2646. Logs("IOS图片上传Error:" + massage);
  2647. //filename = e.Message;
  2648. }
  2649. return filename;//返回相对路径
  2650. }
  2651. /// <summary>
  2652. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2653. /// </summary>
  2654. /// <param name="dto"></param>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2659. {
  2660. if (dto == null)
  2661. {
  2662. return Ok(JsonView(false, "请求错误:"));
  2663. }
  2664. string msg = "参数错误";
  2665. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2666. {
  2667. try
  2668. {
  2669. //_delegationVisaRep.BeginTran();
  2670. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2671. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2672. .Where(s => s.Id == dto.visaProgressCustomerId)
  2673. .ExecuteCommandAsync();
  2674. if (updCount > 0 && dto.publishCode == 1)
  2675. {
  2676. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2677. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2678. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2679. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2680. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2681. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2682. if (groupData == null)
  2683. {
  2684. _delegationVisaRep.RollbackTran();
  2685. }
  2686. string title = string.Format(@"[签证进度更新]");
  2687. string content = string.Format(@"测试文本");
  2688. bool rst = await _message.AddMsg(new MessageDto()
  2689. {
  2690. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2691. IssuerId = dto.publisher,
  2692. Title = title,
  2693. Content = content,
  2694. ReleaseTime = DateTime.Now,
  2695. UIdList = new List<int> {
  2696. 234
  2697. }
  2698. });
  2699. if (rst)
  2700. {
  2701. return Ok(JsonView(true, "发送通知成功"));
  2702. }
  2703. }
  2704. //_delegationVisaRep.CommitTran();
  2705. }
  2706. catch (Exception)
  2707. {
  2708. //_delegationVisaRep.RollbackTran();
  2709. }
  2710. }
  2711. return Ok(JsonView(true, msg));
  2712. }
  2713. #endregion
  2714. #region 团组任务分配
  2715. /// <summary>
  2716. /// 团组任务分配初始化
  2717. /// </summary>
  2718. /// <returns></returns>
  2719. [HttpPost]
  2720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2721. public async Task<IActionResult> GetTaskAssignmen()
  2722. {
  2723. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2724. if (groupData.Code != 0)
  2725. {
  2726. return Ok(JsonView(false, groupData.Msg));
  2727. }
  2728. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2729. }
  2730. /// <summary>
  2731. /// 团组任务分配查询
  2732. /// </summary>
  2733. /// <param name="dto"></param>
  2734. /// <returns></returns>
  2735. [HttpPost]
  2736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2737. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2738. {
  2739. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2740. if (groupData.Code != 0)
  2741. {
  2742. return Ok(JsonView(false, groupData.Msg));
  2743. }
  2744. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2745. }
  2746. /// <summary>
  2747. /// 团组任务分配操作
  2748. /// </summary>
  2749. /// <param name="dto"></param>
  2750. /// <returns></returns>
  2751. [HttpPost]
  2752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2753. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2754. {
  2755. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2756. if (groupData.Code != 0)
  2757. {
  2758. return Ok(JsonView(false, groupData.Msg));
  2759. }
  2760. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2761. }
  2762. /// <summary>
  2763. /// 团组任务分配
  2764. /// 批量分配
  2765. /// 查询团组
  2766. /// </summary>
  2767. /// <param name="dto"></param>
  2768. /// <returns></returns>
  2769. [HttpPost]
  2770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2771. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2772. {
  2773. //参数验证
  2774. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2775. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2776. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2777. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2778. }
  2779. /// <summary>
  2780. /// 团组任务分配
  2781. /// 批量分配
  2782. /// </summary>
  2783. /// <param name="dto"></param>
  2784. /// <returns></returns>
  2785. [HttpPost]
  2786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2787. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2788. {
  2789. //参数验证
  2790. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2791. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2792. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2793. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2794. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2795. }
  2796. #endregion
  2797. #region 团组费用审核
  2798. /// <summary>
  2799. /// 费用审核
  2800. /// 团组列表 Page
  2801. /// </summary>
  2802. /// <param name="_dto">团组列表请求dto</param>
  2803. /// <returns></returns>
  2804. [HttpPost]
  2805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2806. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2807. {
  2808. #region 参数验证
  2809. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2810. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2811. #region 页面操作权限验证
  2812. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2813. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2814. #endregion
  2815. #endregion
  2816. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2817. {
  2818. string sqlWhere = string.Empty;
  2819. if (_dto.IsSure == 0) //未完成
  2820. {
  2821. sqlWhere += string.Format(@" And IsSure = 0");
  2822. }
  2823. else if (_dto.IsSure == 1) //已完成
  2824. {
  2825. sqlWhere += string.Format(@" And IsSure = 1");
  2826. }
  2827. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2828. {
  2829. string tj = _dto.SearchCriteria;
  2830. 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}%')",
  2831. tj, tj, tj, tj, tj);
  2832. }
  2833. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2834. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2835. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2836. From (
  2837. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2838. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2839. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2840. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2841. From Grp_DelegationInfo gdi
  2842. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2843. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2844. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2845. Where gdi.IsDel = 0 {0}
  2846. ) temp ", sqlWhere);
  2847. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2848. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2849. var _view = new
  2850. {
  2851. PageFuncAuth = pageFunAuthView,
  2852. Data = _DelegationList
  2853. };
  2854. return Ok(JsonView(true, "查询成功!", _view, total));
  2855. }
  2856. else
  2857. {
  2858. return Ok(JsonView(false, "查询失败"));
  2859. }
  2860. }
  2861. /// <summary>
  2862. /// 获取团组费用审核
  2863. /// </summary>
  2864. /// <param name="_dto"></param>
  2865. /// <returns></returns>
  2866. [HttpPost]
  2867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2868. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2869. {
  2870. try
  2871. {
  2872. #region 参数验证
  2873. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2874. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2875. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2876. #region 页面操作权限验证
  2877. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2878. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2879. #endregion
  2880. #endregion
  2881. var _view = new Grp_CreditCardPaymentView();
  2882. var clientNameList = GetSimplClientList(_dto.DiId);
  2883. #region 费用清单
  2884. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2885. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2886. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2887. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2888. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2889. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2890. /*
  2891. * 76://酒店预订
  2892. */
  2893. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2894. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2895. /*
  2896. * 79://车/导游地接
  2897. */
  2898. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2899. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2900. /*
  2901. * 80: //签证
  2902. */
  2903. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2904. /*
  2905. *81: //邀请/公务活动
  2906. */
  2907. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2908. /*
  2909. * 82: //团组客户保险
  2910. */
  2911. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2912. /*
  2913. * Lable = 85 机票预订
  2914. */
  2915. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2916. /*
  2917. * 85 机票预定
  2918. */
  2919. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2920. /*
  2921. * 98 其他款项
  2922. */
  2923. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2924. /*
  2925. * 285:收款退还
  2926. */
  2927. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2928. /*
  2929. * 1015: //超支费用
  2930. */
  2931. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2932. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2933. /*
  2934. * 币种信息
  2935. */
  2936. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2937. /*
  2938. * 车/导游地接 费用类型
  2939. */
  2940. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2941. /*
  2942. * 车/导游地接 费用类型
  2943. */
  2944. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2945. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2946. /*
  2947. * 用户信息
  2948. */
  2949. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2950. /*
  2951. * 费用模块
  2952. */
  2953. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2954. string priceModule = string.Empty;
  2955. if (sdPriceName != null)
  2956. {
  2957. priceModule = sdPriceName.Name;
  2958. }
  2959. /*
  2960. * 成本信息
  2961. */
  2962. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2963. decimal _groupRate = 0.0000M;
  2964. string _groupCurrencyCode = "-";
  2965. if (groupCost != null)
  2966. {
  2967. _groupRate = groupCost.Rate;
  2968. if (int.TryParse(groupCost.Currency, out int _currency))
  2969. {
  2970. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2971. }
  2972. else _groupCurrencyCode = groupCost.Currency;
  2973. }
  2974. string costContentSql = $"Select * From Grp_GroupCost";
  2975. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2976. //处理日期为空的天数
  2977. for (int i = 0; i < groupCostDetails.Count; i++)
  2978. if (i != 0)
  2979. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2980. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2981. /*
  2982. * 处理详情数据
  2983. */
  2984. foreach (var entity in entityList)
  2985. {
  2986. var _detail = new Grp_CreditCardPaymentDetailView
  2987. {
  2988. Id = entity.Id,
  2989. PriceName = priceModule,
  2990. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2991. };
  2992. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2993. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2994. //处理金额
  2995. if (entity.CTable == 1015)
  2996. {
  2997. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2998. if (czInfo != null)
  2999. {
  3000. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3001. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3002. }
  3003. }
  3004. /*
  3005. * 应付款金额
  3006. */
  3007. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3008. string PaymentCurrency_WaitPay = "Unknown";
  3009. string hotelCurrncyCode = "Unknown";
  3010. string hotelCurrncyName = "Unknown";
  3011. if (sdPaymentCurrency_WaitPay != null)
  3012. {
  3013. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3014. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3015. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3016. if (hotelCurrncyCode.Equals("CNY"))
  3017. {
  3018. entity.DayRate = 1.0000M;
  3019. }
  3020. }
  3021. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3022. /*
  3023. * 此次付款金额
  3024. */
  3025. decimal CurrPayStr = 0.00M,
  3026. OriginalCurrPay = 0.00M;
  3027. if (entity.PayPercentage == 0)
  3028. {
  3029. if (entity.PayThenMoney != 0)
  3030. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3031. }
  3032. else
  3033. {
  3034. if (entity.PayMoney != 0)
  3035. {
  3036. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3037. }
  3038. }
  3039. //if (_dto.Label == 79)
  3040. //{
  3041. // string original = string.Empty;
  3042. // if (hotelCurrncyCode.Equals("CNY"))
  3043. // {
  3044. // OriginalCurrPay = CurrPayStr;
  3045. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3046. // }
  3047. // else
  3048. // {
  3049. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3050. // //760 EUR(7600.00 CNY)
  3051. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3052. // }
  3053. //}
  3054. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3055. string original = string.Empty;
  3056. if (hotelCurrncyCode.Equals("CNY"))
  3057. {
  3058. OriginalCurrPay = CurrPayStr;
  3059. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3060. }
  3061. else
  3062. {
  3063. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3064. //760 EUR(7600.00 CNY)
  3065. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3066. }
  3067. /*
  3068. * 剩余尾款
  3069. */
  3070. decimal BalanceStr = 0;
  3071. if (CurrPayStr != 0)
  3072. {
  3073. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3074. BalanceStr = 0;
  3075. else
  3076. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3077. }
  3078. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3079. /*
  3080. * Bus名称
  3081. */
  3082. _detail.BusName = "待增加";
  3083. /*
  3084. *费用所属
  3085. */
  3086. switch (entity.CTable)
  3087. {
  3088. case 76://酒店预订
  3089. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3090. if (hotelReservations != null)
  3091. {
  3092. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3093. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3094. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3095. string roomFeeStr = "", roomFeestr1 = "";
  3096. //是否比较房型价格
  3097. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3098. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3099. roomFeeStr += $"<br/>";
  3100. var roomTotal = 0.00M;
  3101. if (hotelReservations.SingleRoomPrice > 0)
  3102. {
  3103. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3104. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3105. //__isSingle = true;
  3106. roomTotal += fee;
  3107. }
  3108. if (hotelReservations.DoubleRoomPrice > 0)
  3109. {
  3110. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3111. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3112. // __isDouble = true;
  3113. roomTotal += fee;
  3114. }
  3115. if (hotelReservations.SuiteRoomPrice > 0)
  3116. {
  3117. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3118. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3119. //__isSuite = true;
  3120. roomTotal += fee;
  3121. }
  3122. if (hotelReservations.OtherRoomPrice > 0)
  3123. {
  3124. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3125. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3126. //__isOther = true;
  3127. roomTotal += fee;
  3128. }
  3129. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3130. else roomFeeStr += " 0.00 * 0";
  3131. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3132. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3133. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3134. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3135. /*
  3136. * 费用类型
  3137. * 1:房费
  3138. * 2:早餐
  3139. * 3:地税
  3140. * 4:城市税
  3141. * </summary>
  3142. */
  3143. //地税
  3144. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3145. if (governmentRentData != null)
  3146. {
  3147. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3148. governmentRentFee = governmentRentData.Price;
  3149. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3150. if (governmentRentCurrData != null)
  3151. {
  3152. governmentRentCode = governmentRentCurrData.Name;
  3153. governmentRentName = $"({governmentRentCurrData.Remark})";
  3154. }
  3155. }
  3156. //城市税
  3157. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3158. if (cityTaxData != null)
  3159. {
  3160. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3161. cityTaxFee = cityTaxData.Price;
  3162. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3163. if (cityTaxCurrData != null)
  3164. {
  3165. cityTaxCode = cityTaxCurrData.Name;
  3166. cityTaxName = $"({cityTaxCurrData.Remark})";
  3167. }
  3168. }
  3169. //酒店早餐
  3170. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3171. if (breakfastData != null)
  3172. {
  3173. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3174. breakfastFee = breakfastData.Price;
  3175. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3176. if (breakfastCurrData != null)
  3177. {
  3178. breakfastCode = breakfastCurrData.Name;
  3179. breakfastName = $"({breakfastCurrData.Remark})";
  3180. }
  3181. }
  3182. //房间费用
  3183. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3184. if (roomData != null)
  3185. {
  3186. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3187. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3188. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3189. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3190. roomFee = roomData.Price;
  3191. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3192. if (roomCurrData != null)
  3193. {
  3194. roomCode = roomCurrData.Name;
  3195. roomName = $"({roomCurrData.Remark})";
  3196. }
  3197. }
  3198. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3199. string hotelCostStr = "";
  3200. decimal hotelCsotTotal = 0.00M;
  3201. if (groupCost != null)
  3202. {
  3203. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3204. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3205. }
  3206. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3207. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3208. string hotelCost_day = "";
  3209. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3210. foreach (var item in hotelCostDetails1)
  3211. {
  3212. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3213. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3214. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3215. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3216. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3217. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3218. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3219. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3220. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3221. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3222. hotelCost_day += @$"<br/>";
  3223. }
  3224. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3225. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3226. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3227. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3228. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3229. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3230. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3231. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3232. $"房间说明: {hotelReservations.Remark} <br/>" +
  3233. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3234. $"{hotelBreakfastStr}" +
  3235. $"{hotelGovernmentRentStr}" +
  3236. $"{hotelCityTaxStr}";
  3237. _detail.PriceNameContent = hotelReservations.HotelName;
  3238. }
  3239. break;
  3240. case 79://车/导游地接
  3241. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3242. if (touristGuideGroundReservations != null)
  3243. {
  3244. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3245. {
  3246. _detail.BusName = touristGuideGroundReservations.BusName;
  3247. }
  3248. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3249. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3250. //if (isInt)
  3251. //{
  3252. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3253. // if (cityInfo != null)
  3254. // {
  3255. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3256. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3257. // if (carFeeItem != null)
  3258. // {
  3259. // nameContent += $@"({carFeeItem.Name})";
  3260. // }
  3261. // _detail.PriceNameContent = nameContent;
  3262. // }
  3263. //}
  3264. //else
  3265. //{
  3266. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3267. //}
  3268. var touristGuideGroundReservationsContents =
  3269. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3270. var opContent_sb = new StringBuilder();
  3271. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3272. opContent_sb.AppendLine(contetTitle);
  3273. foreach (var item in touristGuideGroundReservationsContents)
  3274. {
  3275. string typeName = "Unknown";
  3276. string carCurrencyCode = "Unknown";
  3277. string carCurrencyName = "Unknown";
  3278. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3279. if (carTypeData != null) typeName = carTypeData.Name;
  3280. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3281. if (currencyData != null)
  3282. {
  3283. carCurrencyCode = currencyData.Name;
  3284. carCurrencyName = currencyData.Remark;
  3285. }
  3286. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3287. bool IsCurrencyAgreement = false;
  3288. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3289. string opCostStr = string.Empty;
  3290. decimal opCostTypePrice = 0.00M;
  3291. #region 处理成本各项费用
  3292. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3293. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3294. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3295. costOPFeeCNY = 0.00M, //团组成本 op费用
  3296. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3297. if (opCost.Count > 0)
  3298. {
  3299. switch (item.SId)
  3300. {
  3301. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3302. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3303. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3304. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3305. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3306. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3307. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3308. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3309. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3310. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3311. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3312. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3313. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3314. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3315. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3316. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3317. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3318. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3319. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3320. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3321. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3322. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3323. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3324. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3325. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3326. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3327. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3328. }
  3329. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3330. costOPFeeCNY = opCostTypePrice * _groupRate;
  3331. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3332. }
  3333. #endregion
  3334. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3335. aduitOPFeeCNY = item.Price * entity.DayRate;
  3336. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3337. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3338. $"{opTypeStr} {opCostStr}<br/>" +
  3339. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3340. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3341. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3342. {
  3343. if (IsCurrencyAgreement)
  3344. {
  3345. if (item.Price > opCostTypePrice)
  3346. {
  3347. opContent_sb.Append("<span style='color:red;'>");
  3348. opContent_sb.Append(opContent);
  3349. opContent_sb.Append("</span>");
  3350. opContent_sb.AppendLine();
  3351. }
  3352. else
  3353. {
  3354. opContent_sb.Append(opContent);
  3355. opContent_sb.AppendLine();
  3356. }
  3357. }
  3358. else
  3359. {
  3360. //验证是否超成本 按付款比例计算
  3361. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3362. {
  3363. opContent_sb.Append("<span style='color:red;'>");
  3364. opContent_sb.Append(opContent);
  3365. opContent_sb.Append("</span>");
  3366. opContent_sb.AppendLine();
  3367. }
  3368. else
  3369. {
  3370. opContent_sb.Append(opContent);
  3371. opContent_sb.AppendLine();
  3372. }
  3373. }
  3374. }
  3375. else
  3376. {
  3377. opContent_sb.Append(opContent);
  3378. opContent_sb.AppendLine();
  3379. }
  3380. }
  3381. _detail.PriceMsgContent = opContent_sb.ToString();
  3382. }
  3383. break;
  3384. case 80: //签证
  3385. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3386. if (visaInfo != null)
  3387. {
  3388. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3389. _detail.PriceNameContent = visaInfo.VisaDescription;
  3390. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3391. }
  3392. break;
  3393. case 81: //邀请/公务活动
  3394. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3395. if (_ioa != null)
  3396. {
  3397. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3398. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3399. sendCurrName = "Unknown", //快递费用币种 Name
  3400. sendCurrCode = "Unknown", //快递费用币种 Code
  3401. eventsCurrName = "Unknown", //公务活动费币种 Name
  3402. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3403. translateCurrName = "Unknown", //公务翻译费 Name
  3404. translateCurrCode = "Unknown"; //公务翻译费 Code
  3405. #region 处理费用币种
  3406. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3407. if (inviteCurrData != null)
  3408. {
  3409. inviteCurrName = inviteCurrData.Remark;
  3410. inviteCurrCode = inviteCurrData.Name;
  3411. }
  3412. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3413. if (sendCurrData != null)
  3414. {
  3415. sendCurrName = sendCurrData.Remark;
  3416. sendCurrCode = sendCurrData.Name;
  3417. }
  3418. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3419. if (eventsCurrData != null)
  3420. {
  3421. eventsCurrName = eventsCurrData.Remark;
  3422. eventsCurrCode = eventsCurrData.Name;
  3423. }
  3424. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3425. if (translateCurrData != null)
  3426. {
  3427. translateCurrName = translateCurrData.Remark;
  3428. translateCurrCode = translateCurrData.Name;
  3429. }
  3430. #endregion
  3431. _detail.PriceNameContent = _ioa.InviterArea;
  3432. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3433. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3434. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3435. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3436. $@"备注:" + _ioa.Remark + "<br/>";
  3437. }
  3438. break;
  3439. case 82: //团组客户保险
  3440. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3441. if (customers != null)
  3442. {
  3443. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3444. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3445. }
  3446. break;
  3447. case 85: //机票预订
  3448. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3449. if (jpRes != null)
  3450. {
  3451. string FlightsDescription = jpRes.FlightsDescription;
  3452. string PriceDescription = jpRes.PriceDescription;
  3453. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3454. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3455. }
  3456. break;
  3457. case 98://其他款项
  3458. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3459. if (gdpRes != null)
  3460. {
  3461. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3462. _detail.PriceNameContent = gdpRes.PriceName;
  3463. }
  3464. break;
  3465. case 285://收款退还
  3466. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3467. if (refundAndOtherMoney != null)
  3468. {
  3469. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3470. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3471. }
  3472. break;
  3473. case 751://酒店早餐
  3474. break;
  3475. case 1015://超支费用
  3476. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3477. if (groupExtraCost != null)
  3478. {
  3479. _detail.PriceNameContent = groupExtraCost.PriceName;
  3480. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3481. }
  3482. break;
  3483. default:
  3484. break;
  3485. }
  3486. /*
  3487. * 申请人
  3488. */
  3489. string operatorName = " - ";
  3490. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3491. if (_opUser != null)
  3492. {
  3493. operatorName = _opUser.CnName;
  3494. }
  3495. _detail.OperatorName = operatorName;
  3496. /*
  3497. * 审核人
  3498. */
  3499. string auditOperatorName = " - ";
  3500. if (entity.IsAuditGM != 0)
  3501. {
  3502. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3503. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3504. else
  3505. {
  3506. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3507. if (_adUser != null)
  3508. {
  3509. auditOperatorName = _adUser.CnName;
  3510. }
  3511. }
  3512. }
  3513. _detail.AuditOperatorName = auditOperatorName;
  3514. /*
  3515. * 超预算比例
  3516. */
  3517. string overBudgetStr = "";
  3518. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3519. else if (entity.ExceedBudget == 0)
  3520. {
  3521. if (entity.CTable == 76 || entity.CTable == 79)
  3522. {
  3523. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3524. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3525. }
  3526. else
  3527. {
  3528. overBudgetStr = "未超预算";
  3529. }
  3530. }
  3531. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3532. _detail.OverBudget = overBudgetStr;
  3533. decimal auditFee = 0.00M; //已审核金额 人名币
  3534. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3535. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3536. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3537. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3538. {
  3539. auditedFeeOriginal = entity.PayMoney;
  3540. auditFee = CurrPayStr;
  3541. }
  3542. else if (entity.IsAuditGM == 0)
  3543. {
  3544. unAuditFeeCNY = CurrPayStr;
  3545. unAuditFeeOriginal = OriginalCurrPay;
  3546. OriginalCurrPay = 0.00M;
  3547. }
  3548. /*
  3549. * 费用总计
  3550. */
  3551. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3552. {
  3553. CurrencyId = entity.PaymentCurrency,
  3554. CurrencyName = PaymentCurrency_WaitPay,
  3555. AmountPayable = entity.PayMoney,
  3556. ThisPayment = OriginalCurrPay,
  3557. BalancePayment = BalanceStr,
  3558. AuditedFunds = auditFee,
  3559. AuditedFundsOriginal = auditedFeeOriginal,
  3560. UnAuditFundsCNY = unAuditFeeCNY,
  3561. UnAuditFundsOriginal = unAuditFeeOriginal
  3562. });
  3563. _detail.IsAuditGM = entity.IsAuditGM;
  3564. detailList.Add(_detail);
  3565. }
  3566. #endregion
  3567. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3568. /*
  3569. * 下方描述处理
  3570. */
  3571. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3572. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3573. if (ccpCurrencyPrice != null)
  3574. {
  3575. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3576. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3577. }
  3578. else
  3579. {
  3580. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3581. }
  3582. string amountPayableStr = string.Format(@"应付款总金额: ");
  3583. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3584. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3585. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3586. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3587. foreach (var item in nonDuplicat)
  3588. {
  3589. var currencyName = item.CurrencyName;
  3590. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3591. if (strs.Count > 0)
  3592. {
  3593. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3594. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3595. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3596. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3597. //单独处理此次付款金额
  3598. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3599. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3600. //单独处理已审核费用
  3601. //if (item.CurrencyId == 836) //人民币
  3602. //{
  3603. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3604. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3605. //}
  3606. //else
  3607. //{
  3608. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3609. //}
  3610. if (currencyName.Equals("CNY"))
  3611. {
  3612. //已审核费用
  3613. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3614. //未审核费用
  3615. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3616. }
  3617. else
  3618. {
  3619. //已审核费用
  3620. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  3621. //未审核费用
  3622. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  3623. }
  3624. }
  3625. }
  3626. _view.TotalStr1 = amountPayableStr[..^1];
  3627. _view.TotalStr2 = thisPaymentStr[..^1];
  3628. _view.TotalStr3 = balancePaymentStr[..^1];
  3629. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3630. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3631. var _view1 = new
  3632. {
  3633. PageFuncAuth = pageFunAuthView,
  3634. Data = _view
  3635. };
  3636. return Ok(JsonView(_view1));
  3637. }
  3638. catch (Exception ex)
  3639. {
  3640. return Ok(JsonView(false, ex.Message));
  3641. }
  3642. }
  3643. /// <summary>
  3644. /// 费用审核
  3645. /// 修改团组费用审核状态
  3646. /// </summary>
  3647. /// <param name="_dto">参数Json字符串</param>
  3648. /// <returns></returns>
  3649. [HttpPost]
  3650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3651. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3652. {
  3653. #region 参数验证
  3654. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3655. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3656. #endregion
  3657. #region 页面操作权限验证
  3658. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3659. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3660. #endregion
  3661. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3662. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3663. DateTime dtNow = DateTime.Now;
  3664. _groupRepository.BeginTran();
  3665. int rst = 0;
  3666. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3667. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3668. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3669. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3670. var msgDatas = new List<dynamic>();
  3671. var dic_ccp_user = new Dictionary<int, int>() { };
  3672. foreach (var item in idList)
  3673. {
  3674. int CreditId = int.Parse(item);
  3675. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3676. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3677. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3678. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3679. .Where(s => s.Id == CreditId)
  3680. .ExecuteCommandAsync();
  3681. if (result < 1)
  3682. {
  3683. rst = -1;
  3684. _groupRepository.RollbackTran();
  3685. return Ok(JsonView(false, "操作失败并回滚!"));
  3686. }
  3687. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3688. if (creditData != null)
  3689. {
  3690. #region 应用通知配置
  3691. try
  3692. {
  3693. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3694. }
  3695. catch (Exception ex)
  3696. {
  3697. }
  3698. #endregion
  3699. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3700. string groupNameStr = string.Empty;
  3701. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3702. if (groupData != null) groupNameStr = groupData.TeamName;
  3703. string creditTypeStr = string.Empty;
  3704. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3705. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3706. string creditCurrency = string.Empty;
  3707. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3708. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3709. if (creditCurrency.Equals("CNY"))
  3710. {
  3711. creditData.DayRate = 1.0000M;
  3712. }
  3713. if (creditData.PayPercentage == 0.00M)
  3714. {
  3715. creditData.PayPercentage = 100M;
  3716. }
  3717. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3718. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3719. string msgContent = "";
  3720. if (creditCurrency.Equals("CNY"))
  3721. {
  3722. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3723. }
  3724. else
  3725. {
  3726. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3727. }
  3728. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3729. }
  3730. }
  3731. if (rst == 0)
  3732. {
  3733. _groupRepository.CommitTran();
  3734. foreach (var item in msgDatas)
  3735. {
  3736. //发送消息
  3737. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3738. }
  3739. #region 应用推送
  3740. try
  3741. {
  3742. foreach (var ccpId in dic_ccp_user.Keys)
  3743. {
  3744. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3745. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3746. }
  3747. }
  3748. catch (Exception)
  3749. {
  3750. }
  3751. #endregion
  3752. return Ok(JsonView(true, "操作成功!"));
  3753. }
  3754. return Ok(JsonView(false, "操作失败!"));
  3755. }
  3756. #endregion
  3757. #region 机票费用录入
  3758. /// <summary>
  3759. /// 机票录入当前登录人可操作团组
  3760. /// </summary>
  3761. /// <param name="dto"></param>
  3762. /// <returns></returns>
  3763. [HttpPost]
  3764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3765. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3766. {
  3767. try
  3768. {
  3769. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3770. if (groupData.Code != 0)
  3771. {
  3772. return Ok(JsonView(false, groupData.Msg));
  3773. }
  3774. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3775. }
  3776. catch (Exception ex)
  3777. {
  3778. return Ok(JsonView(false, ex.Message));
  3779. }
  3780. }
  3781. /// <summary>
  3782. /// 机票费用录入列表
  3783. /// </summary>
  3784. /// <param name="dto"></param>
  3785. /// <returns></returns>
  3786. [HttpPost]
  3787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3788. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3789. {
  3790. try
  3791. {
  3792. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3793. if (groupData.Code != 0)
  3794. {
  3795. return Ok(JsonView(false, groupData.Msg));
  3796. }
  3797. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3798. }
  3799. catch (Exception ex)
  3800. {
  3801. return Ok(JsonView(false, ex.Message));
  3802. throw;
  3803. }
  3804. }
  3805. /// <summary>
  3806. /// 根据id查询费用录入信息
  3807. /// </summary>
  3808. /// <param name="dto"></param>
  3809. /// <returns></returns>
  3810. [HttpPost]
  3811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3812. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3813. {
  3814. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3815. if (groupData.Code != 0)
  3816. {
  3817. return Ok(JsonView(false, groupData.Msg));
  3818. }
  3819. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3820. }
  3821. /// <summary>
  3822. /// 机票费用录入操作(Status:1.新增,2.修改)
  3823. /// </summary>
  3824. /// <param name="dto"></param>
  3825. /// <returns></returns>
  3826. [HttpPost]
  3827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3828. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3829. {
  3830. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3831. if (groupData.Code != 0)
  3832. {
  3833. return Ok(JsonView(false, groupData.Msg));
  3834. }
  3835. #region 应用推送
  3836. try
  3837. {
  3838. var diId = dto.AirTicketResOpData.DiId;
  3839. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3840. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3841. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3842. //自动审核
  3843. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3844. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3845. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3846. $"GroupId:{diId};airId:{dataId};",
  3847. status,
  3848. auditMsg);
  3849. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3850. //2024-10-21 新增LZ UID
  3851. var userIds = new List<int>() { 21 };
  3852. string title = $"系统通知";
  3853. string content = "";
  3854. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3855. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3856. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3857. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3858. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3859. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3860. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3861. }
  3862. catch (Exception ex)
  3863. {
  3864. }
  3865. #endregion
  3866. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3867. }
  3868. /// <summary>
  3869. /// 机票费用自动审核 AI识别方式
  3870. /// </summary>
  3871. /// <returns></returns>
  3872. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3873. {
  3874. var ecoTypeIds = new List<int>() {
  3875. 459, //超经舱
  3876. 460, //经济舱
  3877. 1430, //公务舱(实际经济舱)
  3878. 1432, //头等舱(实际经济舱)
  3879. };
  3880. var bizTypeIds = new List<int>() {
  3881. 457, //头等舱
  3882. 458, //公务舱
  3883. 1431, //头等舱(实际公务舱)
  3884. };
  3885. var auditFeeTypeIds = new List<int>() { };
  3886. auditFeeTypeIds.AddRange(ecoTypeIds);
  3887. auditFeeTypeIds.AddRange(bizTypeIds);
  3888. int currModule = 85;
  3889. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3890. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3891. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3892. .Select((x, y) => new
  3893. {
  3894. x.Id,
  3895. CcpId = y.Id,
  3896. x.FlightsDate,
  3897. x.PrePrice,
  3898. x.CType,
  3899. x.ClientNum,
  3900. x.DIId
  3901. })
  3902. .FirstAsync();
  3903. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3904. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3905. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3906. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3907. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3908. var groupCostContents = await _sqlSugar
  3909. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3910. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3911. .ToListAsync();
  3912. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3913. //处理 成本详细信息日期为空 填装费用信息
  3914. var airFeeLabel = new StringBuilder();
  3915. airFeeLabel.AppendLine("费用成本:");
  3916. for (int i = 0; i < groupCostContents.Count; i++)
  3917. {
  3918. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3919. {
  3920. int index = i - 1;
  3921. if (index >= 0)
  3922. {
  3923. groupCostContents[i].Date = groupCostContents[index].Date;
  3924. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3925. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3926. }
  3927. }
  3928. else
  3929. {
  3930. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3931. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3932. }
  3933. var item = groupCostContents[i];
  3934. airFeeLabel.AppendLine($"{item.Date}");
  3935. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3936. }
  3937. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3938. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3939. //访问Kimi AI 返回价格结果
  3940. var msgs = new List<SeedMessages>()
  3941. {
  3942. new ()
  3943. {
  3944. Role = KimiRole.user,
  3945. Content = airFeeLabel.ToString()
  3946. }
  3947. };
  3948. var client = new KiMiApiClient();
  3949. var kimiApiResult = await client.SeedMessage(msgs);
  3950. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3951. string clients = kimiApiResult_JObject["content"].ToString();
  3952. decimal ecoPri_kimiAI = 0.00M,
  3953. bizPri_kimiAI = 0.00M;
  3954. //单个价格: 经济舱价格
  3955. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3956. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3957. if (clients.Contains('/'))
  3958. {
  3959. var priArray = clients.Split('/');
  3960. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3961. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3962. }
  3963. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3964. var isAutoAudit = false;
  3965. //价格验证处理
  3966. //经济舱
  3967. if (ecoTypeIds.Contains(airInfo.CType))
  3968. {
  3969. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3970. }
  3971. //公务舱
  3972. else if (bizTypeIds.Contains(airInfo.CType))
  3973. {
  3974. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3975. }
  3976. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3977. //是否执行自动审核
  3978. if (isAutoAudit)
  3979. {
  3980. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3981. .SetColumns(x => x.IsAuditGM == 3)
  3982. .SetColumns(x => x.AuditGMOperate == 4)
  3983. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3984. .Where(x => x.Id == airInfo.CcpId)
  3985. .ExecuteCommandAsync();
  3986. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3987. }
  3988. return (false, "当前费用超过成本费用,不可自动审核!");
  3989. }
  3990. /// <summary>
  3991. /// 机票费用录入
  3992. /// 自动审核测试 - AI 识别
  3993. /// </summary>
  3994. /// <param name="groupId"></param>
  3995. /// <param name="Id"></param>
  3996. /// <returns></returns>
  3997. [HttpPost]
  3998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3999. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4000. {
  4001. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4002. return Ok(JsonView(status, msg));
  4003. }
  4004. /// <summary>
  4005. /// 根据舱位类型查询接团客户名单信息
  4006. /// </summary>
  4007. /// <param name="dto"></param>
  4008. /// <returns></returns>
  4009. [HttpPost]
  4010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4011. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4012. {
  4013. try
  4014. {
  4015. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4016. if (crm_Groups.Count != 0)
  4017. {
  4018. var Customer = new List<dynamic>();
  4019. foreach (var item in crm_Groups)
  4020. {
  4021. var data = new
  4022. {
  4023. item.Id,
  4024. item.Pinyin,
  4025. Name = item.LastName + item.FirstName
  4026. };
  4027. Customer.Add(data);
  4028. }
  4029. return Ok(JsonView(true, "查询成功!", Customer));
  4030. }
  4031. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4032. }
  4033. catch (Exception ex)
  4034. {
  4035. return Ok(JsonView(false, "程序错误!"));
  4036. throw;
  4037. }
  4038. }
  4039. /// <summary>
  4040. /// 根据团号获取客户信息
  4041. /// </summary>
  4042. /// <param name="dto"></param>
  4043. /// <returns></returns>
  4044. [HttpPost]
  4045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4046. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4047. {
  4048. var jw = JsonView(false);
  4049. if (dto.DIID < 1)
  4050. {
  4051. jw.Msg += "请输入正确的diid";
  4052. return Ok(jw);
  4053. }
  4054. var arr = GetSimplClientList(dto.DIID);
  4055. jw = JsonView(true, "获取成功!", arr);
  4056. return Ok(jw);
  4057. }
  4058. private List<SimplClientInfo> GetSimplClientList(int diId)
  4059. {
  4060. 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);
  4061. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4062. foreach (var item in arr)
  4063. {
  4064. EncryptionProcessor.DecryptProperties(item);
  4065. }
  4066. return arr;
  4067. }
  4068. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4069. {
  4070. string result = origin;
  4071. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4072. {
  4073. string[] temparr = origin.Split(',');
  4074. string fistrStr = temparr[0];
  4075. int count = temparr.Length;
  4076. bool success = int.TryParse(fistrStr, out int tempId);
  4077. if (success)
  4078. {
  4079. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4080. if (tempInfo != null)
  4081. {
  4082. if (count > 1)
  4083. {
  4084. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4085. }
  4086. else
  4087. {
  4088. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4089. }
  4090. }
  4091. }
  4092. }
  4093. return result;
  4094. }
  4095. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4096. {
  4097. string result = origin;
  4098. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4099. {
  4100. string[] temparr = origin.Split(',');
  4101. result = "";
  4102. foreach (var item in temparr)
  4103. {
  4104. bool success = int.TryParse(item, out int tempId);
  4105. if (success)
  4106. {
  4107. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4108. if (tempInfo != null)
  4109. {
  4110. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4111. }
  4112. }
  4113. }
  4114. }
  4115. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4116. return result;
  4117. }
  4118. /// <summary>
  4119. /// 机票费用录入,删除
  4120. /// </summary>
  4121. /// <param name="dto"></param>
  4122. /// <returns></returns>
  4123. [HttpPost]
  4124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4125. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4126. {
  4127. try
  4128. {
  4129. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4130. if (res)
  4131. {
  4132. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4133. {
  4134. IsDel = 1,
  4135. DeleteUserId = dto.DeleteUserId,
  4136. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4137. }).ExecuteCommandAsync();
  4138. return Ok(JsonView(true, "删除成功!"));
  4139. }
  4140. return Ok(JsonView(false, "删除失败!"));
  4141. }
  4142. catch (Exception ex)
  4143. {
  4144. return Ok(JsonView(false, "程序错误!"));
  4145. throw;
  4146. }
  4147. }
  4148. /// <summary>
  4149. /// 导出机票录入报表
  4150. /// </summary>
  4151. /// <param name="dto"></param>
  4152. /// <returns></returns>
  4153. [HttpPost]
  4154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4155. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4156. {
  4157. try
  4158. {
  4159. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4160. if (groupData.Code != 0)
  4161. {
  4162. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4163. }
  4164. else
  4165. {
  4166. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4167. if (AirTicketReservations.Count != 0)
  4168. {
  4169. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4170. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4171. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4172. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4173. var designer = new WorkbookDesigner
  4174. {
  4175. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4176. };
  4177. decimal countCost = 0;
  4178. foreach (var item in AirTicketReservations)
  4179. {
  4180. #region 处理客人姓名
  4181. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4182. item.ClientName = clientNames;
  4183. #endregion
  4184. if (item.BankType == "其他")
  4185. {
  4186. item.BankNo = "--";
  4187. }
  4188. else
  4189. {
  4190. if (!string.IsNullOrEmpty(item.BankType))
  4191. {
  4192. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4193. }
  4194. }
  4195. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4196. item.Price = System.Decimal.Round(item.Price, 2);
  4197. countCost += Convert.ToDecimal(item.Price);
  4198. }
  4199. designer.SetDataSource("Export", AirTicketReservations);
  4200. designer.SetDataSource("ExportDiCode", diCode);
  4201. designer.SetDataSource("ExportDiName", diName);
  4202. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4203. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4204. designer.Process();
  4205. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4206. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4207. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4208. return Ok(JsonView(true, "成功", url = rst));
  4209. }
  4210. else
  4211. {
  4212. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4213. }
  4214. }
  4215. }
  4216. catch (Exception ex)
  4217. {
  4218. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4219. throw;
  4220. }
  4221. }
  4222. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4223. /// <summary>
  4224. /// 行程单导出
  4225. /// </summary>
  4226. /// <param name="dto"></param>
  4227. /// <returns></returns>
  4228. [HttpPost]
  4229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4230. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4231. {
  4232. try
  4233. {
  4234. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4235. if (groupData.Code != 0)
  4236. {
  4237. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4238. }
  4239. else
  4240. {
  4241. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4242. if (dto.Language == "CN")
  4243. {
  4244. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4245. var builder = new DocumentBuilder(doc);
  4246. int tableIndex = 0;//表格索引
  4247. //得到文档中的第一个表格
  4248. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4249. foreach (var item in _AirTicketReservations)
  4250. {
  4251. #region 处理固定数据
  4252. string[] FlightsCode = item.FlightsCode.Split('/');
  4253. if (FlightsCode.Length != 0)
  4254. {
  4255. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4256. if (_AirCompany != null)
  4257. {
  4258. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4259. }
  4260. else
  4261. {
  4262. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4263. }
  4264. }
  4265. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4266. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4267. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4268. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4269. string name = "";
  4270. foreach (string clientName in nameArray)
  4271. {
  4272. if (!name.Contains(clientName))
  4273. {
  4274. name += clientName + ",";
  4275. }
  4276. }
  4277. if (!string.IsNullOrWhiteSpace(name))
  4278. {
  4279. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4280. }
  4281. else
  4282. {
  4283. table.Range.Bookmarks["ClientName"].Text = "--";
  4284. }
  4285. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4286. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4287. table.Range.Bookmarks["JointTicket"].Text = "--";
  4288. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4289. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4290. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4291. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4292. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4293. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4294. #endregion
  4295. #region 循环数据处理
  4296. var airs = new List<AirInfo>();
  4297. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4298. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4299. for (int i = 0; i < FlightsCode.Length; i++)
  4300. {
  4301. var air = new AirInfo();
  4302. string[] tempstr = DayArray[i]
  4303. .Replace("\r\n", string.Empty)
  4304. .Replace("\\r\\n", string.Empty)
  4305. .TrimStart().TrimEnd()
  4306. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4307. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4308. string starCity = "";
  4309. if (star_Three != null)
  4310. {
  4311. starCity = star_Three.AirPort;
  4312. }
  4313. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4314. string EndCity = "";
  4315. if (End_Three != null)
  4316. {
  4317. EndCity = End_Three.AirPort;
  4318. }
  4319. air.Destination = starCity + "/" + EndCity;
  4320. air.Flight = FlightsCode[i];
  4321. air.SeatingClass = item.CTypeName;
  4322. string dateTime = tempstr[2];
  4323. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4324. air.FlightDate = DateTemp;
  4325. air.DepartureTime = tempstr[5];
  4326. air.LandingTime = tempstr[6];
  4327. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4328. air.TicketStatus = "--";
  4329. air.Luggage = "--";
  4330. air.DepartureTerminal = "--";
  4331. air.LandingTerminal = "--";
  4332. airs.Add(air);
  4333. }
  4334. int row = 13;
  4335. for (int i = 0; i < airs.Count; i++)
  4336. {
  4337. if (airs.Count > 2)
  4338. {
  4339. for (int j = 0; j < airs.Count - 2; j++)
  4340. {
  4341. var CopyRow = table.Rows[12].Clone(true);
  4342. table.Rows.Add(CopyRow);
  4343. }
  4344. }
  4345. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4346. int index = 0;
  4347. foreach (PropertyInfo property in properties)
  4348. {
  4349. string value = property.GetValue(airs[i]).ToString();
  4350. Cell ishcel0 = table.Rows[row].Cells[index];
  4351. var p = new Paragraph(doc);
  4352. string s = value;
  4353. p.AppendChild(new Run(doc, s));
  4354. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4355. ishcel0.AppendChild(p);
  4356. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4357. index++;
  4358. }
  4359. row++;
  4360. }
  4361. #endregion
  4362. var lastParagraph = new Paragraph(doc);
  4363. //第一个表格末尾加段落
  4364. table.ParentNode.InsertAfter(lastParagraph, table);
  4365. //复制第一个表格
  4366. Table cloneTable = (Table)table.Clone(true);
  4367. //在文档末尾段落后面加入复制的表格
  4368. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4369. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4370. {
  4371. int rownewsIndex = 13;
  4372. for (int i = 0; i < 2; i++)
  4373. {
  4374. var CopyRow = table.Rows[12].Clone(true);
  4375. table.Rows.RemoveAt(13);
  4376. table.Rows.Add(CopyRow);
  4377. rownewsIndex++;
  4378. }
  4379. }
  4380. else
  4381. {
  4382. table.Rows.RemoveAt(12);
  4383. }
  4384. cloneTable.Rows.RemoveAt(12);
  4385. }
  4386. if (_AirTicketReservations.Count != 0)
  4387. {
  4388. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4389. if (FlightsCode.Length != 0)
  4390. {
  4391. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4392. if (_AirCompany != null)
  4393. {
  4394. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4395. }
  4396. else
  4397. {
  4398. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4399. }
  4400. }
  4401. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4402. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4403. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4404. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4405. string name = "";
  4406. foreach (string clientName in nameArray)
  4407. {
  4408. if (!name.Contains(clientName))
  4409. {
  4410. name += clientName + ",";
  4411. }
  4412. }
  4413. if (!string.IsNullOrWhiteSpace(name))
  4414. {
  4415. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4416. }
  4417. else
  4418. {
  4419. table.Range.Bookmarks["ClientName"].Text = "--";
  4420. }
  4421. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4422. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4423. table.Range.Bookmarks["JointTicket"].Text = "--";
  4424. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4425. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4426. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4427. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4428. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4429. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4430. }
  4431. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4432. //保存合并后的文档
  4433. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4434. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4435. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4436. return Ok(JsonView(true, "成功!", rst));
  4437. }
  4438. else
  4439. {
  4440. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4441. var builder = new DocumentBuilder(doc);
  4442. int tableIndex = 0;//表格索引
  4443. //得到文档中的第一个表格
  4444. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4445. var texts = new List<string>();
  4446. foreach (var item in _AirTicketReservations)
  4447. {
  4448. string[] FlightsCode = item.FlightsCode.Split('/');
  4449. if (FlightsCode.Length != 0)
  4450. {
  4451. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4452. if (_AirCompany != null)
  4453. {
  4454. if (!transDic.ContainsKey(_AirCompany.CnName))
  4455. {
  4456. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4457. }
  4458. }
  4459. else
  4460. {
  4461. if (!transDic.ContainsKey("--"))
  4462. {
  4463. transDic.Add("--", "--");
  4464. }
  4465. }
  4466. }
  4467. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4468. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4469. string name = "";
  4470. foreach (string clientName in nameArray)
  4471. {
  4472. name += clientName + ",";
  4473. }
  4474. if (!texts.Contains(name))
  4475. {
  4476. texts.Add(name);
  4477. }
  4478. var airs = new List<AirInfo>();
  4479. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4480. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4481. for (int i = 0; i < FlightsCode.Length; i++)
  4482. {
  4483. var air = new AirInfo();
  4484. string[] tempstr = DayArray[i]
  4485. .Replace("\r\n", string.Empty)
  4486. .Replace("\\r\\n", string.Empty)
  4487. .TrimStart().TrimEnd()
  4488. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4489. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4490. if (star_Three != null)
  4491. {
  4492. if (!transDic.ContainsKey(star_Three.AirPort))
  4493. {
  4494. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4495. }
  4496. }
  4497. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4498. if (End_Three != null)
  4499. {
  4500. if (!transDic.ContainsKey(End_Three.AirPort))
  4501. {
  4502. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4503. }
  4504. }
  4505. if (!texts.Contains(item.CTypeName))
  4506. {
  4507. texts.Add(item.CTypeName);
  4508. }
  4509. }
  4510. }
  4511. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4512. if (transData.Count > 0)
  4513. {
  4514. foreach (TranslateResult item in transData)
  4515. {
  4516. if (!transDic.ContainsKey(item.Query))
  4517. {
  4518. transDic.Add(item.Query, item.Translation);
  4519. }
  4520. }
  4521. }
  4522. foreach (var item in _AirTicketReservations)
  4523. {
  4524. #region 处理固定数据
  4525. string[] FlightsCode = item.FlightsCode.Split('/');
  4526. if (FlightsCode.Length != 0)
  4527. {
  4528. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4529. if (_AirCompany != null)
  4530. {
  4531. string str = "--";
  4532. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4533. if (!string.IsNullOrEmpty(translateResult))
  4534. {
  4535. str = translateResult;
  4536. str = _airTicketResRep.Processing(str);
  4537. }
  4538. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4539. }
  4540. else
  4541. {
  4542. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4543. }
  4544. }
  4545. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4546. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4547. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4548. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4549. string names = "";
  4550. foreach (string clientName in nameArray)
  4551. {
  4552. names += clientName + ",";
  4553. }
  4554. if (!string.IsNullOrWhiteSpace(names))
  4555. {
  4556. string str = "--";
  4557. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4558. if (!string.IsNullOrEmpty(translateResult))
  4559. {
  4560. str = translateResult;
  4561. str = _airTicketResRep.Processing(str);
  4562. }
  4563. table.Range.Bookmarks["ClientName"].Text = str;
  4564. }
  4565. else
  4566. {
  4567. table.Range.Bookmarks["ClientName"].Text = "--";
  4568. }
  4569. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4570. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4571. table.Range.Bookmarks["JointTicket"].Text = "--";
  4572. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4573. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4574. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4575. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4576. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4577. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4578. #endregion
  4579. #region 循环数据处理
  4580. var airs = new List<AirInfo>();
  4581. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4582. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4583. for (int i = 0; i < FlightsCode.Length; i++)
  4584. {
  4585. var air = new AirInfo();
  4586. string[] tempstr = DayArray[i]
  4587. .Replace("\r\n", string.Empty)
  4588. .Replace("\\r\\n", string.Empty)
  4589. .TrimStart().TrimEnd()
  4590. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4591. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4592. string starCity = "";
  4593. if (star_Three != null)
  4594. {
  4595. string str2 = "--";
  4596. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4597. if (!string.IsNullOrEmpty(translateResult2))
  4598. {
  4599. str2 = translateResult2;
  4600. str2 = _airTicketResRep.Processing(str2);
  4601. }
  4602. starCity = str2;
  4603. }
  4604. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4605. string EndCity = "";
  4606. if (End_Three != null)
  4607. {
  4608. string str1 = "--";
  4609. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4610. if (!string.IsNullOrEmpty(translateResult1))
  4611. {
  4612. str1 = translateResult1;
  4613. str1 = _airTicketResRep.Processing(str1);
  4614. }
  4615. EndCity = str1;
  4616. }
  4617. air.Destination = starCity + "/" + EndCity;
  4618. air.Flight = FlightsCode[i];
  4619. string str = "--";
  4620. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4621. if (!string.IsNullOrEmpty(translateResult))
  4622. {
  4623. str = translateResult;
  4624. str = _airTicketResRep.Processing(str);
  4625. }
  4626. air.SeatingClass = str;
  4627. string dateTime = tempstr[2];
  4628. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4629. air.FlightDate = DateTemp;
  4630. air.DepartureTime = tempstr[5];
  4631. air.LandingTime = tempstr[6];
  4632. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4633. air.TicketStatus = "--";
  4634. air.Luggage = "--";
  4635. air.DepartureTerminal = "--";
  4636. air.LandingTerminal = "--";
  4637. airs.Add(air);
  4638. }
  4639. int row = 13;
  4640. for (int i = 0; i < airs.Count; i++)
  4641. {
  4642. if (airs.Count > 2)
  4643. {
  4644. for (int j = 0; j < airs.Count - 2; j++)
  4645. {
  4646. var CopyRow = table.Rows[12].Clone(true);
  4647. table.Rows.Add(CopyRow);
  4648. }
  4649. }
  4650. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4651. int index = 0;
  4652. foreach (PropertyInfo property in properties)
  4653. {
  4654. string value = property.GetValue(airs[i]).ToString();
  4655. Cell ishcel0 = table.Rows[row].Cells[index];
  4656. var p = new Paragraph(doc);
  4657. string s = value;
  4658. p.AppendChild(new Run(doc, s));
  4659. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4660. ishcel0.AppendChild(p);
  4661. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4662. //ishcel0.CellFormat.VerticalAlignment=
  4663. index++;
  4664. }
  4665. row++;
  4666. }
  4667. #endregion
  4668. var lastParagraph = new Paragraph(doc);
  4669. //第一个表格末尾加段落
  4670. table.ParentNode.InsertAfter(lastParagraph, table);
  4671. //复制第一个表格
  4672. Table cloneTable = (Table)table.Clone(true);
  4673. //在文档末尾段落后面加入复制的表格
  4674. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4675. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4676. {
  4677. int rownewsIndex = 13;
  4678. for (int i = 0; i < 2; i++)
  4679. {
  4680. var CopyRow = table.Rows[12].Clone(true);
  4681. table.Rows.RemoveAt(13);
  4682. table.Rows.Add(CopyRow);
  4683. rownewsIndex++;
  4684. }
  4685. }
  4686. else
  4687. {
  4688. table.Rows.RemoveAt(12);
  4689. }
  4690. cloneTable.Rows.RemoveAt(12);
  4691. }
  4692. if (_AirTicketReservations.Count != 0)
  4693. {
  4694. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4695. if (FlightsCode.Length != 0)
  4696. {
  4697. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4698. if (_AirCompany != null)
  4699. {
  4700. string str = "--";
  4701. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4702. if (!string.IsNullOrEmpty(translateResult))
  4703. {
  4704. str = translateResult;
  4705. str = _airTicketResRep.Processing(str);
  4706. }
  4707. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4708. }
  4709. else
  4710. {
  4711. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4712. }
  4713. }
  4714. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4715. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4716. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4717. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4718. string names = "";
  4719. foreach (string clientName in nameArray)
  4720. {
  4721. names += clientName + ",";
  4722. }
  4723. if (!string.IsNullOrWhiteSpace(names))
  4724. {
  4725. string str = "--";
  4726. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4727. if (!string.IsNullOrEmpty(translateResult))
  4728. {
  4729. str = translateResult;
  4730. str = _airTicketResRep.Processing(str);
  4731. }
  4732. table.Range.Bookmarks["ClientName"].Text = str;
  4733. }
  4734. else
  4735. {
  4736. table.Range.Bookmarks["ClientName"].Text = "--";
  4737. }
  4738. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4739. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4740. table.Range.Bookmarks["JointTicket"].Text = "--";
  4741. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4742. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4743. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4744. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4745. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4746. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4747. }
  4748. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4749. //保存合并后的文档
  4750. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4751. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4752. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4753. return Ok(JsonView(true, "成功!", rst));
  4754. }
  4755. }
  4756. }
  4757. catch (Exception ex)
  4758. {
  4759. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4760. throw;
  4761. }
  4762. }
  4763. #endregion
  4764. #region 团组增减款项 --> 其他款项
  4765. /// <summary>
  4766. /// 团组增减款项下拉框绑定
  4767. /// </summary>
  4768. /// <param name="dto"></param>
  4769. /// <returns></returns>
  4770. [HttpPost]
  4771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4772. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4773. {
  4774. #region 参数验证
  4775. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4776. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4777. #endregion
  4778. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4779. }
  4780. /// <summary>
  4781. /// 根据团组Id查询团组增减款项
  4782. /// </summary>
  4783. /// <param name="dto"></param>
  4784. /// <returns></returns>
  4785. [HttpPost]
  4786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4787. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4788. {
  4789. #region 参数验证
  4790. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4791. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4792. #endregion
  4793. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4794. }
  4795. /// <summary>
  4796. /// 团组增减款项操作(Status:1.新增,2.修改)
  4797. /// </summary>
  4798. /// <param name="dto"></param>
  4799. /// <returns></returns>
  4800. [HttpPost]
  4801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4802. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4803. {
  4804. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4805. if (groupData.Code != 200)
  4806. {
  4807. return Ok(JsonView(false, groupData.Msg));
  4808. }
  4809. #region 应用推送
  4810. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4811. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4812. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4813. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4814. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4815. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4816. //自动审核
  4817. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4818. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4819. //2024-10-21 新增LZ UID
  4820. var userIds = new List<int>() { 21 };
  4821. string title = $"系统通知";
  4822. string content = "";
  4823. var diId = dto.DiId;
  4824. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4825. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4826. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4827. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4828. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4829. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4830. #endregion
  4831. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4832. }
  4833. /// <summary>
  4834. ///
  4835. /// 团组增减款项操作 删除
  4836. /// </summary>
  4837. /// <param name="dto"></param>
  4838. /// <returns></returns>
  4839. [HttpPost]
  4840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4841. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4842. {
  4843. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4844. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4845. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4846. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4847. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4848. }
  4849. /// <summary>
  4850. /// 根据团组增减款项Id查询
  4851. /// </summary>
  4852. /// <param name="dto"></param>
  4853. /// <returns></returns>
  4854. [HttpPost]
  4855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4856. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4857. {
  4858. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4859. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4860. }
  4861. /// <summary>
  4862. /// 查询供应商名称
  4863. /// </summary>
  4864. /// <param name="dto"></param>
  4865. /// <returns></returns>
  4866. [HttpPost]
  4867. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4868. {
  4869. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4870. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4871. ?? new List<Grp_DecreasePayments>();
  4872. dbResult = dbResult.Distinct(new
  4873. ProductComparer()).ToList();
  4874. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4875. {
  4876. x.Id,
  4877. x.SupplierAddress,
  4878. x.SupplierArea,
  4879. x.SupplierContact,
  4880. x.SupplierContactNumber,
  4881. x.SupplierEmail,
  4882. x.SupplierName,
  4883. x.SupplierSocialAccount,
  4884. x.SupplierTypeId,
  4885. }).ToList());
  4886. return Ok(jw);
  4887. }
  4888. /// <summary>
  4889. /// 团组增减款项 OTA匹配
  4890. /// </summary>
  4891. /// <param name="file"></param>
  4892. /// <returns></returns>
  4893. [HttpPost]
  4894. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4895. {
  4896. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4897. string fileName = file.FileName;
  4898. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4899. {
  4900. return Ok(JsonView(false, "请上传Excel文件!"));
  4901. }
  4902. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4903. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4904. if (!Directory.Exists(path))
  4905. {
  4906. Directory.CreateDirectory(path);
  4907. }
  4908. var filePath = @$"{path}/{fileName}";
  4909. //保存文件
  4910. using (FileStream fs = System.IO.File.Create(filePath))
  4911. {
  4912. file.CopyTo(fs);
  4913. fs.Flush();
  4914. }
  4915. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4916. //读取ExcelFile
  4917. DataTable dt = ConvertExcelToDataTable(filePath);
  4918. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4919. dt.TableName = "TB";
  4920. //修改table列名
  4921. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4922. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4923. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4924. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4925. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4926. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4927. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4928. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4929. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4930. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4931. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4932. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4933. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4934. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4935. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4936. var otaOrderNos = new List<string>();
  4937. foreach (DataRow item in dt.Rows)
  4938. {
  4939. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4940. }
  4941. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4942. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4943. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4944. .Select((dp, di) => new
  4945. {
  4946. dp.PriceName,
  4947. dp.OTAOrderNo,
  4948. dp.FeeTotal,
  4949. di.TeamName,
  4950. })
  4951. .ToListAsync();
  4952. foreach (DataRow item in dt.Rows)
  4953. {
  4954. var otaOrderNo = item["OTAOrderNo"].ToString();
  4955. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4956. if (oaData == null) continue;
  4957. item["GroupName"] = oaData.TeamName;
  4958. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4959. }
  4960. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  4961. var pairs = new Dictionary<string, object>();
  4962. var datas = new List<DataTable>
  4963. {
  4964. dt
  4965. };
  4966. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4967. return Ok(JsonView(true, "操作成功", new { url }));
  4968. }
  4969. #region
  4970. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  4971. {
  4972. // 创建Workbook对象
  4973. var workbook = new Workbook(excelFilePath);
  4974. // 获取第一个工作表
  4975. var worksheet = workbook.Worksheets[0];
  4976. // 将工作表转换为DataTable
  4977. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4978. return dataTable;
  4979. }
  4980. #endregion
  4981. /// <summary>
  4982. /// 世运会数据
  4983. /// </summary>
  4984. /// <returns></returns>
  4985. [HttpGet]
  4986. public IActionResult WorldGamesData()
  4987. {
  4988. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  4989. var groupMenu = setData.GroupBy(x => x.T0);
  4990. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  4991. foreach (var item in groupMenu)
  4992. {
  4993. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  4994. {
  4995. Data = new SetDataView
  4996. {
  4997. Name = item.Key
  4998. },
  4999. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5000. });
  5001. }
  5002. return Ok(JsonView(true, "success", resultArr));
  5003. }
  5004. #endregion
  5005. #region 文件上传、删除
  5006. /// <summary>
  5007. /// region 文件上传 可以带参数
  5008. /// </summary>
  5009. /// <param name="file"></param>
  5010. /// <returns></returns>
  5011. [HttpPost]
  5012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5013. public async Task<IActionResult> UploadProject(IFormFile file)
  5014. {
  5015. //var TypeName = Request.Headers["TypeName"].ToString();
  5016. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5017. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5018. ////文件名称
  5019. //string projectFileName = file.FileName;
  5020. ////上传的文件的路径
  5021. //string filePath = $"{fileDir}/{projectFileName}";
  5022. //if (TypeName == "A")//A代表团组增减款项
  5023. //{
  5024. // filePath = fileDir + $@"\团组增减款项相关文件";
  5025. // if (!Directory.Exists(filePath))
  5026. // {
  5027. // Directory.CreateDirectory(filePath);
  5028. // }
  5029. // //上传的文件的路径
  5030. // filePath += $@"\{projectFileName}";
  5031. //}
  5032. //else if (TypeName == "B")//B代表商邀相关文件
  5033. //{
  5034. // //上传的文件的路径
  5035. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5036. // if (!Directory.Exists(filePath))
  5037. // {
  5038. // Directory.CreateDirectory(filePath);
  5039. // }
  5040. // //上传的文件的路径
  5041. // filePath = $@"\{projectFileName}";
  5042. //}
  5043. //try
  5044. //{
  5045. // using (FileStream fs = System.IO.File.Create(filePath))
  5046. // {
  5047. // file.CopyTo(fs);
  5048. // fs.Flush();
  5049. // }
  5050. //}
  5051. //catch (Exception ex)
  5052. //{
  5053. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5054. //}
  5055. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5056. try
  5057. {
  5058. var TypeName = Request.Headers["TypeName"].ToString();
  5059. if (file != null)
  5060. {
  5061. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5062. //文件名称
  5063. string projectFileName = file.FileName;
  5064. //上传的文件的路径
  5065. string filePath = $"{fileDir}/{projectFileName}";
  5066. if (TypeName == "A")//A代表团组增减款项
  5067. {
  5068. if (!Directory.Exists(fileDir))
  5069. {
  5070. Directory.CreateDirectory(fileDir);
  5071. }
  5072. //上传的文件的路径
  5073. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5074. }
  5075. else if (TypeName == "B")//B代表商邀相关文件
  5076. {
  5077. if (!Directory.Exists(fileDir))
  5078. {
  5079. Directory.CreateDirectory(fileDir);
  5080. }
  5081. //上传的文件的路径
  5082. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5083. }
  5084. using (FileStream fs = System.IO.File.Create(filePath))
  5085. {
  5086. file.CopyTo(fs);
  5087. fs.Flush();
  5088. }
  5089. return Ok(JsonView(true, "上传成功!", projectFileName));
  5090. }
  5091. else
  5092. {
  5093. return Ok(JsonView(false, "上传失败!"));
  5094. }
  5095. }
  5096. catch (Exception ex)
  5097. {
  5098. return Ok(JsonView(false, ex.Message));
  5099. }
  5100. }
  5101. /// <summary>
  5102. /// 删除指定文件
  5103. /// </summary>
  5104. /// <param name="dto"></param>
  5105. /// <returns></returns>
  5106. [HttpPost]
  5107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5108. public async Task<IActionResult> DelFile(DelFileDto dto)
  5109. {
  5110. try
  5111. {
  5112. var TypeName = Request.Headers["TypeName"].ToString();
  5113. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5114. string filePath = "";
  5115. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5116. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5117. int id = 0;
  5118. if (TypeName == "A")
  5119. {
  5120. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5121. // 删除该文件
  5122. System.IO.File.Delete(filePath);
  5123. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5124. .Where(a => a.Id == dto.Id)
  5125. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5126. .ExecuteCommandAsync();
  5127. }
  5128. else if (TypeName == "B")
  5129. {
  5130. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5131. // 删除该文件
  5132. System.IO.File.Delete(filePath);
  5133. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5134. if (info != null)
  5135. {
  5136. string[] files = Array.Empty<string>();
  5137. if (!string.IsNullOrEmpty(info.Attachment))
  5138. {
  5139. try
  5140. {
  5141. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5142. }
  5143. catch (Exception)
  5144. {
  5145. files = new List<string>() { info.Attachment }.ToArray();
  5146. }
  5147. }
  5148. if (files.Length > 0)
  5149. {
  5150. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5151. string filePath2 = string.Empty;
  5152. if (files1.Length > 0)
  5153. {
  5154. filePath2 = JsonConvert.SerializeObject(files1);
  5155. }
  5156. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5157. .Where(a => a.Id == dto.Id)
  5158. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5159. .ExecuteCommandAsync();
  5160. }
  5161. }
  5162. }
  5163. if (id != 0)
  5164. {
  5165. return Ok(JsonView(true, "成功!"));
  5166. }
  5167. else
  5168. {
  5169. return Ok(JsonView(false, "失败!"));
  5170. }
  5171. }
  5172. catch (Exception ex)
  5173. {
  5174. return Ok(JsonView(false, "程序错误!"));
  5175. throw;
  5176. }
  5177. }
  5178. /// <summary>
  5179. /// 文件上传多个文件 可以带参数
  5180. /// </summary>
  5181. /// <param name="files"></param>
  5182. /// <returns></returns>
  5183. [HttpPost]
  5184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5185. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5186. {
  5187. try
  5188. {
  5189. var TypeName = Request.Headers["TypeName"].ToString();
  5190. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5191. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5192. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5193. var filePahts = new List<string>();
  5194. foreach (var file in files)
  5195. {
  5196. //文件名称
  5197. string projectFileName = file.FileName;
  5198. //上传的文件的路径
  5199. string filePath = $"{fileDir}/{projectFileName}";
  5200. if (TypeName == "A")//A代表团组增减款项
  5201. {
  5202. if (!Directory.Exists(fileDir))
  5203. {
  5204. Directory.CreateDirectory(fileDir);
  5205. }
  5206. //上传的文件的路径
  5207. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5208. }
  5209. else if (TypeName == "B")//B代表商邀相关文件
  5210. {
  5211. if (!Directory.Exists(fileDir))
  5212. {
  5213. Directory.CreateDirectory(fileDir);
  5214. }
  5215. //上传的文件的路径
  5216. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5217. }
  5218. using (FileStream fs = System.IO.File.Create(filePath))
  5219. {
  5220. file.CopyTo(fs);
  5221. fs.Flush();
  5222. }
  5223. filePahts.Add(projectFileName);
  5224. }
  5225. return Ok(JsonView(true, "上传成功!", filePahts));
  5226. }
  5227. catch (Exception ex)
  5228. {
  5229. return Ok(JsonView(false, ex.Message));
  5230. }
  5231. }
  5232. #endregion
  5233. #region 商邀费用录入
  5234. /// <summary>
  5235. /// 根据团组Id查询商邀费用列表
  5236. /// </summary>
  5237. /// <param name="dto"></param>
  5238. /// <returns></returns>
  5239. [HttpPost]
  5240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5241. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5242. {
  5243. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5244. if (groupData.Code != 0)
  5245. {
  5246. return Ok(JsonView(false, groupData.Msg));
  5247. }
  5248. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5249. }
  5250. /// <summary>
  5251. /// 商邀费用列表
  5252. /// 下载文件
  5253. /// </summary>
  5254. /// <param name="id"></param>
  5255. /// <returns></returns>
  5256. [HttpGet("{id}")]
  5257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5258. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5259. {
  5260. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5261. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5262. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5263. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5264. var filePaths = new List<string>();
  5265. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5266. try
  5267. {
  5268. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5269. }
  5270. catch (Exception ex)
  5271. {
  5272. filePaths.Add(info.Attachment);
  5273. }
  5274. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5275. for (int i = 0; i < filePaths.Count; i++)
  5276. {
  5277. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5278. }
  5279. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5280. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5281. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5282. {
  5283. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5284. {
  5285. foreach (string filePath in filePaths)
  5286. {
  5287. if (System.IO.File.Exists(filePath))
  5288. {
  5289. // 获取文件名
  5290. string fileName = Path.GetFileName(filePath);
  5291. // 将文件添加到ZIP归档中
  5292. zipArchive.CreateEntryFromFile(filePath, fileName);
  5293. }
  5294. }
  5295. }
  5296. }
  5297. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5298. }
  5299. /// <summary>
  5300. /// 商邀费用 Info Page 基础数据源
  5301. /// </summary>
  5302. /// <returns></returns>
  5303. [HttpPost]
  5304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5305. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5306. {
  5307. try
  5308. {
  5309. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5310. if (groupData.Code != 0)
  5311. {
  5312. return Ok(JsonView(false, groupData.Msg));
  5313. }
  5314. return Ok(JsonView(true, "操作成功", groupData.Data));
  5315. }
  5316. catch (Exception ex)
  5317. {
  5318. return Ok(JsonView(false, ex.Message));
  5319. throw;
  5320. }
  5321. }
  5322. /// <summary>
  5323. /// 根据商邀费用ID查询C表和商邀费用数据
  5324. /// </summary>
  5325. /// <param name="dto"></param>
  5326. /// <returns></returns>
  5327. [HttpPost]
  5328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5329. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5330. {
  5331. try
  5332. {
  5333. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5334. if (groupData.Code != 0)
  5335. {
  5336. return Ok(JsonView(false, groupData.Msg));
  5337. }
  5338. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5339. }
  5340. catch (Exception ex)
  5341. {
  5342. return Ok(JsonView(false, ex.Message));
  5343. throw;
  5344. }
  5345. }
  5346. /// <summary>
  5347. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5348. /// </summary>
  5349. /// <param name="dto"></param>
  5350. /// <returns></returns>
  5351. [HttpPost]
  5352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5353. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5354. {
  5355. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5356. if (groupData.Code != 0)
  5357. {
  5358. return Ok(JsonView(false, groupData.Msg));
  5359. }
  5360. #region 应用推送
  5361. try
  5362. {
  5363. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5364. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5365. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5366. //2024-10-21 新增LZ UID
  5367. var userIds = new List<int>() { 21 };
  5368. string title = $"系统通知";
  5369. string content = "";
  5370. var diId = dto.DiId;
  5371. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5372. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5373. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5374. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5375. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5376. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5377. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5378. }
  5379. catch (Exception ex)
  5380. {
  5381. }
  5382. #endregion
  5383. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5384. }
  5385. /// <summary>
  5386. /// 商邀删除
  5387. /// </summary>
  5388. /// <param name="dto"></param>
  5389. /// <returns></returns>
  5390. [HttpPost]
  5391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5392. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5393. {
  5394. try
  5395. {
  5396. _sqlSugar.BeginTran();
  5397. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5398. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5399. {
  5400. IsDel = 1,
  5401. DeleteUserId = dto.DeleteUserId,
  5402. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5403. })
  5404. .Where(it => it.Id == dto.Id)
  5405. .ExecuteCommand();
  5406. if (res1 > 0)
  5407. {
  5408. int _diId = 0;
  5409. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5410. if (_ioaInfo != null)
  5411. {
  5412. _diId = _ioaInfo.DiId;
  5413. }
  5414. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5415. .SetColumns(a => new Grp_CreditCardPayment()
  5416. {
  5417. IsDel = 1,
  5418. DeleteUserId = dto.DeleteUserId,
  5419. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5420. })
  5421. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5422. .ExecuteCommand();
  5423. if (res2 > 0)
  5424. {
  5425. _sqlSugar.CommitTran();
  5426. return Ok(JsonView(true, "删除成功!"));
  5427. }
  5428. }
  5429. _sqlSugar.RollbackTran();
  5430. return Ok(JsonView(false, "删除失败"));
  5431. }
  5432. catch (Exception ex)
  5433. {
  5434. _sqlSugar.RollbackTran();
  5435. return Ok(JsonView(false, ex.Message));
  5436. }
  5437. }
  5438. #endregion
  5439. #region 票据上传
  5440. /// <summary>
  5441. /// 团组模块文件上传
  5442. /// </summary>
  5443. /// <param name="dto"></param>
  5444. /// <returns></returns>
  5445. [HttpPost]
  5446. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5447. {
  5448. var jw = JsonView(false);
  5449. long M = 1024 * 1024;
  5450. if (dto.Files == null || dto.Files.Count == 0)
  5451. {
  5452. jw.Msg = "无文件信息!";
  5453. return Ok(jw);
  5454. }
  5455. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5456. {
  5457. jw.Msg = "文件大小超过20M!";
  5458. return Ok(jw);
  5459. }
  5460. //var nameSp = dto.File.FileName.Split(".");
  5461. //if (nameSp.Length < 2)
  5462. //{
  5463. // jw.Msg = "拓展名称有误!";
  5464. // return Ok(jw);
  5465. //}
  5466. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5467. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5468. //{
  5469. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5470. // return Ok(jw);
  5471. //}
  5472. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5473. if (Ctable == null)
  5474. {
  5475. jw.Msg = "Ctable指向有误!";
  5476. return Ok(jw);
  5477. }
  5478. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5479. if (groupInfo == null)
  5480. {
  5481. jw.Msg = "团组信息不存在!";
  5482. return Ok(jw);
  5483. }
  5484. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5485. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5486. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5487. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5488. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5489. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5490. try
  5491. {
  5492. if (!Directory.Exists(fileBase))
  5493. {
  5494. Directory.CreateDirectory(fileBase);
  5495. }
  5496. var saveArr = new List<Grp_GroupModelFile>();
  5497. foreach (var fileStream in dto.Files)
  5498. {
  5499. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5500. var file = new Grp_GroupModelFile()
  5501. {
  5502. Cid = dto.Cid,
  5503. CreateTime = DateTime.Now,
  5504. CreateUserId = dto.Userid,
  5505. Ctable = dto.Ctable,
  5506. Diid = dto.Diid,
  5507. IsDel = 0,
  5508. FilePath = saveFilePath,
  5509. FileName = fileStream.FileName
  5510. };
  5511. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5512. {
  5513. fileStream.CopyTo(fs);
  5514. fs.Flush();
  5515. }
  5516. saveArr.Add(file);
  5517. }
  5518. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5519. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5520. jw = JsonView(true, "保存成功!", new
  5521. {
  5522. count = addResult,
  5523. filesName = saveArr.Select(x => x.FileName)
  5524. });
  5525. }
  5526. catch (Exception ex)
  5527. {
  5528. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5529. {
  5530. count = 0,
  5531. filesName = Array.Empty<string>(),
  5532. });
  5533. }
  5534. return Ok(jw);
  5535. }
  5536. /// <summary>
  5537. /// 查询各模块已保存文件
  5538. /// </summary>
  5539. /// <param name="dto"></param>
  5540. /// <returns></returns>
  5541. [HttpPost]
  5542. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5543. {
  5544. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5545. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5546. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5547. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5548. {
  5549. expression = Expressionable.Create<Grp_GroupModelFile>()
  5550. .And(x => visaIds.Contains(x.CreateUserId));
  5551. }
  5552. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5553. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5554. .Where(expression.ToExpression())
  5555. .ToList();
  5556. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5557. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5558. {
  5559. x.FileName,
  5560. x.Id,
  5561. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5562. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5563. })));
  5564. }
  5565. /// <summary>
  5566. /// 下载该团组下的所有文件
  5567. /// </summary>
  5568. /// <param name="dto"></param>
  5569. /// <returns></returns>
  5570. [HttpPost]
  5571. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5572. {
  5573. var jw = JsonView(false);
  5574. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5575. if (groupInfo == null)
  5576. {
  5577. jw.Msg = "团组信息不存在!";
  5578. return Ok(jw);
  5579. }
  5580. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5581. var isModule = Convert.ToBoolean(dto.isModule);
  5582. var Zips = new Dictionary<string, Stream>();
  5583. var io = new IOOperatorHelper();
  5584. if (isModule)
  5585. {
  5586. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5587. foreach (var moduleArr in moduleGroup)
  5588. {
  5589. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5590. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5591. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5592. var chiZips = new Dictionary<string, Stream>();
  5593. foreach (var item in moduleArr)
  5594. {
  5595. if (System.IO.File.Exists(item.FilePath))
  5596. {
  5597. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5598. {
  5599. byte[] bytes = new byte[fileStream.Length];
  5600. fileStream.Read(bytes, 0, bytes.Length);
  5601. fileStream.Close();
  5602. Stream stream = new MemoryStream(bytes);
  5603. chiZips.Add(item.FileName, stream);
  5604. }
  5605. }
  5606. }
  5607. if (chiZips.Count > 0)
  5608. {
  5609. var byts = io.ConvertZipStream(chiZips);
  5610. Stream stream = new MemoryStream(byts);
  5611. Zips.Add(key.Name + "_.zip", stream);
  5612. }
  5613. }
  5614. }
  5615. else
  5616. {
  5617. foreach (var item in dbQuery)
  5618. {
  5619. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5620. {
  5621. byte[] bytes = new byte[fileStream.Length];
  5622. fileStream.Read(bytes, 0, bytes.Length);
  5623. fileStream.Close();
  5624. var stream = new MemoryStream(bytes);
  5625. while (Zips.ContainsKey(item.FileName))
  5626. {
  5627. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5628. }
  5629. Zips.Add(item.FileName, stream);
  5630. }
  5631. }
  5632. }
  5633. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5634. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5635. if (Zips.Count > 0)
  5636. {
  5637. var byts = io.ConvertZipStream(Zips);
  5638. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5639. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5640. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5641. }
  5642. else
  5643. {
  5644. jw.Msg = "暂无生成文件!";
  5645. }
  5646. return Ok(jw);
  5647. }
  5648. /// <summary>
  5649. /// 下载该团组下此模块的所有文件
  5650. /// </summary>
  5651. /// <param name="dto"></param>
  5652. /// <returns></returns>
  5653. [HttpPost]
  5654. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5655. {
  5656. var jw = JsonView(false);
  5657. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5658. if (groupInfo == null)
  5659. {
  5660. jw.Msg = "团组信息不存在!";
  5661. return Ok(jw);
  5662. }
  5663. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5664. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5665. && x.IsDel == 0);
  5666. if (key == null)
  5667. {
  5668. jw.Msg = "Ctable指向错误!";
  5669. return Ok(jw);
  5670. }
  5671. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5672. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5673. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5674. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5675. var io = new IOOperatorHelper();
  5676. var Zips = new Dictionary<string, Stream>();
  5677. foreach (var item in dbQuery)
  5678. {
  5679. if (System.IO.File.Exists(item.FilePath))
  5680. {
  5681. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5682. {
  5683. byte[] bytes = new byte[fileStream.Length];
  5684. fileStream.Read(bytes, 0, bytes.Length);
  5685. fileStream.Close();
  5686. var stream = new MemoryStream(bytes);
  5687. while (Zips.ContainsKey(item.FileName))
  5688. {
  5689. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5690. }
  5691. Zips.Add(item.FileName, stream);
  5692. }
  5693. }
  5694. }
  5695. if (Zips.Count > 0)
  5696. {
  5697. var byts = io.ConvertZipStream(Zips);
  5698. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5699. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5700. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5701. }
  5702. else
  5703. {
  5704. jw.Msg = "暂无生成文件!";
  5705. }
  5706. return Ok(jw);
  5707. }
  5708. /// <summary>
  5709. /// 删除该团组下的指定文件
  5710. /// </summary>
  5711. /// <param name="dto"></param>
  5712. /// <returns></returns>
  5713. [HttpPost]
  5714. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5715. {
  5716. var jw = JsonView(false);
  5717. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5718. if (sing == null)
  5719. {
  5720. jw.Msg = "暂无";
  5721. return Ok(jw);
  5722. }
  5723. if (System.IO.File.Exists(sing.FilePath))
  5724. {
  5725. try
  5726. {
  5727. System.IO.File.Delete(sing.FilePath);
  5728. }
  5729. catch (Exception ex)
  5730. {
  5731. jw.Msg = "删除失败!" + ex.Message;
  5732. return Ok(jw);
  5733. }
  5734. }
  5735. sing.IsDel = 1;
  5736. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5737. sing.DeleteUserId = dto.UserId;
  5738. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5739. jw = JsonView(true, "删除成功!");
  5740. return Ok(jw);
  5741. }
  5742. #endregion
  5743. #region 共享文件上传
  5744. /// <summary>
  5745. /// 共享文件数据初始化
  5746. /// </summary>
  5747. /// <returns></returns>
  5748. [HttpGet]
  5749. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5750. {
  5751. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5752. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5753. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5754. .Select(x => x.Id)
  5755. .ToList()
  5756. .Contains(userid);
  5757. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5758. .Where(x => x.STid == 111 && x.IsDel == 0)
  5759. .Select(x => new
  5760. {
  5761. x.Name,
  5762. x.Id,
  5763. }).ToList();
  5764. if (isMarketingDepartment)
  5765. {
  5766. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5767. }
  5768. if (portType == 1)
  5769. {
  5770. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5771. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5772. .Where(x => x.IsDel == 0)
  5773. .OrderByDescending(x => x.VisitDate)
  5774. .Select(x => new
  5775. {
  5776. x.TeamName,
  5777. x.Id,
  5778. x.CityId,
  5779. })
  5780. .ToList()
  5781. .Select(x =>
  5782. {
  5783. var provinceId = x.CityId;
  5784. var isDefualtVal = true;
  5785. if (provinceId > 0)
  5786. {
  5787. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5788. if (parentId != null)
  5789. {
  5790. isDefualtVal = false;
  5791. provinceId = (int)parentId;
  5792. }
  5793. }
  5794. if (isDefualtVal)
  5795. {
  5796. provinceId = 122; //默认四川
  5797. }
  5798. return new
  5799. {
  5800. x.TeamName,
  5801. x.Id,
  5802. provinceId,
  5803. };
  5804. })
  5805. .ToList();
  5806. return Ok(JsonView(true, "SUCCESS!", new
  5807. {
  5808. dropDownType,
  5809. dropDownGroupList,
  5810. isMarketingDepartment
  5811. }));
  5812. }
  5813. else if (portType == 2 || portType == 3)
  5814. {
  5815. return Ok(JsonView(true, "SUCCESS!", new
  5816. {
  5817. dropDownType,
  5818. isMarketingDepartment
  5819. }));
  5820. }
  5821. else
  5822. {
  5823. return Ok(JsonView(false, "portType有误!"));
  5824. }
  5825. }
  5826. /// <summary>
  5827. /// 共享文件上传
  5828. /// </summary>
  5829. /// <param name="dto"></param>
  5830. /// <returns></returns>
  5831. [HttpPost]
  5832. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5833. {
  5834. var isGroup = new List<int> { 1412 };
  5835. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5836. {
  5837. return Ok(JsonView(false, "该文件需要关联团组!"));
  5838. }
  5839. if (dto.Files == null || dto.Files.Count == 0)
  5840. {
  5841. return Ok(JsonView(false, "无文件信息!"));
  5842. }
  5843. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5844. {
  5845. return Ok(JsonView(false, "文件大小超过20M!"));
  5846. }
  5847. if (dto.Userid < 1)
  5848. {
  5849. return Ok(JsonView(false, "请传入有效的Userid!"));
  5850. }
  5851. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5852. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5853. .Select((u, j) => new
  5854. {
  5855. u.CnName,
  5856. UserId = u.Id,
  5857. j.JobName,
  5858. })
  5859. .First();
  5860. if (jobInfo == null)
  5861. {
  5862. return Ok(JsonView(false, "请传入有效的Userid!"));
  5863. }
  5864. var commonFileExtensions = new List<string>
  5865. {
  5866. // 文本文件
  5867. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5868. // 图片文件
  5869. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5870. // 视频文件
  5871. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5872. // 音频文件
  5873. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5874. // 压缩文件
  5875. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5876. // 数据文件
  5877. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5878. };
  5879. try
  5880. {
  5881. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5882. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5883. commonFileExtensions.AddRange(settingExtend);
  5884. }
  5885. catch (Exception)
  5886. { }
  5887. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5888. if (setdata == null)
  5889. {
  5890. return Ok(JsonView(false, "请传入有效的FileType!"));
  5891. }
  5892. var insertList = new List<Grp_GroupShareFile>();
  5893. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5894. if (!Directory.Exists(winPath))
  5895. {
  5896. Directory.CreateDirectory(winPath);
  5897. }
  5898. foreach (var item in dto.Files)
  5899. {
  5900. var houzui = Path.GetExtension(item.FileName);
  5901. if (!commonFileExtensions.Contains(houzui))
  5902. {
  5903. return Ok(JsonView(false, "未知后缀名称!"));
  5904. }
  5905. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5906. var saveFilePath = winPath + fileName;
  5907. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5908. {
  5909. item.CopyTo(fs);
  5910. fs.Flush();
  5911. }
  5912. var fileDetail = new Grp_GroupShareFile()
  5913. {
  5914. CreateUserId = dto.Userid,
  5915. CreateTime = DateTime.Now,
  5916. UploadJob = jobInfo.JobName,
  5917. FileName = fileName,
  5918. FileType = dto.FileType,
  5919. Diid = dto.Diid,
  5920. FilePath = winPath + fileName,
  5921. };
  5922. insertList.Add(fileDetail);
  5923. }
  5924. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5925. return Ok(JsonView(true, "保存成功!"));
  5926. }
  5927. /// <summary>
  5928. /// 查询共享文件列表
  5929. /// </summary>
  5930. /// <param name="dto"></param>
  5931. /// <returns></returns>
  5932. [HttpPost]
  5933. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5934. {
  5935. var isGroup = new List<int> { 1412 };
  5936. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5937. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5938. .And(x => x.Diid == dto.Diid)
  5939. .And(x => x.FileType == dto.FileType)
  5940. .And(x => x.IsDel == 0)
  5941. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5942. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5943. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5944. int totalCount = 0;
  5945. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5946. .Where(queryExpression.ToExpression())
  5947. .OrderBy(x => x.UploadJob)
  5948. .Select(x => new
  5949. {
  5950. x.Id,
  5951. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5952. x.FileName,
  5953. x.FileType,
  5954. x.CreateTime,
  5955. })
  5956. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5957. return Ok(JsonView(true, "SUCCESS!", new
  5958. {
  5959. FileList = dbQuery,
  5960. dto.PageSize,
  5961. dto.PageIndex,
  5962. totalCount
  5963. }));
  5964. }
  5965. /// <summary>
  5966. /// 删除共享文件模块下的指定文件
  5967. /// </summary>
  5968. /// <param name="dto"></param>
  5969. /// <returns></returns>
  5970. [HttpPost]
  5971. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5972. {
  5973. var jw = JsonView(false);
  5974. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5975. if (sing == null)
  5976. {
  5977. jw.Msg = "暂无文件信息!";
  5978. return Ok(jw);
  5979. }
  5980. if (sing.CreateUserId != dto.UserId)
  5981. {
  5982. jw.Msg = "只能删除自己上传的文件!";
  5983. return Ok(jw);
  5984. }
  5985. if (System.IO.File.Exists(sing.FilePath))
  5986. {
  5987. try
  5988. {
  5989. System.IO.File.Delete(sing.FilePath);
  5990. }
  5991. catch (Exception ex)
  5992. {
  5993. jw.Msg = "删除失败!" + ex.Message;
  5994. return Ok(jw);
  5995. }
  5996. }
  5997. sing.IsDel = 1;
  5998. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5999. sing.DeleteUserId = dto.UserId;
  6000. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6001. jw = JsonView(true, "删除成功!");
  6002. return Ok(jw);
  6003. }
  6004. #endregion
  6005. #region 团组英文资料
  6006. /// <summary>
  6007. /// 查询团组英文所有资料
  6008. /// </summary>
  6009. /// <param name="dto"></param>
  6010. /// <returns></returns>
  6011. [HttpPost]
  6012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6013. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6014. {
  6015. try
  6016. {
  6017. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6018. if (groupData.Code != 0)
  6019. {
  6020. return Ok(JsonView(false, groupData.Msg));
  6021. }
  6022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6023. }
  6024. catch (Exception ex)
  6025. {
  6026. return Ok(JsonView(false, ex.Message));
  6027. throw;
  6028. }
  6029. }
  6030. /// <summary>
  6031. /// 团组英文资料操作(Status:1.新增,2.修改)
  6032. /// </summary>
  6033. /// <param name="dto"></param>
  6034. /// <returns></returns>
  6035. [HttpPost]
  6036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6037. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6038. {
  6039. try
  6040. {
  6041. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6042. if (groupData.Code != 0)
  6043. {
  6044. return Ok(JsonView(false, groupData.Msg));
  6045. }
  6046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6047. }
  6048. catch (Exception ex)
  6049. {
  6050. return Ok(JsonView(false, ex.Message));
  6051. throw;
  6052. }
  6053. }
  6054. /// <summary>
  6055. /// 团组英文资料Id查询数据
  6056. /// </summary>
  6057. /// <param name="dto"></param>
  6058. /// <returns></returns>
  6059. [HttpPost]
  6060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6061. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6062. {
  6063. try
  6064. {
  6065. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6066. if (_DelegationEnData != null)
  6067. {
  6068. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6069. }
  6070. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6071. }
  6072. catch (Exception ex)
  6073. {
  6074. return Ok(JsonView(false, "程序错误!"));
  6075. throw;
  6076. }
  6077. }
  6078. /// <summary>
  6079. /// 团组英文资料删除
  6080. /// </summary>
  6081. /// <param name="dto"></param>
  6082. /// <returns></returns>
  6083. [HttpPost]
  6084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6085. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6086. {
  6087. try
  6088. {
  6089. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6090. if (!res)
  6091. {
  6092. return Ok(JsonView(false, "删除失败"));
  6093. }
  6094. return Ok(JsonView(true, "删除成功!"));
  6095. }
  6096. catch (Exception ex)
  6097. {
  6098. return Ok(JsonView(false, ex.Message));
  6099. throw;
  6100. }
  6101. }
  6102. #endregion
  6103. #region 导出邀请函
  6104. /// <summary>
  6105. /// 导出邀请函页面初始化
  6106. /// </summary>
  6107. /// <param name="dto"></param>
  6108. /// <returns></returns>
  6109. [HttpPost]
  6110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6111. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6112. {
  6113. try
  6114. {
  6115. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6116. var crm_Deles = new List<Crm_DeleClient>();
  6117. if (dto.DiId == 0)
  6118. {
  6119. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6120. }
  6121. else
  6122. {
  6123. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6124. }
  6125. return Ok(JsonView(true, "查询成功!", new
  6126. {
  6127. deleClient = crm_Deles,
  6128. delegations = grp_Delegations
  6129. }));
  6130. }
  6131. catch (Exception ex)
  6132. {
  6133. return Ok(JsonView(false, "程序错误!"));
  6134. throw;
  6135. }
  6136. }
  6137. /// <summary>
  6138. /// 导出邀请函
  6139. /// </summary>
  6140. /// <param name="dto"></param>
  6141. /// <returns></returns>
  6142. [HttpPost]
  6143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6144. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6145. {
  6146. #region 参数验证
  6147. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6148. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6149. #endregion
  6150. try
  6151. {
  6152. var transDic = new Dictionary<string, string>();
  6153. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6154. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6155. From Grp_TourClientList tcl
  6156. Left Join
  6157. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6158. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6159. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6160. From Crm_DeleClient dc
  6161. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6162. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6163. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6164. Where dc.IsDel = 0) temp
  6165. On temp.DcId =tcl.ClientId
  6166. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6167. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6168. var texts = new List<string>();
  6169. if (datas.Count != 0)
  6170. {
  6171. foreach (TourClientListDetailsView item in datas)
  6172. {
  6173. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6174. {
  6175. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6176. }
  6177. else
  6178. {
  6179. string name = item.LastName + item.FirstName;
  6180. texts.Add(name);
  6181. }
  6182. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6183. {
  6184. if (!transDic.ContainsKey(item.Job))
  6185. {
  6186. texts.Add(item.Job);
  6187. }
  6188. }
  6189. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6190. {
  6191. texts.Add(item.CompanyFullName);
  6192. }
  6193. }
  6194. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6195. if (transData.Count > 0)
  6196. {
  6197. foreach (TranslateResult item in transData)
  6198. {
  6199. if (!transDic.ContainsKey(item.Query))
  6200. {
  6201. transDic.Add(item.Query, item.Translation);
  6202. }
  6203. }
  6204. }
  6205. var list = new List<GuestList>();
  6206. foreach (var dele in datas)
  6207. {
  6208. var guestList = new GuestList();
  6209. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6210. {
  6211. guestList.Name = dele.Pinyin;
  6212. }
  6213. else
  6214. {
  6215. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6216. guestList.Name = Name;
  6217. }
  6218. if (dele.Sex == 0)
  6219. {
  6220. guestList.Sex = "Male";
  6221. }
  6222. else if (dele.Sex == 1)
  6223. {
  6224. guestList.Sex = "Female";
  6225. }
  6226. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6227. if (!string.IsNullOrEmpty(dele.Job))
  6228. {
  6229. guestList.Job = dele.Job;
  6230. }
  6231. list.Add(guestList);
  6232. }
  6233. //载入模板
  6234. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6235. var builder = new DocumentBuilder(doc);
  6236. //获取word里所有表格
  6237. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6238. //获取所填表格的序数
  6239. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6240. var rowStart = tableOne.Rows[0]; //获取第1行
  6241. //循环赋值
  6242. for (int i = 0; i < list.Count; i++)
  6243. {
  6244. builder.MoveToCell(0, i + 1, 0, 0);
  6245. builder.Write(list[i].Name.ToString());
  6246. builder.MoveToCell(0, i + 1, 1, 0);
  6247. builder.Write(list[i].Sex.ToString());
  6248. builder.MoveToCell(0, i + 1, 2, 0);
  6249. builder.Write(list[i].DOB.ToString());
  6250. builder.MoveToCell(0, i + 1, 3, 0);
  6251. builder.Write(list[i].Job.ToString());
  6252. }
  6253. //删除多余行
  6254. while (tableOne.Rows.Count > list.Count + 1)
  6255. {
  6256. tableOne.Rows.RemoveAt(list.Count + 1);
  6257. }
  6258. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6259. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6260. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6261. doc.Save(filePath);
  6262. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6263. return Ok(JsonView(true, "操作成功!", Url));
  6264. }
  6265. else
  6266. {
  6267. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6268. }
  6269. }
  6270. catch (Exception ex)
  6271. {
  6272. return Ok(JsonView(false, ex.Message));
  6273. throw;
  6274. }
  6275. }
  6276. #endregion
  6277. #region 团组经理模块 出入境费用
  6278. /// <summary>
  6279. /// 团组模块 - 出入境费用 - 省份基础数据源
  6280. /// </summary>
  6281. /// <returns></returns>
  6282. [HttpGet]
  6283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6284. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6285. {
  6286. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6287. }
  6288. /// <summary>
  6289. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6290. /// </summary>
  6291. /// <param name="dto"></param>
  6292. /// <returns></returns>
  6293. [HttpPost]
  6294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6295. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6296. {
  6297. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6298. var groupNamFirst = groupNameData.FirstOrDefault();
  6299. //SetDataInfoView
  6300. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6301. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6302. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6303. //验证城市归属并给默认值
  6304. int provinceId = 122;
  6305. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6306. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6307. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6308. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6309. return Ok(JsonView(true, "查询成功!", new
  6310. {
  6311. GroupNameData = groupNameData,
  6312. CurrencyData = _CurrencyData,
  6313. WordTypeData = wordTypeData,
  6314. ExcelTypeData = excelTypeData,
  6315. CurrencyInit = _currencyInfos,
  6316. ViewPermissionData = viewPermissionData
  6317. }));
  6318. }
  6319. /// <summary>
  6320. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6321. /// </summary>
  6322. /// <returns></returns>
  6323. [HttpGet("{provinceId}")]
  6324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6325. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6326. {
  6327. //验证城市归属并给默认值
  6328. if (provinceId < 1) provinceId = 122;
  6329. /*
  6330. * 122 四川
  6331. * 108 贵州
  6332. * 103 重庆
  6333. * 132 云南
  6334. */
  6335. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6336. return Ok(JsonView(true, "查询成功!", new
  6337. {
  6338. WordTypeData = wordTypeData,
  6339. ExcelTypeData = excelTypeData,
  6340. }));
  6341. }
  6342. /// <summary>
  6343. /// 团组模块 - 出入境费用
  6344. /// 实时汇率 tips
  6345. /// 签证费用 tips
  6346. /// 机票费用 tips
  6347. /// </summary>
  6348. /// <returns></returns>
  6349. [HttpPost]
  6350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6351. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6352. {
  6353. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6354. //默认币种显示
  6355. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6356. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6357. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6358. return Ok(JsonView(true, "查询成功!", new
  6359. {
  6360. //GroupNameData = groupNameData.Data,
  6361. visaData = visaData.Data,
  6362. airData,
  6363. reteInfos
  6364. }));
  6365. }
  6366. /// <summary>
  6367. /// 团组模块 - 出入境费用 - Info
  6368. /// </summary>
  6369. /// <param name="dto"></param>
  6370. /// <returns></returns>
  6371. [HttpPost]
  6372. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6374. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6375. {
  6376. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6377. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6378. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6379. }
  6380. /// <summary>
  6381. /// 团组模块 - 出入境费用 - 设置view权限
  6382. /// </summary>
  6383. /// <returns></returns>
  6384. [HttpPost]
  6385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6386. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6387. {
  6388. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6389. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6390. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6391. var permissions = new List<Grp_EnterExitCostPermission>();
  6392. foreach (var userId in dto.UserIds)
  6393. {
  6394. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6395. }
  6396. if (permissions.Any())
  6397. {
  6398. _sqlSugar.BeginTran();
  6399. try
  6400. {
  6401. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6402. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6403. if (result < 1)
  6404. {
  6405. _sqlSugar.RollbackTran();
  6406. return Ok(JsonView(false));
  6407. }
  6408. }
  6409. catch (Exception ex)
  6410. {
  6411. _sqlSugar.RollbackTran();
  6412. return Ok(JsonView(false, ex.Message));
  6413. }
  6414. _sqlSugar.CommitTran();
  6415. return Ok(JsonView(true));
  6416. }
  6417. return Ok(JsonView(false));
  6418. }
  6419. /// <summary>
  6420. /// 团组模块 - 出入境费用 - Add And Update
  6421. /// </summary>
  6422. /// <returns></returns>
  6423. [HttpPost]
  6424. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6426. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6427. {
  6428. try
  6429. {
  6430. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6431. if (dto.DayOtherPriceData.Any())
  6432. {
  6433. var inserList = dto.DayOtherPriceData
  6434. .Where(x => x.Id == 0)
  6435. .Select(x => new Grp_DayOtherPrice
  6436. {
  6437. Cost = x.Cost,
  6438. Id = x.Id,
  6439. CreateTime = DateTime.Now,
  6440. CreateUserId = dto.UserId,
  6441. Currency = x.Currency,
  6442. Diid = x.DiId,
  6443. Index = x.Index,
  6444. IsDel = 0,
  6445. SetDataId = x.SetDataId,
  6446. SubTotal = x.SubTotal,
  6447. Remark = x.Remark
  6448. })
  6449. .ToList();
  6450. var updateList = dto.DayOtherPriceData
  6451. .Where(x => x.Id != 0)
  6452. .Select(x => new Grp_DayOtherPrice
  6453. {
  6454. Cost = x.Cost,
  6455. Id = x.Id,
  6456. CreateTime = DateTime.Now,
  6457. CreateUserId = dto.UserId,
  6458. Currency = x.Currency,
  6459. Diid = x.DiId,
  6460. Index = x.Index,
  6461. IsDel = 0,
  6462. SetDataId = x.SetDataId,
  6463. SubTotal = x.SubTotal,
  6464. Remark = x.Remark
  6465. })
  6466. .ToList();
  6467. //添加
  6468. _sqlSugar.BeginTran();
  6469. if (inserList.Any())
  6470. {
  6471. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6472. }
  6473. if (updateList.Any())
  6474. {
  6475. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6476. }
  6477. _sqlSugar.CommitTran();
  6478. }
  6479. if (data.Code != 0)
  6480. {
  6481. return Ok(JsonView(false, data.Msg));
  6482. }
  6483. //生成默认文件pdf并且通知人员
  6484. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6485. {
  6486. DiId = dto.DiId,
  6487. ExportType = 1,
  6488. SubTypeId = 1005
  6489. }, "pdf");
  6490. //发送通知
  6491. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6492. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6493. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6494. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6495. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6496. //汇率信息记录
  6497. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6498. return Ok(JsonView(true, data.Msg, data.Data));
  6499. }
  6500. catch (Exception ex)
  6501. {
  6502. return Ok(JsonView(false, ex.Message));
  6503. }
  6504. }
  6505. /// <summary>
  6506. /// 团组模块 - 出入境费用 - Confirm 费用
  6507. /// </summary>
  6508. /// <returns></returns>
  6509. [HttpPost]
  6510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6511. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6512. {
  6513. //TODO:测试完毕需把对应的用户ID更改
  6514. //1、数据表添加字段
  6515. //2、更改字段接口()
  6516. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6517. //3、确认成功 给财务发送消息
  6518. if (_view.Code == 200)
  6519. {
  6520. if (dto.Type == 1)
  6521. {
  6522. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6523. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6524. }
  6525. }
  6526. return Ok(_view);
  6527. }
  6528. /// <summary>
  6529. /// 团组模块 - 出入境费用 - File download
  6530. /// </summary>
  6531. /// <param name="dto"></param>
  6532. /// <returns></returns>
  6533. [HttpPost]
  6534. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6536. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6537. {
  6538. try
  6539. {
  6540. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6541. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6542. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6543. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6544. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6545. 3 团组成员名单 1 团组成员名单", ""));
  6546. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6547. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6548. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6549. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6550. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6551. //数据源
  6552. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6553. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6554. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6555. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6556. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6557. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6558. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6559. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6560. .Select((x, a, b) => new
  6561. {
  6562. x.Index,
  6563. itemName = a.Name,
  6564. CurrencyStr = b.Name,
  6565. x.Cost,
  6566. x.SubTotal,
  6567. x.Remark
  6568. })
  6569. .OrderBy((x) => x.Index)
  6570. .ToList(); //其他款项费用
  6571. var peiceItemCurrencys = new List<string>();
  6572. if (_DayAndCosts.Any())
  6573. {
  6574. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6575. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6576. }
  6577. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6578. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6579. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6580. {
  6581. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6582. }
  6583. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6584. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6585. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6586. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6587. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6588. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6589. .Select((tcl, dc, cc) => new ClientInfo
  6590. {
  6591. LastName = dc.LastName,
  6592. FirstName = dc.FirstName,
  6593. Sex = dc.Sex,
  6594. Birthday = dc.BirthDay,
  6595. Company = cc.CompanyFullName,
  6596. Job = dc.Job
  6597. })
  6598. .ToList();
  6599. foreach (var item in DeleClientList)
  6600. {
  6601. EncryptionProcessor.DecryptProperties(item);
  6602. }
  6603. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6604. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6605. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6606. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6607. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6608. if (dto.ExportType == 1) //明细表
  6609. {
  6610. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6611. {
  6612. //获取模板
  6613. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6614. //载入模板
  6615. var doc = new Document(tempPath);
  6616. var builder = new DocumentBuilder(doc);
  6617. var dic = new Dictionary<string, string>();
  6618. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6619. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6620. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6621. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6622. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6623. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6624. //境内费用(其他费用)
  6625. if (_EnterExitCosts.ChoiceOne == 1)
  6626. {
  6627. string row1_1 = "";
  6628. if (_EnterExitCosts.Visa > 0)
  6629. {
  6630. //insidePayTotal += _EnterExitCosts.Visa;
  6631. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6632. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6633. //{
  6634. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6635. //}
  6636. }
  6637. string row1_2 = "";
  6638. if (_EnterExitCosts.YiMiao > 0)
  6639. {
  6640. //insidePayTotal += _EnterExitCosts.YiMiao;
  6641. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6642. }
  6643. if (_EnterExitCosts.HeSuan > 0)
  6644. {
  6645. //insidePayTotal += _EnterExitCosts.HeSuan;
  6646. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6647. }
  6648. if (_EnterExitCosts.Service > 0)
  6649. {
  6650. //insidePayTotal += _EnterExitCosts.Service;
  6651. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6652. }
  6653. string row1_3 = "";
  6654. if (_EnterExitCosts.Safe > 0)
  6655. {
  6656. //insidePayTotal += _EnterExitCosts.Safe;
  6657. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6658. }
  6659. if (_EnterExitCosts.Ticket > 0)
  6660. {
  6661. //insidePayTotal += _EnterExitCosts.Ticket;
  6662. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6663. }
  6664. string row1 = "";
  6665. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6666. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6667. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6668. row1 += $"备注:{_EnterExitCosts.Remark}";
  6669. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6670. dic.Add("Row1Str", row1);
  6671. }
  6672. string airTotalStr = string.Empty,
  6673. airPriceStr = string.Empty;
  6674. //经济舱
  6675. if (_EnterExitCosts.SumJJC == 1)
  6676. {
  6677. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6678. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6679. }
  6680. //公务舱
  6681. if (_EnterExitCosts.SumGWC == 1)
  6682. {
  6683. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6684. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6685. }
  6686. //头等舱
  6687. if (_EnterExitCosts.SumTDC == 1)
  6688. {
  6689. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6690. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6691. }
  6692. //汇率描述
  6693. string rateStr = "";
  6694. if (peiceItemCurrencyInfos.Any())
  6695. {
  6696. rateStr = "\r\n汇率描述:";
  6697. foreach (var item in peiceItemCurrencyInfos)
  6698. {
  6699. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6700. }
  6701. }
  6702. string twoItemRemark = "备注:";
  6703. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6704. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6705. dic.Add("AirTotalStr", airTotalStr);
  6706. dic.Add("AirPriceStr", airPriceStr);
  6707. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6708. dic.Add("TwoItemRemark", twoItemRemark);
  6709. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6710. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6711. int table1Row = 0,
  6712. table2Row = 0,
  6713. table3Row = 0,
  6714. table4Row = 0,
  6715. table5Row = 0;
  6716. //住宿费
  6717. if (_EnterExitCosts.ChoiceThree == 1)
  6718. {
  6719. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6720. table1Row = dac1.Count;
  6721. #region 填充word表格内容
  6722. for (int i = 0; i < dac1.Count; i++)
  6723. {
  6724. Grp_DayAndCost dac = dac1[i];
  6725. if (dac == null) continue;
  6726. builder.MoveToCell(0, i, 0, 0);
  6727. builder.Write("第" + dac.Days.ToString() + "晚:");
  6728. builder.MoveToCell(0, i, 1, 0);
  6729. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6730. //builder.Write(dac.Place == null ? "" : dac.Place);
  6731. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6732. builder.MoveToCell(0, i, 2, 0);
  6733. builder.Write("费用标准:");
  6734. string curr = "";
  6735. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6736. if (currData != null)
  6737. {
  6738. curr = currData.Name;
  6739. }
  6740. builder.MoveToCell(0, i, 3, 0);
  6741. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6742. builder.MoveToCell(0, i, 4, 0);
  6743. builder.Write("费用小计:");
  6744. builder.MoveToCell(0, i, 5, 0);
  6745. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6746. }
  6747. #endregion
  6748. }
  6749. else dic.Add("SubZS", "0.00");
  6750. //删除多余行
  6751. while (table1.Rows.Count > table1Row)
  6752. {
  6753. table1.Rows.RemoveAt(table1Row);
  6754. }
  6755. //伙食费
  6756. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6757. if (_EnterExitCosts.ChoiceFour == 1)
  6758. {
  6759. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6760. table2Row = dac2.Count;
  6761. #region 填充word表格内容
  6762. for (int i = 0; i < dac2.Count; i++)
  6763. {
  6764. Grp_DayAndCost dac = dac2[i];
  6765. if (dac == null) continue;
  6766. builder.MoveToCell(1, i, 0, 0);
  6767. builder.Write("第" + dac.Days.ToString() + "天:");
  6768. builder.MoveToCell(1, i, 1, 0);
  6769. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6770. builder.MoveToCell(1, i, 2, 0);
  6771. builder.Write("费用标准:");
  6772. string curr = "";
  6773. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6774. if (currData != null)
  6775. {
  6776. curr = currData.Name;
  6777. }
  6778. builder.MoveToCell(1, i, 3, 0);
  6779. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6780. builder.MoveToCell(1, i, 4, 0);
  6781. builder.Write("费用小计:");
  6782. builder.MoveToCell(1, i, 5, 0);
  6783. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6784. }
  6785. #endregion
  6786. }
  6787. else dic.Add("SubHS", "0.00");
  6788. //删除多余行
  6789. while (table2.Rows.Count > table2Row)
  6790. {
  6791. table2.Rows.RemoveAt(table2Row);
  6792. }
  6793. //公杂费
  6794. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6795. if (_EnterExitCosts.ChoiceFive == 1)
  6796. {
  6797. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6798. table3Row = dac3.Count;
  6799. #region 填充word表格内容
  6800. for (int i = 0; i < dac3.Count; i++)
  6801. {
  6802. Grp_DayAndCost dac = dac3[i];
  6803. if (dac == null) continue;
  6804. builder.MoveToCell(2, i, 0, 0);
  6805. builder.Write("第" + dac.Days.ToString() + "天:");
  6806. builder.MoveToCell(2, i, 1, 0);
  6807. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6808. builder.MoveToCell(2, i, 2, 0);
  6809. builder.Write("费用标准:");
  6810. string curr = "";
  6811. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6812. if (currData != null)
  6813. {
  6814. curr = currData.Name;
  6815. }
  6816. builder.MoveToCell(2, i, 3, 0);
  6817. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6818. builder.MoveToCell(2, i, 4, 0);
  6819. builder.Write("费用小计:");
  6820. builder.MoveToCell(2, i, 5, 0);
  6821. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6822. }
  6823. //删除多余行
  6824. while (table3.Rows.Count > table3Row)
  6825. {
  6826. table3.Rows.RemoveAt(table3Row);
  6827. }
  6828. #endregion
  6829. }
  6830. else dic.Add("SubGZF", "0.00");
  6831. //删除多余行
  6832. while (table3.Rows.Count > table3Row)
  6833. {
  6834. table3.Rows.RemoveAt(table3Row);
  6835. }
  6836. //培训费
  6837. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6838. if (_EnterExitCosts.ChoiceSix == 1)
  6839. {
  6840. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6841. dic.Add("SubPX", pxStr);
  6842. table4Row = dac4.Count;
  6843. #region 填充word表格内容
  6844. for (int i = 0; i < dac4.Count; i++)
  6845. {
  6846. Grp_DayAndCost dac = dac4[i];
  6847. if (dac == null) continue;
  6848. builder.MoveToCell(3, i, 0, 0);
  6849. builder.Write("第" + dac.Days.ToString() + "天:");
  6850. builder.MoveToCell(3, i, 1, 0);
  6851. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6852. builder.MoveToCell(3, i, 2, 0);
  6853. builder.Write("费用标准:");
  6854. string curr = "";
  6855. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6856. if (currData != null)
  6857. {
  6858. curr = currData.Name;
  6859. }
  6860. builder.MoveToCell(3, i, 3, 0);
  6861. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6862. builder.MoveToCell(3, i, 4, 0);
  6863. builder.Write("费用小计:");
  6864. builder.MoveToCell(3, i, 5, 0);
  6865. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6866. }
  6867. #endregion
  6868. }
  6869. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6870. //删除多余行
  6871. while (table4.Rows.Count > table4Row)
  6872. {
  6873. table4.Rows.RemoveAt(table4Row);
  6874. }
  6875. //其他费用
  6876. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6877. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6878. {
  6879. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6880. dic.Add("titleQi", qtStr);
  6881. table5Row = dac5.Count;
  6882. #region 填充word表格内容
  6883. for (int i = 0; i < dac5.Count; i++)
  6884. {
  6885. var dac = dac5[i];
  6886. if (dac == null) continue;
  6887. builder.MoveToCell(4, i, 0, 0);
  6888. builder.Write("第" + dac.Index.ToString() + "项:");
  6889. builder.MoveToCell(4, i, 1, 0);
  6890. builder.Write(dac.itemName);
  6891. builder.MoveToCell(4, i, 2, 0);
  6892. builder.Write("费用标准:");
  6893. builder.MoveToCell(4, i, 3, 0);
  6894. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6895. builder.MoveToCell(4, i, 4, 0);
  6896. builder.Write("费用小计:");
  6897. builder.MoveToCell(4, i, 5, 0);
  6898. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6899. builder.MoveToCell(4, i, 6, 0);
  6900. builder.Write("备注:");
  6901. builder.MoveToCell(4, i, 7, 0);
  6902. builder.Write(dac.Remark);
  6903. }
  6904. #endregion
  6905. }
  6906. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6907. //删除多余行
  6908. while (table5.Rows.Count > table5Row)
  6909. {
  6910. table5.Rows.RemoveAt(table5Row);
  6911. }
  6912. //加上其他费用
  6913. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6914. decimal subJJC = 0.00M,
  6915. subGWC = 0.00M,
  6916. subTDC = 0.00M;
  6917. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6918. string totalLabel = string.Format("全部费用总计:");
  6919. //经济舱
  6920. if (_EnterExitCosts.SumJJC == 1)
  6921. {
  6922. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6923. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  6924. }
  6925. //公务舱
  6926. if (_EnterExitCosts.SumGWC == 1)
  6927. {
  6928. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6929. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  6930. }
  6931. //头等舱
  6932. if (_EnterExitCosts.SumTDC == 1)
  6933. {
  6934. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6935. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  6936. }
  6937. //TotalLabel
  6938. dic.Add("TotalLabel", totalLabel);
  6939. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6940. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6941. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6942. #region 填充word模板书签内容
  6943. foreach (var key in dic.Keys)
  6944. {
  6945. Bookmark bookmark = doc.Range.Bookmarks[key];
  6946. if (bookmark != null)
  6947. {
  6948. builder.MoveToBookmark(key);
  6949. builder.Write(dic[key]);
  6950. }
  6951. }
  6952. #endregion
  6953. #region 设置页眉
  6954. string userLabel = string.Empty;
  6955. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6956. if (currUserInfo != null)
  6957. {
  6958. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6959. if (userInfo != null)
  6960. {
  6961. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6962. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6963. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6964. }
  6965. }
  6966. //设置页脚
  6967. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6968. #endregion
  6969. //文件名
  6970. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6971. AsposeHelper.removewatermark_v2180();
  6972. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6973. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6974. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6975. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6976. }
  6977. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6978. {
  6979. //获取模板
  6980. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6981. //载入模板
  6982. var doc = new Document(tempPath);
  6983. var builder = new DocumentBuilder(doc);
  6984. var dic = new Dictionary<string, string>();
  6985. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6986. {
  6987. var list = new List<string>();
  6988. try
  6989. {
  6990. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6991. foreach (var item in spilitArr)
  6992. {
  6993. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6994. var depCode = spDotandEmpty[2].Substring(0, 3);
  6995. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6996. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6997. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6998. list.Add(depName);
  6999. list.Add(arrName);
  7000. }
  7001. list = list.Distinct().ToList();
  7002. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7003. }
  7004. catch (Exception)
  7005. {
  7006. dic.Add("ReturnCode", "行程录入不正确!");
  7007. }
  7008. }
  7009. else
  7010. {
  7011. dic.Add("ReturnCode", "未录入行程!");
  7012. }
  7013. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7014. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7015. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7016. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7017. {
  7018. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7019. dic.Add("Day", sp.Days.ToString());
  7020. }
  7021. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7022. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7023. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7024. //dic.Add("Names", Names);
  7025. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7026. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7027. decimal dac1totalPrice = 0.00M;
  7028. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7029. foreach (var dac in dac1)
  7030. {
  7031. if (dac.SubTotal == 0.00M)
  7032. {
  7033. continue;
  7034. }
  7035. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7036. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7037. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7038. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7039. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7040. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7041. builder.Write(currency);//币种
  7042. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7043. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7044. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7045. builder.Write("");//人数
  7046. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7047. builder.Write("");//天数
  7048. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7049. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7050. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7051. decimal rate = 0.00M;
  7052. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7053. builder.Write(rate.ToString("#0.0000"));//汇率
  7054. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7055. decimal rbmPrice = dac.SubTotal;
  7056. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7057. accommodationStartIndex++;
  7058. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7059. }
  7060. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7061. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7062. {
  7063. table1.Rows.RemoveAt(i - 1);
  7064. foodandotherStartIndex--;
  7065. }
  7066. if (dac2.Count == dac3.Count)//国家 币种 金额
  7067. {
  7068. for (int i = 0; i < dac2.Count; i++)
  7069. {
  7070. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7071. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7072. }
  7073. }
  7074. decimal dac2totalPrice = 0.00M;
  7075. foreach (var dac in dac2)
  7076. {
  7077. if (dac.SubTotal == 0)
  7078. {
  7079. continue;
  7080. }
  7081. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7082. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7083. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7084. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7085. builder.Write(currency);//币种
  7086. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7087. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7088. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7089. builder.Write("");//人数
  7090. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7091. builder.Write("");//天数
  7092. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7093. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7094. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7095. decimal rate = 0.00M;
  7096. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7097. builder.Write(rate.ToString("#0.0000"));//汇率
  7098. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7099. decimal rbmPrice = dac.SubTotal;
  7100. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7101. foodandotherStartIndex++;
  7102. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7103. }
  7104. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7105. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7106. {
  7107. table1.Rows.RemoveAt(i - 1);
  7108. }
  7109. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7110. string otherFeeStr = "";
  7111. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7112. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7113. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7114. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7115. foreach (var otherInfo in dac5)
  7116. {
  7117. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7118. }
  7119. #endregion
  7120. if (otherFeeStr.Length > 0)
  7121. {
  7122. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7123. otherFeeStr = $"({otherFeeStr})";
  7124. dic.Add("OtherFeeStr", otherFeeStr);
  7125. }
  7126. //总计
  7127. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7128. //国际旅费
  7129. string outsideAir = string.Empty;
  7130. string allPriceAir = string.Empty;
  7131. if (_EnterExitCosts.SumJJC == 1)
  7132. {
  7133. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7134. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7135. }
  7136. if (_EnterExitCosts.SumGWC == 1)
  7137. {
  7138. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7139. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7140. }
  7141. if (_EnterExitCosts.SumTDC == 1)
  7142. {
  7143. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7144. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7145. }
  7146. dic.Add("InTravelPrice", $"({outsideAir})");
  7147. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7148. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7149. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7150. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7151. foreach (var key in dic.Keys)
  7152. {
  7153. builder.MoveToBookmark(key);
  7154. builder.Write(dic[key]);
  7155. }
  7156. //模板文件名
  7157. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7158. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7159. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7160. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7161. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7162. }
  7163. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7164. {
  7165. //获取模板
  7166. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7167. //载入模板
  7168. var designer = new WorkbookDesigner
  7169. {
  7170. Workbook = new Workbook(tempPath)
  7171. };
  7172. var dic = new Dictionary<string, string>();
  7173. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7174. {
  7175. var list = new List<string>();
  7176. try
  7177. {
  7178. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7179. foreach (var item in spilitArr)
  7180. {
  7181. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7182. var depCode = spDotandEmpty[2].Substring(0, 3);
  7183. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7184. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7185. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7186. list.Add(depName);
  7187. list.Add(arrName);
  7188. }
  7189. list = list.Distinct().ToList();
  7190. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7191. }
  7192. catch (Exception)
  7193. {
  7194. dic.Add("ReturnCode", "行程录入不正确!");
  7195. }
  7196. }
  7197. else
  7198. {
  7199. dic.Add("ReturnCode", "未录入行程!");
  7200. }
  7201. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7202. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7203. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7204. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7205. {
  7206. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7207. dic.Add("Day", sp.Days.ToString());
  7208. }
  7209. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7210. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7211. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7212. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7213. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7214. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7215. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7216. designer.SetDataSource("Name", Names);
  7217. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7218. designer.SetDataSource("Day", dic["Day"] + "天");
  7219. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7220. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7221. int startIndex = 10;
  7222. const int startIndexcopy = 10;
  7223. if (dac2.Count == dac3.Count)//国家 币种 金额
  7224. {
  7225. for (int i = 0; i < dac2.Count; i++)
  7226. {
  7227. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7228. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7229. }
  7230. }
  7231. var dtdac1 = new DataTable();
  7232. var place = new List<string>();
  7233. dtdac1.Columns.AddRange(new DataColumn[] {
  7234. new(){ ColumnName = "city"},
  7235. new(){ ColumnName = "curr"},
  7236. new(){ ColumnName = "criterion"},
  7237. new(){ ColumnName = "number",DataType = typeof(int)},
  7238. new(){ ColumnName = "day",DataType = typeof(int)},
  7239. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7240. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7241. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7242. });
  7243. var dtdac2 = new DataTable();
  7244. dtdac2.Columns.AddRange(new DataColumn[] {
  7245. new(){ ColumnName = "city"},
  7246. new(){ ColumnName = "curr"},
  7247. new(){ ColumnName = "criterion"},
  7248. new(){ ColumnName = "number",DataType = typeof(int)},
  7249. new(){ ColumnName = "day",DataType = typeof(int)},
  7250. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7251. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7252. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7253. });
  7254. dtdac1.TableName = "tb1";
  7255. dtdac2.TableName = "tb2";
  7256. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7257. foreach (var item in dac1)
  7258. {
  7259. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7260. if (place.Contains(item.Place))
  7261. {
  7262. continue;
  7263. }
  7264. DataRow row = dtdac1.NewRow();
  7265. row["city"] = item.Place;
  7266. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7267. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7268. row["curr"] = currency;
  7269. row["rate"] = rate.ToString("#0.0000");
  7270. row["criterion"] = item.Cost.ToString("#0.00");
  7271. row["number"] = 1;
  7272. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7273. //row["costRMB"] = rbmPrice;
  7274. dtdac1.Rows.Add(row);
  7275. place.Add(item.Place);
  7276. }
  7277. place = new List<string>();
  7278. foreach (var item in dac2)
  7279. {
  7280. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7281. if (place.Contains(item.Place))
  7282. {
  7283. continue;
  7284. }
  7285. DataRow row = dtdac2.NewRow();
  7286. row["city"] = item.Place;
  7287. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7288. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7289. row["curr"] = currency;
  7290. row["rate"] = rate.ToString("#0.0000");
  7291. row["criterion"] = item.Cost.ToString("#0.00");
  7292. row["number"] = 1;
  7293. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7294. //row["cost"] = item.SubTotal;
  7295. //row["costRMB"] = rbmPrice;
  7296. dtdac2.Rows.Add(row);
  7297. place.Add(item.Place);
  7298. //dac2totalPrice += rbmPrice;
  7299. }
  7300. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7301. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7302. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7303. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7304. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7305. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7306. string cell4Str1 = string.Empty;
  7307. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7308. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7309. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7310. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7311. string cellStr = $" 5.其他费用(";
  7312. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7313. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7314. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7315. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7316. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7317. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7318. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7319. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7320. foreach (var otherInfo in dac5)
  7321. {
  7322. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7323. }
  7324. #endregion
  7325. if (cellStr.Length > 8)
  7326. {
  7327. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7328. }
  7329. cellStr += ")";
  7330. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7331. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7332. decimal pxFee = dac4.Sum(it => it.Cost);
  7333. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7334. string celllastStr1 = "";
  7335. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7336. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7337. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7338. celllastStr1 += $",国际旅费 元";
  7339. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7340. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7341. designer.SetDataSource("cell4Str", cell4Str);
  7342. designer.SetDataSource("cellStr", cellStr);
  7343. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7344. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7345. designer.SetDataSource("celllastStr", celllastStr);
  7346. Workbook wb = designer.Workbook;
  7347. var sheet = wb.Worksheets[0];
  7348. //绑定datatable数据集
  7349. designer.SetDataSource(dtdac1);
  7350. designer.SetDataSource(dtdac2);
  7351. designer.Process();
  7352. var rowStart = dtdac1.Rows.Count;
  7353. while (rowStart > 0)
  7354. {
  7355. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7356. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7357. startIndex++;
  7358. rowStart--;
  7359. }
  7360. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7361. startIndex += 1; //总计行
  7362. rowStart = dtdac2.Rows.Count;
  7363. while (rowStart > 0)
  7364. {
  7365. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7366. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7367. startIndex++;
  7368. rowStart--;
  7369. }
  7370. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7371. wb.CalculateFormula(true);
  7372. //模板文件名
  7373. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7374. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7375. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7376. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7377. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7378. }
  7379. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7380. {
  7381. //获取模板
  7382. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7383. //载入模板
  7384. var doc = new Document(tempPath);
  7385. var builder = new DocumentBuilder(doc);
  7386. var dic = new Dictionary<string, string>
  7387. {
  7388. { "GroupName", _DelegationInfo.TeamName },
  7389. { "ClientUnit", _DelegationInfo.ClientUnit }
  7390. };
  7391. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7392. string missionLeaderJob = "";//负责人job
  7393. //int groupNumber = 0; //团人数
  7394. if (DeleClientList.Count > 0)
  7395. {
  7396. missionLeader = DeleClientList[0]?.Name ?? "";
  7397. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7398. }
  7399. dic.Add("MissionLeader", missionLeader); //团负责人
  7400. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7401. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7402. #region MyRegion
  7403. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7404. //{
  7405. // List<string> list = new List<string>();
  7406. // try
  7407. // {
  7408. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7409. // foreach (var item in spilitArr)
  7410. // {
  7411. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7412. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7413. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7414. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7415. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7416. // list.Add(depName);
  7417. // list.Add(arrName);
  7418. // }
  7419. // list = list.Distinct().ToList();
  7420. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7421. // }
  7422. // catch (Exception)
  7423. // {
  7424. // dic.Add("ReturnCode", "行程录入不正确!");
  7425. // }
  7426. //}
  7427. //else
  7428. //{
  7429. // dic.Add("ReturnCode", "未录入行程!");
  7430. //}
  7431. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7432. dic.Add("ReturnCode", string.Join("、", countrys));
  7433. #endregion
  7434. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7435. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7436. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7437. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7438. //{
  7439. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7440. // dic.Add("Day", sp.Days.ToString());
  7441. //}
  7442. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7443. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7444. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7445. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7446. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7447. //培训人员名单
  7448. int cultivateRowIndex = 7;
  7449. foreach (var item in DeleClientList)
  7450. {
  7451. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7452. builder.Write(item.Name);
  7453. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7454. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7455. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7456. string birthDay = "";
  7457. if (item.Birthday != null)
  7458. {
  7459. DateTime dt = Convert.ToDateTime(item.Birthday);
  7460. birthDay = $"{dt.Year}.{dt.Month}";
  7461. }
  7462. builder.Write(birthDay);
  7463. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7464. builder.Write(item.Company);
  7465. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7466. builder.Write(item.Job);
  7467. cultivateRowIndex++;
  7468. }
  7469. //删除多余行
  7470. //cultivateRowIndex -= 2;
  7471. int delRows = 10 + 7 - cultivateRowIndex;
  7472. if (delRows > 0)
  7473. {
  7474. for (int i = 0; i < delRows; i++)
  7475. {
  7476. table1.Rows.RemoveAt(cultivateRowIndex);
  7477. //cultivateRowIndex++;
  7478. }
  7479. }
  7480. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7481. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7482. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7483. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7484. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7485. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7486. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7487. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7488. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7489. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7490. //其他费用
  7491. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7492. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7493. //其他费用合计
  7494. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7495. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7496. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7497. //公务舱合计
  7498. //国际旅费
  7499. //string outsideJJ = "";
  7500. //string allPriceJJ = "";
  7501. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7502. {
  7503. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7504. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7505. }
  7506. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7507. {
  7508. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7509. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7510. }
  7511. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7512. {
  7513. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7514. dic.Add("AirFeeTotal", airFeeTotalStr);
  7515. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7516. dic.Add("FeeTotal", feeTotalStr);
  7517. }
  7518. foreach (var key in dic.Keys)
  7519. {
  7520. builder.MoveToBookmark(key);
  7521. builder.Write(dic[key]);
  7522. }
  7523. //模板文件名
  7524. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7525. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7526. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7527. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7528. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7529. }
  7530. }
  7531. else if (dto.ExportType == 2) //表格
  7532. {
  7533. //利用键值对存放数据
  7534. Dictionary<string, string> dic = new Dictionary<string, string>();
  7535. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7536. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7537. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7538. dic.Add("Day", sp.Days.ToString());
  7539. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7540. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7541. {
  7542. //获取模板
  7543. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7544. //载入模板
  7545. var doc = new Document(tempPath);
  7546. var builder = new DocumentBuilder(doc);
  7547. dic.Add("TeamName", _DelegationInfo.TeamName);
  7548. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7549. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7550. string missionLeaderName = "",
  7551. missionLeaderJob = "";
  7552. if (DeleClientList.Count > 0)
  7553. {
  7554. missionLeaderName = DeleClientList[0].Name;
  7555. missionLeaderJob = DeleClientList[0].Job;
  7556. }
  7557. dic.Add("MissionLeaderName", missionLeaderName);
  7558. dic.Add("MissionLeaderJob", missionLeaderJob);
  7559. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7560. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7561. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7562. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7563. int rowCount = 10;//总人数行
  7564. int startRowIndex = 7; //起始行
  7565. for (int i = 0; i < DeleClientList.Count; i++)
  7566. {
  7567. builder.MoveToCell(0, startRowIndex, 0, 0);
  7568. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7569. builder.MoveToCell(0, startRowIndex, 1, 0);
  7570. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7571. builder.Write(sex);//性别
  7572. builder.MoveToCell(0, startRowIndex, 2, 0);
  7573. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7574. builder.MoveToCell(0, startRowIndex, 3, 0);
  7575. builder.Write(DeleClientList[i].Company);//工作单位
  7576. builder.MoveToCell(0, startRowIndex, 4, 0);
  7577. builder.Write(DeleClientList[i].Job);//职务及级别
  7578. builder.MoveToCell(0, startRowIndex, 5, 0);
  7579. builder.Write("");//人员属性
  7580. builder.MoveToCell(0, startRowIndex, 6, 0);
  7581. builder.Write("");//上次出国时间
  7582. startRowIndex++;
  7583. }
  7584. int nullRow = rowCount - DeleClientList.Count;//空行
  7585. for (int i = 0; i < nullRow; i++)
  7586. {
  7587. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7588. }
  7589. foreach (var key in dic.Keys)
  7590. {
  7591. builder.MoveToBookmark(key);
  7592. builder.Write(dic[key]);
  7593. }
  7594. //模板文件名
  7595. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7596. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7597. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7598. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7599. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7600. }
  7601. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7602. {
  7603. //获取模板
  7604. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7605. //载入模板
  7606. var doc = new Document(tempPath);
  7607. var builder = new DocumentBuilder(doc);
  7608. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7609. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7610. dic.Add("Names", Names);
  7611. int accommodationRows = 12;
  7612. //int foodandotherRows = 12;
  7613. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7614. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7615. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7616. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7617. int accommodationStartIndex = 6;
  7618. decimal dac1totalPrice = 0.00M;
  7619. foreach (var dac in dac1)
  7620. {
  7621. if (dac.SubTotal == 0)
  7622. {
  7623. continue;
  7624. }
  7625. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7626. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7627. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7628. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7629. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7630. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7631. builder.Write(currency);//币种
  7632. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7633. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7634. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7635. builder.Write("");//人数
  7636. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7637. builder.Write("");//天数
  7638. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7639. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7640. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7641. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7642. builder.Write(rate.ToString("#0.0000"));//汇率
  7643. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7644. decimal rbmPrice = rate * dac.SubTotal;
  7645. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7646. accommodationStartIndex++;
  7647. dac1totalPrice += rbmPrice;
  7648. }
  7649. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7650. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7651. builder.Write("小计");
  7652. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7653. builder.Write(dac1totalPrice.ToString("#0.00"));
  7654. accommodationStartIndex++;
  7655. int nullRow = accommodationRows - dac1.Count;
  7656. //删除空行
  7657. //if (nullRow > 0)
  7658. //{
  7659. // int rowIndex = accommodationStartIndex;
  7660. // for (int i = 0; i < nullRow; i++)
  7661. // {
  7662. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7663. // row.Remove();
  7664. // rowIndex++;
  7665. // }
  7666. //}
  7667. if (dac2.Count == dac3.Count)//国家 币种 金额
  7668. {
  7669. for (int i = 0; i < dac2.Count; i++)
  7670. {
  7671. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7672. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7673. }
  7674. }
  7675. int foodandotherStartIndex = 19;//
  7676. decimal dac2totalPrice = 0.00M;
  7677. foreach (var dac in dac2)
  7678. {
  7679. if (dac.SubTotal == 0)
  7680. {
  7681. continue;
  7682. }
  7683. //foodandotherStartIndex = 12;
  7684. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7685. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7686. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7687. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7688. builder.Write(currency);//币种
  7689. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7690. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7691. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7692. builder.Write("");//人数
  7693. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7694. builder.Write("");//天数
  7695. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7696. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7697. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7698. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7699. builder.Write(rate.ToString("#0.0000"));//汇率
  7700. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7701. decimal rbmPrice = rate * dac.SubTotal;
  7702. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7703. foodandotherStartIndex++;
  7704. dac2totalPrice += rbmPrice;
  7705. }
  7706. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7707. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7708. //删除空行
  7709. //if (dac2.Count < foodandotherRows)
  7710. //{
  7711. // while (table2.Rows.Count > dac2.Count)
  7712. // {
  7713. // table2.Rows.RemoveAt(dac2.Count);
  7714. // }
  7715. //}
  7716. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7717. string otherFeeStr = "";
  7718. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7719. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7720. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7721. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7722. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7723. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7724. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7725. foreach (var otherInfo in dac5)
  7726. {
  7727. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7728. }
  7729. #endregion
  7730. if (otherFeeStr.Length > 0)
  7731. {
  7732. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7733. otherFeeStr = $"({otherFeeStr})";
  7734. dic.Add("OtherFeeStr", otherFeeStr);
  7735. }
  7736. foreach (var key in dic.Keys)
  7737. {
  7738. builder.MoveToBookmark(key);
  7739. builder.Write(dic[key]);
  7740. }
  7741. //模板文件名
  7742. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7743. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7744. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7745. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7746. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7747. }
  7748. }
  7749. else if (dto.ExportType == 3)
  7750. {
  7751. if (dto.SubTypeId == 1) //团组成员名单
  7752. {
  7753. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7754. //获取模板
  7755. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7756. //载入模板
  7757. var doc = new Document(tempPath);
  7758. var builder = new DocumentBuilder(doc);
  7759. //获取word里所有表格
  7760. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7761. //获取所填表格的序数
  7762. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7763. var rowStart = tableOne.Rows[0]; //获取第1行
  7764. //循环赋值
  7765. for (int i = 0; i < DeleClientList.Count; i++)
  7766. {
  7767. builder.MoveToCell(0, i + 1, 0, 0);
  7768. builder.Write(DeleClientList[i].Name);
  7769. builder.MoveToCell(0, i + 1, 1, 0);
  7770. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7771. builder.Write(sex);
  7772. builder.MoveToCell(0, i + 1, 2, 0);
  7773. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7774. builder.MoveToCell(0, i + 1, 3, 0);
  7775. builder.Write(DeleClientList[i].Company);
  7776. builder.MoveToCell(0, i + 1, 4, 0);
  7777. builder.Write(DeleClientList[i].Job);
  7778. }
  7779. //删除多余行
  7780. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7781. {
  7782. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7783. }
  7784. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7785. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7786. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7787. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7788. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7789. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7790. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7791. }
  7792. }
  7793. return Ok(JsonView(400, "操作失败!", ""));
  7794. }
  7795. catch (Exception ex)
  7796. {
  7797. return Ok(JsonView(400, ex.Message, ""));
  7798. }
  7799. }
  7800. /// <summary>
  7801. /// 获取三公费用标准city
  7802. /// </summary>
  7803. /// <param name="placeData"></param>
  7804. /// <param name="nationalTravelFeeId"></param>
  7805. /// <returns></returns>
  7806. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7807. {
  7808. string _city = string.Empty;
  7809. if (placeData.Count < 1) return _city;
  7810. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7811. if (data == null) return _city;
  7812. string country = data.Country;
  7813. string city = data.City;
  7814. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7815. else _city = city;
  7816. return _city;
  7817. }
  7818. ///// <summary>
  7819. ///// 团组模块 - 出入境费用 - 明细表导出
  7820. ///// </summary>
  7821. ///// <returns></returns>
  7822. //[HttpPost]
  7823. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7824. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7825. //{
  7826. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7827. // if (data.Code != 0)
  7828. // {
  7829. // return Ok(JsonView(false, data.Msg));
  7830. // }
  7831. // return Ok(JsonView(true, data.Msg, data.Data));
  7832. //}
  7833. /// <summary>
  7834. /// 团组模块 - 出入境费用 - 一键清空
  7835. /// </summary>
  7836. /// <returns></returns>
  7837. [HttpPost]
  7838. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7840. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7841. {
  7842. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7843. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7844. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7845. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7846. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7847. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7848. .SetColumns(x => new Grp_DayOtherPrice
  7849. {
  7850. IsDel = 1,
  7851. DeleteUserId = dto.UserId,
  7852. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7853. })
  7854. .ExecuteCommandAsync();
  7855. if (_view.Code == 0)
  7856. {
  7857. return Ok(JsonView(true, "操作成功"));
  7858. }
  7859. return Ok(JsonView(false, "操作失败"));
  7860. }
  7861. /// <summary>
  7862. /// 团组模块 - 出入境费用 - 子项删除
  7863. /// </summary>
  7864. /// <returns></returns>
  7865. [HttpPost]
  7866. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7868. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7869. {
  7870. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7871. if (data.Code != 0)
  7872. {
  7873. return Ok(JsonView(false, data.Msg));
  7874. }
  7875. return Ok(JsonView(true, "操作成功!", data.Data));
  7876. }
  7877. /// <summary>
  7878. /// 删除三公其他费用
  7879. /// </summary>
  7880. /// <param name="dto"></param>
  7881. /// <returns></returns>
  7882. [HttpPost]
  7883. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7884. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7885. {
  7886. var jw = JsonView(false, "删除失败!");
  7887. var data = new Grp_DayOtherPrice()
  7888. {
  7889. Id = dto.Id,
  7890. IsDel = 1,
  7891. DeleteUserId = dto.DeleteUserId,
  7892. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7893. };
  7894. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7895. if (del > 0)
  7896. {
  7897. jw.Code = 200;
  7898. jw.Msg = "删除成功!";
  7899. }
  7900. return Ok(jw);
  7901. }
  7902. /// <summary>
  7903. /// 团组模块 - 出入境国家费用标准 List
  7904. /// </summary>
  7905. /// <returns></returns>
  7906. [HttpPost]
  7907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7908. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7909. {
  7910. int provinceId = dto.ProvinceId;
  7911. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7912. var nftData = await _sqlSugar
  7913. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7914. JoinType.Left, ntf.Currency == sd1.Id,
  7915. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7916. JoinType.Left, ntf.ProvinceId == c.Id
  7917. ))
  7918. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7919. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7920. {
  7921. Id = ntf.Id,
  7922. ProvinceId = ntf.ProvinceId,
  7923. ProvinceName = c.Name_CN,
  7924. Continent = ntf.Continent,
  7925. Country = ntf.Country,
  7926. City = ntf.City,
  7927. Currency = ntf.Currency,
  7928. CurrencyCode = sd1.Name,
  7929. CurrencyName = sd1.Remark,
  7930. RoomCost = ntf.RoomCost,
  7931. FoodCost = ntf.FoodCost,
  7932. PublicCost = ntf.PublicCost,
  7933. LastUpdateUserId = ntf.LastUpdateUserId,
  7934. LastUpdateUserName = u.CnName,
  7935. LastUpdateTime = ntf.LastUpdateTime
  7936. })
  7937. .ToListAsync();
  7938. return Ok(JsonView(true, "查询成功!", nftData));
  7939. }
  7940. /// <summary>
  7941. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7942. /// </summary>
  7943. /// <returns></returns>
  7944. [HttpPost]
  7945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7946. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7947. {
  7948. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7949. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7950. List<string> countryData = new List<string>();
  7951. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7952. countryData = countryData.Distinct().ToList();
  7953. List<dynamic> dataSource = new List<dynamic>();
  7954. foreach (var item in countryData)
  7955. {
  7956. var cityData1 = new List<string>();
  7957. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7958. var countryData2 = new
  7959. {
  7960. CountryName = item,
  7961. CityData = cityData1
  7962. };
  7963. if (!dataSource.Contains(countryData2))
  7964. {
  7965. dataSource.Add(countryData2);
  7966. }
  7967. }
  7968. return Ok(JsonView(true, "查询成功!", dataSource));
  7969. }
  7970. /// <summary>
  7971. /// 团组模块 - 出入境国家费用标准 Page List
  7972. /// </summary>
  7973. /// <returns></returns>
  7974. [HttpPost]
  7975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7976. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7977. {
  7978. int portId = dto.PortType,
  7979. pageIndex = dto.PageIndex,
  7980. pageSize = dto.PageSize;
  7981. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7982. if (pageIndex == 0) pageIndex = 1;
  7983. if (pageSize == 0) pageSize = 10;
  7984. RefAsync<int> total = 0;
  7985. var nationalTravelFeeData = await _sqlSugar
  7986. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7987. JoinType.Left, ntf.Currency == sd1.Id,
  7988. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7989. JoinType.Left, ntf.ProvinceId == sd2.Id
  7990. ))
  7991. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7992. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7993. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7994. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7995. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7996. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7997. {
  7998. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7999. Id = ntf.Id,
  8000. ProvinceId = ntf.ProvinceId,
  8001. ProvinceName = sd2.Name_CN,
  8002. Continent = ntf.Continent,
  8003. Country = ntf.Country,
  8004. City = ntf.City,
  8005. Currency = ntf.Currency,
  8006. CurrencyCode = sd1.Name,
  8007. CurrencyName = sd1.Remark,
  8008. RoomCost = ntf.RoomCost,
  8009. FoodCost = ntf.FoodCost,
  8010. PublicCost = ntf.PublicCost,
  8011. LastUpdateUserId = ntf.LastUpdateUserId,
  8012. LastUpdateUserName = u.CnName,
  8013. LastUpdateTime = ntf.LastUpdateTime,
  8014. Remark = ntf.Remark
  8015. })
  8016. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8017. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8018. }
  8019. /// <summary>
  8020. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8021. /// </summary>
  8022. /// <returns></returns>
  8023. [HttpPost]
  8024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8025. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8026. {
  8027. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8028. int portId = dto.PortType;
  8029. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8030. string whereSql = string.Empty;
  8031. if (!string.IsNullOrEmpty(dto.Country))
  8032. {
  8033. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8034. }
  8035. if (!string.IsNullOrEmpty(dto.City))
  8036. {
  8037. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8038. }
  8039. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8040. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8041. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8042. From Grp_NationalTravelFee gntf
  8043. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8044. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8045. Where gntf.Isdel = 0 {0} ", whereSql);
  8046. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8047. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8048. }
  8049. /// <summary>
  8050. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8051. /// </summary>
  8052. /// <returns></returns>
  8053. [HttpPost]
  8054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8055. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8056. {
  8057. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8058. }
  8059. /// <summary>
  8060. /// 团组模块 - 出入境国家费用标准 - Del
  8061. /// </summary>
  8062. /// <returns></returns>
  8063. [HttpPost]
  8064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8065. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8066. {
  8067. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8068. {
  8069. Id = dto.Id,
  8070. DeleteUserId = dto.DeleteUserId,
  8071. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8072. IsDel = 1
  8073. };
  8074. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8075. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8076. .WhereColumns(it => new { it.Id })
  8077. .ExecuteCommandAsync();
  8078. if (delStatus <= 0)
  8079. {
  8080. return Ok(JsonView(false, "删除失败!"));
  8081. }
  8082. return Ok(JsonView(true, "操作成功!"));
  8083. }
  8084. /// <summary>
  8085. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8086. /// 注:Get 请求Headers 加 Token
  8087. /// </summary>
  8088. /// <param name="groupId"></param>
  8089. /// <returns></returns>
  8090. [HttpGet("{groupId}")]
  8091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8092. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8093. {
  8094. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8095. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8096. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8097. data.ForEach(x =>
  8098. {
  8099. x.CreateUserId = _currUserInfo.UserId;
  8100. });
  8101. if (data.Any())
  8102. {
  8103. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8104. if (add > 0)
  8105. {
  8106. return Ok(JsonView(true, "操作成功!"));
  8107. }
  8108. }
  8109. return Ok(JsonView(false, "未操作!"));
  8110. }
  8111. #endregion
  8112. #region 团组经理模块 出入境费用-草稿
  8113. /// <summary>
  8114. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8115. /// </summary>
  8116. /// <returns></returns>
  8117. [HttpGet]
  8118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8119. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8120. {
  8121. var provData = await _groupRepository.ProvinceBasicSource();
  8122. return Ok(JsonView(true, "查询成功!", provData));
  8123. }
  8124. /// <summary>
  8125. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8126. /// </summary>
  8127. /// <returns></returns>
  8128. [HttpGet("{provinceId}")]
  8129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8130. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8131. {
  8132. //验证城市归属并给默认值
  8133. if (provinceId < 1) provinceId = 122;
  8134. /*
  8135. * 122 四川
  8136. * 108 贵州
  8137. * 103 重庆
  8138. * 132 云南
  8139. */
  8140. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8141. return Ok(JsonView(true, "查询成功!", new
  8142. {
  8143. WordTypeData = wordTypeData,
  8144. ExcelTypeData = excelTypeData,
  8145. }));
  8146. }
  8147. /// <summary>
  8148. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8149. /// </summary>
  8150. /// <returns></returns>
  8151. [HttpPost]
  8152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8153. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8154. {
  8155. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8156. .Where(x => x.IsDel == 0)
  8157. .OrderByDescending(x => x.CreateTime)
  8158. .Select(x => new { x.Id, x.DraftName })
  8159. .ToListAsync();
  8160. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8161. //SetDataInfoView
  8162. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8163. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8164. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8165. int provinceId = dto.ProvinceId;
  8166. if (provinceId < 1) provinceId = 122;
  8167. /*
  8168. * 122 四川
  8169. * 108 贵州
  8170. * 103 重庆
  8171. * 132 云南
  8172. */
  8173. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8174. //默认币种显示
  8175. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8176. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8177. return Ok(JsonView(true, "查询成功!", new
  8178. {
  8179. DraftNameDatas = draftNameDatas,
  8180. CurrencyData = _CurrencyData,
  8181. WordTypeData = wordTypeData,
  8182. ExcelTypeData = excelTypeData,
  8183. CurrencyInit = _currencyInfos,
  8184. ViewPermissionData = viewPermissionData
  8185. }));
  8186. }
  8187. /// <summary>
  8188. /// 团组模块 - 出入境费用-草稿
  8189. /// 实时汇率 tips
  8190. /// 机票费用 tips
  8191. /// </summary>
  8192. /// <returns></returns>
  8193. [HttpPost]
  8194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8195. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8196. {
  8197. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8198. return Ok(JsonView(true, "查询成功!", new
  8199. {
  8200. //GroupNameData = groupNameData.Data,
  8201. //visaData = visaData.Data,
  8202. //airData = airData.Data,
  8203. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8204. }));
  8205. }
  8206. /// <summary>
  8207. /// 团组模块 - 出入境费用-草稿
  8208. /// 签证费用 tips
  8209. /// </summary>
  8210. /// <returns></returns>
  8211. [HttpPost]
  8212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8213. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8214. {
  8215. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8216. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8217. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8218. .Select(x => x.NationalTravelFeeId)
  8219. .Distinct()
  8220. .ToListAsync();
  8221. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8222. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8223. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8224. .Select(x => x.Country)
  8225. .Distinct()
  8226. .ToArrayAsync();
  8227. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8228. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8229. return Ok(JsonView(true, "查询成功!", new
  8230. {
  8231. totalAmt,
  8232. remark
  8233. }));
  8234. }
  8235. /// <summary>
  8236. /// 团组模块 - 出入境费用-草稿 - Info
  8237. /// </summary>
  8238. /// <returns></returns>
  8239. [HttpPost]
  8240. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8242. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8243. {
  8244. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8245. }
  8246. /// <summary>
  8247. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8248. /// </summary>
  8249. /// <returns></returns>
  8250. [HttpPost]
  8251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8252. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8253. {
  8254. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8255. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8256. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8257. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8258. foreach (var userId in dto.UserIds)
  8259. {
  8260. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8261. }
  8262. if (permissions.Any())
  8263. {
  8264. _sqlSugar.BeginTran();
  8265. try
  8266. {
  8267. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8268. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8269. if (result < 1)
  8270. {
  8271. _sqlSugar.RollbackTran();
  8272. return Ok(JsonView(false));
  8273. }
  8274. }
  8275. catch (Exception ex)
  8276. {
  8277. _sqlSugar.RollbackTran();
  8278. return Ok(JsonView(false, ex.Message));
  8279. }
  8280. _sqlSugar.CommitTran();
  8281. return Ok(JsonView(true));
  8282. }
  8283. return Ok(JsonView(false));
  8284. }
  8285. /// <summary>
  8286. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8287. /// </summary>
  8288. /// <returns></returns>
  8289. [HttpPost]
  8290. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8292. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8293. {
  8294. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8295. if (data.Code != 0)
  8296. {
  8297. return Ok(JsonView(false, data.Msg));
  8298. }
  8299. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8300. //汇率信息记录
  8301. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8302. return Ok(JsonView(true, data.Msg, data.Data));
  8303. }
  8304. /// <summary>
  8305. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8306. /// </summary>
  8307. /// <param name="dto"></param>
  8308. /// <returns></returns>
  8309. [HttpPost]
  8310. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8312. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8313. {
  8314. try
  8315. {
  8316. var id = dto.Id;
  8317. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8318. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8319. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8320. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8321. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8322. 3 团组成员名单 1 团组成员名单", ""));
  8323. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8324. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8325. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8326. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8327. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8328. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8329. //数据源
  8330. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8331. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8332. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8333. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8334. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8335. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8336. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8337. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8338. .Select((x, a, b) => new
  8339. {
  8340. x.Index,
  8341. itemName = a.Name,
  8342. CurrencyStr = b.Name,
  8343. x.Cost,
  8344. x.SubTotal,
  8345. x.Remark
  8346. })
  8347. .OrderBy((x) => x.Index)
  8348. .ToList(); //其他款项费用
  8349. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8350. var peiceItemCurrencys = new List<string>();
  8351. if (_DayAndCosts.Any())
  8352. {
  8353. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8354. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8355. }
  8356. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8357. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8358. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8359. {
  8360. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8361. }
  8362. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8363. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8364. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8365. if (dto.ExportType == 1) //明细表
  8366. {
  8367. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8368. {
  8369. //获取模板
  8370. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8371. //载入模板
  8372. Document doc = new Document(tempPath);
  8373. DocumentBuilder builder = new DocumentBuilder(doc);
  8374. //利用键值对存放数据
  8375. Dictionary<string, string> dic = new Dictionary<string, string>();
  8376. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8377. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8378. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8379. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8380. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8381. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8382. //境内费用(其他费用)
  8383. if (_EnterExitCosts.ChoiceOne == 1)
  8384. {
  8385. string row1_1 = "";
  8386. if (_EnterExitCosts.Visa > 0)
  8387. {
  8388. //insidePayTotal += _EnterExitCosts.Visa;
  8389. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8390. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8391. //{
  8392. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8393. //}
  8394. }
  8395. string row1_2 = "";
  8396. if (_EnterExitCosts.YiMiao > 0)
  8397. {
  8398. //insidePayTotal += _EnterExitCosts.YiMiao;
  8399. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8400. }
  8401. if (_EnterExitCosts.HeSuan > 0)
  8402. {
  8403. //insidePayTotal += _EnterExitCosts.HeSuan;
  8404. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8405. }
  8406. if (_EnterExitCosts.Service > 0)
  8407. {
  8408. //insidePayTotal += _EnterExitCosts.Service;
  8409. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8410. }
  8411. string row1_3 = "";
  8412. if (_EnterExitCosts.Safe > 0)
  8413. {
  8414. //insidePayTotal += _EnterExitCosts.Safe;
  8415. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8416. }
  8417. if (_EnterExitCosts.Ticket > 0)
  8418. {
  8419. //insidePayTotal += _EnterExitCosts.Ticket;
  8420. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8421. }
  8422. string row1 = "";
  8423. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8424. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8425. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8426. row1 += $"备注:{_EnterExitCosts.Remark}";
  8427. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8428. dic.Add("Row1Str", row1);
  8429. }
  8430. string airTotalStr = string.Empty,
  8431. airPriceStr = string.Empty;
  8432. //经济舱
  8433. if (_EnterExitCosts.SumJJC == 1)
  8434. {
  8435. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8436. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8437. }
  8438. //公务舱
  8439. if (_EnterExitCosts.SumGWC == 1)
  8440. {
  8441. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8442. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8443. }
  8444. //头等舱
  8445. if (_EnterExitCosts.SumTDC == 1)
  8446. {
  8447. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8448. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8449. }
  8450. //汇率描述
  8451. string rateStr = "";
  8452. if (peiceItemCurrencyInfos.Any())
  8453. {
  8454. rateStr = "\r\n汇率描述:";
  8455. foreach (var item in peiceItemCurrencyInfos)
  8456. {
  8457. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8458. }
  8459. }
  8460. string twoItemRemark = "备注:";
  8461. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8462. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8463. dic.Add("AirTotalStr", airTotalStr);
  8464. dic.Add("AirPriceStr", airPriceStr);
  8465. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8466. dic.Add("TwoItemRemark", twoItemRemark);
  8467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8468. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8469. int table1Row = 0,
  8470. table2Row = 0,
  8471. table3Row = 0,
  8472. table4Row = 0,
  8473. table5Row = 0;
  8474. //住宿费
  8475. if (_EnterExitCosts.ChoiceThree == 1)
  8476. {
  8477. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8478. table1Row = dac1.Count;
  8479. #region 填充word表格内容
  8480. for (int i = 0; i < dac1.Count; i++)
  8481. {
  8482. var dac = dac1[i];
  8483. if (dac == null) continue;
  8484. builder.MoveToCell(0, i, 0, 0);
  8485. builder.Write("第" + dac.Days.ToString() + "晚:");
  8486. builder.MoveToCell(0, i, 1, 0);
  8487. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8488. //builder.Write(dac.Place == null ? "" : dac.Place);
  8489. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8490. builder.MoveToCell(0, i, 2, 0);
  8491. builder.Write("费用标准:");
  8492. string curr = "";
  8493. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8494. if (currData != null)
  8495. {
  8496. curr = currData.Name;
  8497. }
  8498. builder.MoveToCell(0, i, 3, 0);
  8499. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8500. builder.MoveToCell(0, i, 4, 0);
  8501. builder.Write("费用小计:");
  8502. builder.MoveToCell(0, i, 5, 0);
  8503. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8504. }
  8505. #endregion
  8506. }
  8507. else dic.Add("SubZS", "0.00");
  8508. //删除多余行
  8509. while (table1.Rows.Count > table1Row)
  8510. {
  8511. table1.Rows.RemoveAt(table1Row);
  8512. }
  8513. //伙食费
  8514. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8515. if (_EnterExitCosts.ChoiceFour == 1)
  8516. {
  8517. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8518. table2Row = dac2.Count;
  8519. #region 填充word表格内容
  8520. for (int i = 0; i < dac2.Count; i++)
  8521. {
  8522. var dac = dac2[i];
  8523. if (dac == null) continue;
  8524. builder.MoveToCell(1, i, 0, 0);
  8525. builder.Write("第" + dac.Days.ToString() + "天:");
  8526. builder.MoveToCell(1, i, 1, 0);
  8527. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8528. builder.MoveToCell(1, i, 2, 0);
  8529. builder.Write("费用标准:");
  8530. string curr = "";
  8531. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8532. if (currData != null)
  8533. {
  8534. curr = currData.Name;
  8535. }
  8536. builder.MoveToCell(1, i, 3, 0);
  8537. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8538. builder.MoveToCell(1, i, 4, 0);
  8539. builder.Write("费用小计:");
  8540. builder.MoveToCell(1, i, 5, 0);
  8541. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8542. }
  8543. #endregion
  8544. }
  8545. else dic.Add("SubHS", "0.00");
  8546. //删除多余行
  8547. while (table2.Rows.Count > table2Row)
  8548. {
  8549. table2.Rows.RemoveAt(table2Row);
  8550. }
  8551. //公杂费
  8552. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8553. if (_EnterExitCosts.ChoiceFive == 1)
  8554. {
  8555. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8556. table3Row = dac3.Count;
  8557. #region 填充word表格内容
  8558. for (int i = 0; i < dac3.Count; i++)
  8559. {
  8560. var dac = dac3[i];
  8561. if (dac == null) continue;
  8562. builder.MoveToCell(2, i, 0, 0);
  8563. builder.Write("第" + dac.Days.ToString() + "天:");
  8564. builder.MoveToCell(2, i, 1, 0);
  8565. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8566. builder.MoveToCell(2, i, 2, 0);
  8567. builder.Write("费用标准:");
  8568. string curr = "";
  8569. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8570. if (currData != null)
  8571. {
  8572. curr = currData.Name;
  8573. }
  8574. builder.MoveToCell(2, i, 3, 0);
  8575. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8576. builder.MoveToCell(2, i, 4, 0);
  8577. builder.Write("费用小计:");
  8578. builder.MoveToCell(2, i, 5, 0);
  8579. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8580. }
  8581. //删除多余行
  8582. while (table3.Rows.Count > table3Row)
  8583. {
  8584. table3.Rows.RemoveAt(table3Row);
  8585. }
  8586. #endregion
  8587. }
  8588. else dic.Add("SubGZF", "0.00");
  8589. //删除多余行
  8590. while (table3.Rows.Count > table3Row)
  8591. {
  8592. table3.Rows.RemoveAt(table3Row);
  8593. }
  8594. //培训费
  8595. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8596. if (_EnterExitCosts.ChoiceSix == 1)
  8597. {
  8598. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8599. dic.Add("SubPX", pxStr);
  8600. table4Row = dac4.Count;
  8601. #region 填充word表格内容
  8602. for (int i = 0; i < dac4.Count; i++)
  8603. {
  8604. var dac = dac4[i];
  8605. if (dac == null) continue;
  8606. builder.MoveToCell(3, i, 0, 0);
  8607. builder.Write("第" + dac.Days.ToString() + "天:");
  8608. builder.MoveToCell(3, i, 1, 0);
  8609. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8610. builder.MoveToCell(3, i, 2, 0);
  8611. builder.Write("费用标准:");
  8612. string curr = "";
  8613. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8614. if (currData != null)
  8615. {
  8616. curr = currData.Name;
  8617. }
  8618. builder.MoveToCell(3, i, 3, 0);
  8619. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8620. builder.MoveToCell(3, i, 4, 0);
  8621. builder.Write("费用小计:");
  8622. builder.MoveToCell(3, i, 5, 0);
  8623. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8624. }
  8625. #endregion
  8626. }
  8627. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8628. //删除多余行
  8629. while (table4.Rows.Count > table4Row)
  8630. {
  8631. table4.Rows.RemoveAt(table4Row);
  8632. }
  8633. //其他费用
  8634. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8635. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8636. {
  8637. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8638. dic.Add("titleQi", qtStr);
  8639. table5Row = dac5.Count;
  8640. #region 填充word表格内容
  8641. for (int i = 0; i < dac5.Count; i++)
  8642. {
  8643. var dac = dac5[i];
  8644. if (dac == null) continue;
  8645. builder.MoveToCell(4, i, 0, 0);
  8646. builder.Write("第" + dac.Index.ToString() + "项:");
  8647. builder.MoveToCell(4, i, 1, 0);
  8648. builder.Write(dac.itemName);
  8649. builder.MoveToCell(4, i, 2, 0);
  8650. builder.Write("费用标准:");
  8651. builder.MoveToCell(4, i, 3, 0);
  8652. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8653. builder.MoveToCell(4, i, 4, 0);
  8654. builder.Write("费用小计:");
  8655. builder.MoveToCell(4, i, 5, 0);
  8656. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8657. builder.MoveToCell(4, i, 6, 0);
  8658. builder.Write("备注:");
  8659. builder.MoveToCell(4, i, 7, 0);
  8660. builder.Write(dac.Remark);
  8661. }
  8662. #endregion
  8663. }
  8664. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8665. //删除多余行
  8666. while (table5.Rows.Count > table5Row)
  8667. {
  8668. table5.Rows.RemoveAt(table5Row);
  8669. }
  8670. //加上其他费用
  8671. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8672. decimal subJJC = 0.00M,
  8673. subGWC = 0.00M,
  8674. subTDC = 0.00M;
  8675. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8676. string totalLabel = string.Format("全部费用总计:");
  8677. //经济舱
  8678. if (_EnterExitCosts.SumJJC == 1)
  8679. {
  8680. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8681. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8682. }
  8683. //公务舱
  8684. if (_EnterExitCosts.SumGWC == 1)
  8685. {
  8686. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8687. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8688. }
  8689. //头等舱
  8690. if (_EnterExitCosts.SumTDC == 1)
  8691. {
  8692. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8693. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8694. }
  8695. //TotalLabel
  8696. dic.Add("TotalLabel", totalLabel);
  8697. #region 填充word模板书签内容
  8698. foreach (var key in dic.Keys)
  8699. {
  8700. Bookmark bookmark = doc.Range.Bookmarks[key];
  8701. if (bookmark != null)
  8702. {
  8703. builder.MoveToBookmark(key);
  8704. builder.Write(dic[key]);
  8705. }
  8706. }
  8707. #endregion
  8708. //文件名
  8709. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8710. strFileName = CommonFun.ValidFileName(strFileName);
  8711. AsposeHelper.removewatermark_v2180();
  8712. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8713. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8714. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8715. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8716. }
  8717. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8718. {
  8719. //获取模板
  8720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8721. //载入模板
  8722. Document doc = new Document(tempPath);
  8723. DocumentBuilder builder = new DocumentBuilder(doc);
  8724. Dictionary<string, string> dic = new Dictionary<string, string>();
  8725. string returnCodeLabel = string.Empty;
  8726. if (nationalTravelFeeData.Any())
  8727. {
  8728. List<string> list = new List<string>();
  8729. foreach (var item in nationalTravelFeeData)
  8730. {
  8731. list.Add($"{item.Country}({item.City})");
  8732. }
  8733. list = list.Distinct().ToList();
  8734. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8735. }
  8736. var countryLabel = string.Empty;
  8737. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8738. if (countryData.Any())
  8739. {
  8740. countryLabel = string.Join("、", countryData);
  8741. }
  8742. dic.Add("ReturnCodeAir", returnCodeLabel);
  8743. dic.Add("VisitStartDate", "-");
  8744. dic.Add("VisitEndDate", "-");
  8745. dic.Add("Day", "-");
  8746. dic.Add("VisitCountry", countryLabel);
  8747. dic.Add("ClientUnit", "-");
  8748. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8749. //dic.Add("Names", Names);
  8750. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8751. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8752. decimal dac1totalPrice = 0.00M;
  8753. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8754. foreach (var dac in dac1)
  8755. {
  8756. if (dac.SubTotal == 0.00M)
  8757. {
  8758. continue;
  8759. }
  8760. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8761. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8762. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8763. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8764. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8765. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8766. builder.Write(currency);//币种
  8767. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8768. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8769. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8770. builder.Write("");//人数
  8771. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8772. builder.Write("");//天数
  8773. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8774. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8775. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8776. decimal rate = 0.00M;
  8777. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8778. builder.Write(rate.ToString("#0.0000"));//汇率
  8779. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8780. decimal rbmPrice = dac.SubTotal;
  8781. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8782. accommodationStartIndex++;
  8783. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8784. }
  8785. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8786. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8787. {
  8788. table1.Rows.RemoveAt(i - 1);
  8789. foodandotherStartIndex--;
  8790. }
  8791. if (dac2.Count == dac3.Count)//国家 币种 金额
  8792. {
  8793. for (int i = 0; i < dac2.Count; i++)
  8794. {
  8795. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8796. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8797. }
  8798. }
  8799. decimal dac2totalPrice = 0.00M;
  8800. foreach (var dac in dac2)
  8801. {
  8802. if (dac.SubTotal == 0)
  8803. {
  8804. continue;
  8805. }
  8806. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8807. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8808. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8809. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8810. builder.Write(currency);//币种
  8811. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8812. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8813. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8814. builder.Write("");//人数
  8815. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8816. builder.Write("");//天数
  8817. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8818. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8819. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8820. decimal rate = 0.00M;
  8821. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8822. builder.Write(rate.ToString("#0.0000"));//汇率
  8823. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8824. decimal rbmPrice = dac.SubTotal;
  8825. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8826. foodandotherStartIndex++;
  8827. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8828. }
  8829. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8830. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8831. {
  8832. table1.Rows.RemoveAt(i - 1);
  8833. }
  8834. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8835. string otherFeeStr = "";
  8836. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8837. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8838. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8839. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8840. foreach (var otherInfo in dac5)
  8841. {
  8842. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8843. }
  8844. #endregion
  8845. if (otherFeeStr.Length > 0)
  8846. {
  8847. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8848. otherFeeStr = $"({otherFeeStr})";
  8849. dic.Add("OtherFeeStr", otherFeeStr);
  8850. }
  8851. //总计
  8852. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8853. //国际旅费
  8854. string outsideAir = string.Empty;
  8855. string allPriceAir = string.Empty;
  8856. if (_EnterExitCosts.SumJJC == 1)
  8857. {
  8858. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8859. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8860. }
  8861. if (_EnterExitCosts.SumGWC == 1)
  8862. {
  8863. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8864. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8865. }
  8866. if (_EnterExitCosts.SumTDC == 1)
  8867. {
  8868. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8869. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8870. }
  8871. dic.Add("InTravelPrice", $"({outsideAir})");
  8872. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8873. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8874. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8875. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8876. foreach (var key in dic.Keys)
  8877. {
  8878. builder.MoveToBookmark(key);
  8879. builder.Write(dic[key]);
  8880. }
  8881. //模板文件名
  8882. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8883. strFileName = CommonFun.ValidFileName(strFileName);
  8884. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8885. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8886. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8887. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8888. }
  8889. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8890. {
  8891. //获取模板
  8892. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8893. //载入模板
  8894. WorkbookDesigner designer = new WorkbookDesigner();
  8895. designer.Workbook = new Workbook(tempPath);
  8896. Dictionary<string, string> dic = new Dictionary<string, string>();
  8897. string returnCodeLabel = string.Empty;
  8898. if (nationalTravelFeeData.Any())
  8899. {
  8900. List<string> list = new List<string>();
  8901. foreach (var item in nationalTravelFeeData)
  8902. {
  8903. list.Add($"{item.Country}({item.City})");
  8904. }
  8905. list = list.Distinct().ToList();
  8906. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8907. }
  8908. var countryLabel = string.Empty;
  8909. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8910. if (countryData.Any())
  8911. {
  8912. countryLabel = string.Join("、", countryData);
  8913. }
  8914. dic.Add("ReturnCodeAir", returnCodeLabel);
  8915. dic.Add("VisitStartDate", "-");
  8916. dic.Add("VisitEndDate", "-");
  8917. dic.Add("Day", "0");
  8918. dic.Add("VisitCountry", countryLabel);
  8919. dic.Add("ClientUnit", "-");
  8920. designer.SetDataSource("ClientUnit", "-");
  8921. designer.SetDataSource("VisitCountry", countryLabel);
  8922. designer.SetDataSource("Group", "-");
  8923. designer.SetDataSource("ClientUnitTitle", "-");
  8924. designer.SetDataSource("Name", "-");
  8925. designer.SetDataSource("VisitStartDate", "-");
  8926. designer.SetDataSource("Day", "0");
  8927. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8928. designer.SetDataSource("ReturnCodeAir", "-");
  8929. int startIndex = 10;
  8930. const int startIndexcopy = 10;
  8931. if (dac2.Count == dac3.Count)//国家 币种 金额
  8932. {
  8933. for (int i = 0; i < dac2.Count; i++)
  8934. {
  8935. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8936. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8937. }
  8938. }
  8939. DataTable dtdac1 = new DataTable();
  8940. List<string> place = new List<string>();
  8941. dtdac1.Columns.AddRange(new DataColumn[] {
  8942. new DataColumn(){ ColumnName = "city"},
  8943. new DataColumn(){ ColumnName = "curr"},
  8944. new DataColumn(){ ColumnName = "criterion"},
  8945. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8946. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8947. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8948. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8949. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8950. });
  8951. DataTable dtdac2 = new DataTable();
  8952. dtdac2.Columns.AddRange(new DataColumn[] {
  8953. new DataColumn(){ ColumnName = "city"},
  8954. new DataColumn(){ ColumnName = "curr"},
  8955. new DataColumn(){ ColumnName = "criterion"},
  8956. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8957. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8958. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8959. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8960. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8961. });
  8962. dtdac1.TableName = "tb1";
  8963. dtdac2.TableName = "tb2";
  8964. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8965. foreach (var item in dac1)
  8966. {
  8967. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8968. if (place.Contains(item.Place))
  8969. {
  8970. continue;
  8971. }
  8972. DataRow row = dtdac1.NewRow();
  8973. row["city"] = item.Place;
  8974. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8975. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8976. row["curr"] = currency;
  8977. row["rate"] = rate.ToString("#0.0000");
  8978. row["criterion"] = item.Cost.ToString("#0.00");
  8979. row["number"] = 1;
  8980. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8981. //row["costRMB"] = rbmPrice;
  8982. dtdac1.Rows.Add(row);
  8983. place.Add(item.Place);
  8984. }
  8985. place = new List<string>();
  8986. foreach (var item in dac2)
  8987. {
  8988. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8989. if (place.Contains(item.Place))
  8990. {
  8991. continue;
  8992. }
  8993. DataRow row = dtdac2.NewRow();
  8994. row["city"] = item.Place;
  8995. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8996. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8997. row["curr"] = currency;
  8998. row["rate"] = rate.ToString("#0.0000");
  8999. row["criterion"] = item.Cost.ToString("#0.00");
  9000. row["number"] = 1;
  9001. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9002. //row["cost"] = item.SubTotal;
  9003. //row["costRMB"] = rbmPrice;
  9004. dtdac2.Rows.Add(row);
  9005. place.Add(item.Place);
  9006. //dac2totalPrice += rbmPrice;
  9007. }
  9008. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9009. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9010. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9011. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9012. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9013. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9014. string cell4Str1 = string.Empty;
  9015. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9016. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9017. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9018. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9019. string cellStr = $" 5.其他费用(";
  9020. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9021. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9022. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9023. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9024. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9025. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9026. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9027. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9028. foreach (var otherInfo in dac5)
  9029. {
  9030. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9031. }
  9032. #endregion
  9033. if (cellStr.Length > 8)
  9034. {
  9035. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9036. }
  9037. cellStr += ")";
  9038. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9039. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9040. decimal pxFee = dac4.Sum(it => it.Cost);
  9041. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9042. string celllastStr1 = "";
  9043. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9044. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9045. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9046. celllastStr1 += $",国际旅费 元";
  9047. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9048. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9049. designer.SetDataSource("cell4Str", cell4Str);
  9050. designer.SetDataSource("cellStr", cellStr);
  9051. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9052. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9053. designer.SetDataSource("celllastStr", celllastStr);
  9054. Workbook wb = designer.Workbook;
  9055. var sheet = wb.Worksheets[0];
  9056. //绑定datatable数据集
  9057. designer.SetDataSource(dtdac1);
  9058. designer.SetDataSource(dtdac2);
  9059. designer.Process();
  9060. var rowStart = dtdac1.Rows.Count;
  9061. while (rowStart > 0)
  9062. {
  9063. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9064. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9065. startIndex++;
  9066. rowStart--;
  9067. }
  9068. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9069. startIndex += 1; //总计行
  9070. rowStart = dtdac2.Rows.Count;
  9071. while (rowStart > 0)
  9072. {
  9073. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9074. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9075. startIndex++;
  9076. rowStart--;
  9077. }
  9078. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9079. wb.CalculateFormula(true);
  9080. //模板文件名
  9081. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9082. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9083. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9084. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9085. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9086. }
  9087. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9088. {
  9089. //获取模板
  9090. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9091. //载入模板
  9092. Document doc = new Document(tempPath);
  9093. DocumentBuilder builder = new DocumentBuilder(doc);
  9094. Dictionary<string, string> dic = new Dictionary<string, string>();
  9095. dic.Add("GroupName", "-");
  9096. dic.Add("ClientUnit", "-");
  9097. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9098. //string missionLeaderJob = "";//负责人job
  9099. //int groupNumber = 0; //团人数
  9100. dic.Add("MissionLeader", "-"); //团负责人
  9101. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9102. dic.Add("GroupNumber", "0"); //团人数
  9103. dic.Add("Day", "0");
  9104. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9105. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9106. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9107. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9108. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9109. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9110. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9111. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9112. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9113. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9114. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9115. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9116. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9117. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9118. //其他费用
  9119. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9120. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9121. //其他费用合计
  9122. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9123. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9124. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9125. //公务舱合计
  9126. //国际旅费
  9127. //string outsideJJ = "";
  9128. //string allPriceJJ = "";
  9129. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9130. {
  9131. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9132. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9133. }
  9134. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9135. {
  9136. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9137. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9138. }
  9139. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9140. {
  9141. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9142. dic.Add("AirFeeTotal", airFeeTotalStr);
  9143. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9144. dic.Add("FeeTotal", feeTotalStr);
  9145. }
  9146. foreach (var key in dic.Keys)
  9147. {
  9148. builder.MoveToBookmark(key);
  9149. builder.Write(dic[key]);
  9150. }
  9151. //模板文件名
  9152. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9153. strFileName = CommonFun.ValidFileName(strFileName);
  9154. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9155. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9156. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9157. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9158. }
  9159. }
  9160. else if (dto.ExportType == 2) //表格
  9161. {
  9162. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9163. }
  9164. else if (dto.ExportType == 3)
  9165. {
  9166. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9167. }
  9168. return Ok(JsonView(400, "只可导出明细表!", ""));
  9169. }
  9170. catch (Exception ex)
  9171. {
  9172. return Ok(JsonView(400, ex.Message, ""));
  9173. }
  9174. }
  9175. /// <summary>
  9176. /// 获取三公费用标准city
  9177. /// </summary>
  9178. /// <param name="placeData"></param>
  9179. /// <param name="nationalTravelFeeId"></param>
  9180. /// <returns></returns>
  9181. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9182. {
  9183. string _city = string.Empty;
  9184. if (!placeData.Any()) return _city;
  9185. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9186. if (data == null) return _city;
  9187. string country = data.Country;
  9188. string city = data.City;
  9189. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9190. else _city = city;
  9191. return _city;
  9192. }
  9193. /// <summary>
  9194. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9195. /// </summary>
  9196. /// <returns></returns>
  9197. [HttpPost]
  9198. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9200. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9201. {
  9202. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9203. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9204. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9205. if (_view.Code == 0)
  9206. {
  9207. return Ok(JsonView(true, "操作成功"));
  9208. }
  9209. return Ok(JsonView(false, "操作失败"));
  9210. }
  9211. /// <summary>
  9212. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9213. /// </summary>
  9214. /// <returns></returns>
  9215. [HttpPost]
  9216. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9218. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9219. {
  9220. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9221. if (data.Code != 0)
  9222. {
  9223. return Ok(JsonView(false, data.Msg));
  9224. }
  9225. return Ok(JsonView(true, "操作成功!", data.Data));
  9226. }
  9227. /// <summary>
  9228. /// 三公其他费用草稿 删除
  9229. /// </summary>
  9230. /// <param name="dto"></param>
  9231. /// <returns></returns>
  9232. [HttpPost]
  9233. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9234. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9235. {
  9236. var jw = JsonView(false, "删除失败!");
  9237. var data = new Grp_DayOtherPriceDraft()
  9238. {
  9239. Id = dto.Id,
  9240. IsDel = 1,
  9241. DeleteUserId = dto.DeleteUserId,
  9242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9243. };
  9244. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9245. if (del > 0)
  9246. {
  9247. jw.Code = 200;
  9248. jw.Msg = "删除成功!";
  9249. }
  9250. return Ok(jw);
  9251. }
  9252. /// <summary>
  9253. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9254. /// </summary>
  9255. /// <returns></returns>
  9256. [HttpPost]
  9257. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9258. {
  9259. var jw = JsonView(false);
  9260. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9261. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9262. jw.Code = StatusCodes.Status200OK;
  9263. jw.Msg = "操作成功!";
  9264. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9265. return Ok(jw);
  9266. }
  9267. /// <summary>
  9268. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9269. /// </summary>
  9270. /// <param name="dto"></param>
  9271. /// <returns></returns>
  9272. [HttpPost]
  9273. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9274. {
  9275. int userId = dto.UserId,
  9276. portId = dto.PortType,
  9277. groupId = dto.GroupId,
  9278. draftId = dto.DraftId;
  9279. _portTypeData.Add(1);
  9280. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9281. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9282. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9283. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9284. _sqlSugar.BeginTran();
  9285. try
  9286. {
  9287. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9288. if (draftDatas == null)
  9289. {
  9290. _sqlSugar.RollbackTran();
  9291. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9292. }
  9293. //验证可覆盖已有数据 两边创建人需为同一人;
  9294. int draftCreateUserId = draftDatas.CreateUserId,
  9295. formalCreateUserId = 0;
  9296. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9297. if (formalData != null)
  9298. {
  9299. formalCreateUserId = formalData.CreateUserId;
  9300. if (draftCreateUserId != formalCreateUserId)
  9301. {
  9302. _sqlSugar.RollbackTran();
  9303. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9304. }
  9305. }
  9306. //默认添加查看、编辑权限(创建人、自己)
  9307. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9308. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9309. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9310. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9311. newExterData.DiId = groupId;
  9312. newExterData.CreateUserId = userId;
  9313. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9314. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9315. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9316. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9317. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9318. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9319. //数据如果存在执行删除
  9320. if (enterExitCostInfo != null)
  9321. {
  9322. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9323. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9324. .Where(x => x.Id == enterExitCostInfo.Id)
  9325. .ExecuteCommand();
  9326. _sqlSugar.Updateable<Grp_DayAndCost>()
  9327. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9328. .Where(x => x.DiId == groupId)
  9329. .ExecuteCommand();
  9330. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9331. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9332. .Where(x => x.Diid == groupId)
  9333. .ExecuteCommand();
  9334. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9335. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9336. .Where(x => x.GroupId == groupId)
  9337. .ExecuteCommand();
  9338. }
  9339. //执行insert
  9340. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9341. if (insertId < 1)
  9342. {
  9343. _sqlSugar.RollbackTran();
  9344. return Ok(JsonView(false, "草稿数据导入失败!"));
  9345. }
  9346. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9347. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9348. #region 默认添加权限
  9349. #endregion
  9350. _sqlSugar.CommitTran();
  9351. //执行操作之后
  9352. //生成默认文件pdf并且通知人员
  9353. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9354. {
  9355. DiId = groupId,
  9356. ExportType = 1,
  9357. SubTypeId = 1005
  9358. }, "pdf");
  9359. //发送通知
  9360. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9361. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9362. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9363. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9364. //汇率信息记录
  9365. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9366. return Ok(JsonView(true));
  9367. }
  9368. catch (Exception ex)
  9369. {
  9370. _sqlSugar.RollbackTran();
  9371. return Ok(JsonView(false, ex.Message));
  9372. }
  9373. }
  9374. #endregion
  9375. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9376. /// <summary>
  9377. /// 获取币种基础数据(含逻辑处理)
  9378. /// </summary>
  9379. /// <returns></returns>
  9380. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9381. {
  9382. return await GeneralMethod.EnterExitCostInitRate();
  9383. }
  9384. /// <summary>
  9385. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9386. /// </summary>
  9387. /// <returns></returns>
  9388. [HttpPost]
  9389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9390. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9391. {
  9392. //验证城市归属并给默认值
  9393. int provinceId = dto.ProvinceId;
  9394. if (provinceId < 1) provinceId = 122;
  9395. var dataSource = await _sqlSugar
  9396. .Queryable<Sys_SetData>()
  9397. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9398. .ToListAsync();
  9399. var fileTypes = new List<EecSetDataInfoView>();
  9400. //三公费用-Word明细类型
  9401. var wordTypeData = dataSource
  9402. .Where(it => it.STid == 72)
  9403. .Select(x => new EecSetDataInfoView
  9404. {
  9405. ParentId = 1,
  9406. Id = x.Id,
  9407. Name = x.Name
  9408. })
  9409. .ToArray();
  9410. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9411. var excelTypeData = dataSource
  9412. .Where(it => it.STid == 73)
  9413. .Select(x => new EecSetDataInfoView
  9414. {
  9415. ParentId = 2,
  9416. Id = x.Id,
  9417. Name = x.Name
  9418. })
  9419. .ToArray();
  9420. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9421. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9422. fileTypes.Add(groupNameList);
  9423. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9424. //默认币种显示
  9425. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9426. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9427. return Ok(JsonView(true, "查询成功!", new
  9428. {
  9429. FileTypeData = fileTypes,
  9430. CurrencyInit = _currencyInfos,
  9431. viewPermissionData = viewPermissionData
  9432. }));
  9433. }
  9434. /// <summary>
  9435. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9436. /// </summary>
  9437. /// <returns></returns>
  9438. [HttpPost]
  9439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9440. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9441. {
  9442. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9443. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9444. RefAsync<int> total = 0;
  9445. int diId = 0;
  9446. var status = int.TryParse(dto.GroupName, out diId);
  9447. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9448. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9449. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9450. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9451. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9452. .OrderByDescending(x => x.VisitStartDate)
  9453. .Select(x => new EnterExitCostMobileGroupView()
  9454. {
  9455. Id = x.Id,
  9456. GroupName = x.TeamName,
  9457. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9458. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9459. ProvinceId = x.CityId
  9460. })
  9461. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9462. //处理省份Id
  9463. if (data.Any())
  9464. {
  9465. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9466. if (provCityDatas.Any())
  9467. {
  9468. foreach (var item in data)
  9469. {
  9470. var provinceId = item.ProvinceId;
  9471. var isDefualtVal = true;
  9472. if (provinceId > 0)
  9473. {
  9474. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9475. if (parentId != null)
  9476. {
  9477. isDefualtVal = false;
  9478. item.ProvinceId = (int)parentId;
  9479. }
  9480. }
  9481. if (isDefualtVal)
  9482. {
  9483. item.ProvinceId = 122; //默认四川
  9484. }
  9485. }
  9486. }
  9487. }
  9488. //处理是否显示
  9489. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9490. {
  9491. foreach (var item in data)
  9492. {
  9493. item.IsView = true;
  9494. }
  9495. }
  9496. return Ok(JsonView(true, "查询成功!", data, total));
  9497. }
  9498. /// <summary>
  9499. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9500. /// </summary>
  9501. /// <returns></returns>
  9502. [HttpPost]
  9503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9504. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9505. {
  9506. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9507. RefAsync<int> total = 0;
  9508. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9509. .Where(x => x.IsDel == 0 && x.STid == 66)
  9510. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9511. .Select(x => new
  9512. {
  9513. id = x.Id,
  9514. name = x.Name,
  9515. remark = x.Remark,
  9516. })
  9517. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9518. return Ok(JsonView(true, "查询成功!", data, total));
  9519. }
  9520. /// <summary>
  9521. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9522. /// </summary>
  9523. /// <returns></returns>
  9524. [HttpPost]
  9525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9526. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9527. {
  9528. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9529. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9530. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9531. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9532. var groupOtherRateData = groupRateData.TeamRates;
  9533. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9534. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9535. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9536. groupOtherRateData = groupOtherRateData
  9537. .Select(x => new TeamRateDescAddCurrencyIdView
  9538. {
  9539. CurrencyId = x.CurrencyId,
  9540. CurrencyName = x.CurrencyName,
  9541. CurrencyCode = x.CurrencyCode,
  9542. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9543. }).ToList();
  9544. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9545. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9546. }
  9547. /// <summary>
  9548. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9549. /// </summary>
  9550. /// <returns></returns>
  9551. [HttpPost]
  9552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9553. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9554. {
  9555. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9556. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9557. var tipsData = new List<int>() { 1, 2, 3 };
  9558. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9559. if (dto.TipsType == 1)
  9560. {
  9561. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9562. }
  9563. else if (dto.TipsType == 2)
  9564. {
  9565. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9566. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9567. }
  9568. else if (dto.TipsType == 3)
  9569. {
  9570. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9571. return Ok(JsonView(true, "查询成功!", airData));
  9572. }
  9573. return Ok(JsonView(false));
  9574. }
  9575. /// <summary>
  9576. /// 团组模块 - 出入境国家费用标准-移动端 List
  9577. /// </summary>
  9578. /// <returns></returns>
  9579. [HttpPost]
  9580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9581. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9582. {
  9583. Stopwatch sw = new Stopwatch();
  9584. sw.Start();
  9585. int provinceId = dto.ProvinceId;
  9586. if (provinceId < 1) provinceId = 122; // 默认四川
  9587. RefAsync<int> total = 0;
  9588. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9589. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9590. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9591. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9592. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9593. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9594. .Select((ntf, sd, u, sd1) => new
  9595. {
  9596. Id = ntf.Id,
  9597. Area = $"{ntf.Country}-{ntf.City}",
  9598. Currency = ntf.Currency,
  9599. CurrencyCode = sd.Name,
  9600. CurrencyName = sd.Remark,
  9601. RoomCost = ntf.RoomCost,
  9602. FoodCost = ntf.FoodCost,
  9603. PublicCost = ntf.PublicCost,
  9604. TrainCost = ntf.TrainCost,
  9605. LastUpdateUserId = ntf.LastUpdateUserId,
  9606. LastUpdateUserName = u.CnName,
  9607. LastUpdateTime = ntf.LastUpdateTime
  9608. })
  9609. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9610. sw.Stop();
  9611. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9612. }
  9613. /// <summary>
  9614. /// 团组模块 - 出入境费用-移动端 - Info
  9615. /// </summary>
  9616. /// <returns></returns>
  9617. [HttpPost]
  9618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9619. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9620. {
  9621. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9622. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9623. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9624. return Ok(data);
  9625. }
  9626. /// <summary>
  9627. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9628. /// </summary>
  9629. /// <returns></returns>
  9630. [HttpPost]
  9631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9632. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9633. {
  9634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9635. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9637. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9638. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9639. mobileInfo.DiId = dto.DiId;
  9640. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9641. if (eecInfo == null) return Ok(mobileInfo);
  9642. //验证查看权限
  9643. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9644. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9645. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9646. mobileInfo.IsAssignPerm = isSet;
  9647. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9648. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9649. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9650. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9651. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9652. {
  9653. SubId = dac.Id,
  9654. DiId = dac.DiId,
  9655. Type = dac.Type,
  9656. Days = dac.Days,
  9657. NationalTravelFeeId = dac.NationalTravelFeeId,
  9658. Arae = $"{ntf.Country}-{ntf.City}",
  9659. Cost = dac.Cost,
  9660. Currency = dac.Currency,
  9661. CurrencyName = sd.Name,
  9662. SubTotal = dac.SubTotal,
  9663. })
  9664. .ToList();
  9665. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9666. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9667. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9668. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9669. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9670. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9671. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9672. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9673. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9674. //其他款项
  9675. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9676. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9677. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9678. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9679. .OrderBy((dop, sd1, sd2) => dop.Index)
  9680. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9681. {
  9682. SubId = dop.Id,
  9683. DiId = dop.Diid,
  9684. Index = dop.Index,
  9685. SetDataId = dop.SetDataId,
  9686. SetDataName = sd1.Name,
  9687. Cost = dop.Cost,
  9688. Currency = dop.Currency,
  9689. CurrencyName = sd2.Remark,
  9690. SubTotal = dop.SubTotal,
  9691. Remark = dop.Remark,
  9692. })
  9693. .ToArray();
  9694. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9695. return Ok(mobileInfo);
  9696. }
  9697. /// <summary>
  9698. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9699. /// </summary>
  9700. /// <returns></returns>
  9701. [HttpPost]
  9702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9703. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9704. {
  9705. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9706. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9707. //验证查看权限
  9708. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9709. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9710. var userIds = await _sqlSugar
  9711. .Queryable<Grp_EnterExitCostPermission>()
  9712. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9713. .Select(x => x.UserId)
  9714. .ToArrayAsync();
  9715. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9716. var perUsersView = new List<dynamic>();
  9717. foreach (var item in perUsers)
  9718. {
  9719. bool isView1 = false;
  9720. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9721. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9722. }
  9723. return Ok(JsonView(perUsersView));
  9724. }
  9725. /// <summary>
  9726. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9727. /// </summary>
  9728. /// <returns></returns>
  9729. [HttpPost]
  9730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9731. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9732. {
  9733. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9734. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9735. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9736. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9737. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9738. //验证查看权限
  9739. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9740. //if (!isView) return Ok(JsonView(false, msg));
  9741. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9742. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9743. var subType = dto.SubType;
  9744. if (subType == 1) //1:境内费用
  9745. {
  9746. var oneData = new ChoiceOneMobileSubInfoView()
  9747. {
  9748. Id = eecInfo.Id,
  9749. ChoiceOne = eecInfo.ChoiceOne,
  9750. ChoiceOneTotalCost = eecInfo.InsidePay,
  9751. Visa = eecInfo.Visa,
  9752. VisaRemark = eecInfo.VisaRemark,
  9753. YiMiao = eecInfo.YiMiao,
  9754. HeSuan = eecInfo.HeSuan,
  9755. Service = eecInfo.Service,
  9756. Ticket = eecInfo.Ticket,
  9757. Safe = eecInfo.Safe,
  9758. FirstItemRemark = eecInfo.FirstItemRemark
  9759. };
  9760. return Ok(JsonView(oneData));
  9761. }
  9762. else if (subType == 2) //2:国际旅费
  9763. {
  9764. var twoData = new ChoiceTwoMobileSubInfoView()
  9765. {
  9766. Id = eecInfo.Id,
  9767. ChoiceTwoJJ = eecInfo.SumJJC,
  9768. OutsideJJPay = eecInfo.OutsideJJPay,
  9769. ChoiceTwoGW = eecInfo.SumGWC,
  9770. OutsideGWPay = eecInfo.OutsideGWPay,
  9771. ChoiceTwoTD = eecInfo.SumTDC,
  9772. OutsideTDPay = eecInfo.OutsideTDPay,
  9773. AirJJ = eecInfo.AirJJ,
  9774. AirGW = eecInfo.AirGW,
  9775. AirTD = eecInfo.AirTD,
  9776. CityTranffic = eecInfo.CityTranffic,
  9777. TwoItemRemark = eecInfo.TwoItemRemark
  9778. };
  9779. return Ok(JsonView(twoData));
  9780. }
  9781. else if (subType == 3) //3:住宿费
  9782. {
  9783. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9784. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9785. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9786. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9787. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9788. {
  9789. SubId = dac.Id,
  9790. DiId = dac.DiId,
  9791. Type = dac.Type,
  9792. Days = dac.Days,
  9793. NationalTravelFeeId = dac.NationalTravelFeeId,
  9794. Arae = $"{ntf.Country}-{ntf.City}",
  9795. Cost = dac.Cost,
  9796. Currency = dac.Currency,
  9797. CurrencyName = sd.Name,
  9798. SubTotal = dac.SubTotal,
  9799. })
  9800. .ToArray();
  9801. var data = new ChoiceMobileSubInfo3To6View()
  9802. {
  9803. ParentId = eecInfo.Id,
  9804. Choice = eecInfo.ChoiceThree,
  9805. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9806. Details = dayAndCostDatas
  9807. };
  9808. return Ok(JsonView(data));
  9809. }
  9810. else if (subType == 4) //4:伙食费
  9811. {
  9812. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9813. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9814. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9815. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9816. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9817. {
  9818. SubId = dac.Id,
  9819. DiId = dac.DiId,
  9820. Type = dac.Type,
  9821. Days = dac.Days,
  9822. NationalTravelFeeId = dac.NationalTravelFeeId,
  9823. Arae = $"{ntf.Country}-{ntf.City}",
  9824. Cost = dac.Cost,
  9825. Currency = dac.Currency,
  9826. CurrencyName = sd.Name,
  9827. SubTotal = dac.SubTotal,
  9828. })
  9829. .ToArray();
  9830. var data = new ChoiceMobileSubInfo3To6View()
  9831. {
  9832. ParentId = eecInfo.Id,
  9833. Choice = eecInfo.ChoiceFour,
  9834. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9835. Details = dayAndCostDatas
  9836. };
  9837. return Ok(JsonView(data));
  9838. }
  9839. else if (subType == 5) //5:公杂费
  9840. {
  9841. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9842. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9843. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9844. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9845. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9846. {
  9847. SubId = dac.Id,
  9848. DiId = dac.DiId,
  9849. Type = dac.Type,
  9850. Days = dac.Days,
  9851. NationalTravelFeeId = dac.NationalTravelFeeId,
  9852. Arae = $"{ntf.Country}-{ntf.City}",
  9853. Cost = dac.Cost,
  9854. Currency = dac.Currency,
  9855. CurrencyName = sd.Name,
  9856. SubTotal = dac.SubTotal,
  9857. })
  9858. .ToArray();
  9859. var data = new ChoiceMobileSubInfo3To6View()
  9860. {
  9861. ParentId = eecInfo.Id,
  9862. Choice = eecInfo.ChoiceFive,
  9863. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9864. Details = dayAndCostDatas
  9865. };
  9866. return Ok(JsonView(data));
  9867. }
  9868. else if (subType == 6) //6:培训费
  9869. {
  9870. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9871. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9872. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9873. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9874. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9875. {
  9876. SubId = dac.Id,
  9877. DiId = dac.DiId,
  9878. Type = dac.Type,
  9879. Days = dac.Days,
  9880. NationalTravelFeeId = dac.NationalTravelFeeId,
  9881. Arae = $"{ntf.Country}-{ntf.City}",
  9882. Cost = dac.Cost,
  9883. Currency = dac.Currency,
  9884. CurrencyName = sd.Name,
  9885. SubTotal = dac.SubTotal,
  9886. })
  9887. .ToArray();
  9888. var data = new ChoiceMobileSubInfo3To6View()
  9889. {
  9890. ParentId = eecInfo.Id,
  9891. Choice = eecInfo.ChoiceSix,
  9892. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9893. Details = dayAndCostDatas
  9894. };
  9895. return Ok(JsonView(data));
  9896. }
  9897. else if (subType == 7) //7:其他
  9898. {
  9899. //其他款项
  9900. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9901. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9902. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9903. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9904. .OrderBy((dop, sd1, sd2) => dop.Index)
  9905. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9906. {
  9907. SubId = dop.Id,
  9908. DiId = dop.Diid,
  9909. Index = dop.Index,
  9910. SetDataId = dop.SetDataId,
  9911. SetDataName = sd1.Name,
  9912. Cost = dop.Cost,
  9913. Currency = dop.Currency,
  9914. CurrencyName = sd2.Name,
  9915. SubTotal = dop.SubTotal,
  9916. Remark = dop.Remark,
  9917. })
  9918. .ToArray();
  9919. var data = new ChoiceSevenMobileSubInfoView()
  9920. {
  9921. ParentId = eecInfo.Id,
  9922. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9923. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9924. Details = otherData
  9925. };
  9926. return Ok(JsonView(data));
  9927. }
  9928. return Ok(JsonView(false));
  9929. }
  9930. #region op
  9931. ///// <summary>
  9932. ///// 移动端更新费用消息通知
  9933. ///// </summary>
  9934. ///// <param name="diid"></param>
  9935. ///// <param name="id"></param>
  9936. ///// <param name="currUserId"></param>
  9937. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9938. //{
  9939. // try
  9940. // {
  9941. // ////生成默认文件pdf并且通知人员
  9942. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9943. // //{
  9944. // // DiId = diid,
  9945. // // ExportType = 1,
  9946. // // SubTypeId = 1005
  9947. // //}, "pdf");
  9948. // ////发送通知
  9949. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9950. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9951. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9952. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9953. // ////汇率信息记录
  9954. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9955. // }
  9956. // catch (Exception ex)
  9957. // {
  9958. // //记录日志
  9959. // throw;
  9960. // }
  9961. //}
  9962. /// <summary>
  9963. /// 验证出入境费用数据是否存在
  9964. /// 不存在添加
  9965. /// </summary>
  9966. /// <param name="diId"></param>
  9967. /// <param name="currUserId"></param>
  9968. /// <returns></returns>
  9969. /// <exception cref="CustomException"></exception>
  9970. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9971. {
  9972. var parentId = 0;
  9973. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9974. if (info != null)
  9975. {
  9976. parentId = info.Id;
  9977. }
  9978. else
  9979. {
  9980. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9981. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9982. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9983. parentId = addId;
  9984. }
  9985. return parentId;
  9986. }
  9987. /// <summary>
  9988. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9989. /// </summary>
  9990. /// <returns></returns>
  9991. [HttpPost]
  9992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9993. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9994. {
  9995. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9996. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9997. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9998. //验证编辑权限
  9999. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10000. //if (!isEdit) return Ok(JsonView(false, msg));
  10001. var permissions = new List<Grp_EnterExitCostPermission>();
  10002. foreach (var userId in dto.UserIds)
  10003. {
  10004. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10005. }
  10006. if (permissions.Any())
  10007. {
  10008. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10009. {
  10010. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10011. }
  10012. _sqlSugar.BeginTran();
  10013. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10014. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10015. if (result < 1)
  10016. {
  10017. _sqlSugar.RollbackTran();
  10018. return Ok(JsonView(false));
  10019. }
  10020. _sqlSugar.CommitTran();
  10021. return Ok(JsonView(true));
  10022. }
  10023. return Ok(JsonView(false));
  10024. }
  10025. /// <summary>
  10026. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10027. /// </summary>
  10028. /// <returns></returns>
  10029. [HttpPost]
  10030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10031. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10032. {
  10033. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10034. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10035. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10036. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10037. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10038. int id = dto.Id;
  10039. if (id <= 0) //add
  10040. {
  10041. //int provinceId = dto.ProvinceId;
  10042. int groupId = dto.DiId;
  10043. //if (provinceId < 1) provinceId = 122;
  10044. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10045. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10046. if (add < 1) return Ok(JsonView(false));
  10047. id = add;
  10048. }
  10049. else //update
  10050. {
  10051. ////验证编辑权限
  10052. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10053. //if (!isEdit) return Ok(JsonView(false, msg));
  10054. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10055. if (upd < 1) return Ok(JsonView(false));
  10056. }
  10057. #region 汇率变更时更改币种相关费用
  10058. var opDayCosts = new List<Grp_DayAndCost>();
  10059. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10060. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10061. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10062. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10063. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10064. .Select((dac, sd) => new
  10065. {
  10066. dac.Id,
  10067. dac.DiId,
  10068. CurrencyCode = sd.Name,
  10069. dac.Cost
  10070. })
  10071. .ToList();
  10072. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10073. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10074. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10075. .Select((dop, sd) => new
  10076. {
  10077. dop.Id,
  10078. dop.Diid,
  10079. CurrencyCode = sd.Name,
  10080. dop.Cost
  10081. })
  10082. .ToList();
  10083. if (dayCosts.Count > 0)
  10084. {
  10085. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10086. foreach (var dc in new_dayCosts)
  10087. {
  10088. var thisCurrency = dc.Key.ToUpper();
  10089. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10090. if (thisRate == 0.00M) continue;
  10091. foreach (var dcSub in dc)
  10092. {
  10093. opDayCosts.Add(new Grp_DayAndCost()
  10094. {
  10095. Id = dcSub.Id,
  10096. DiId = dcSub.DiId,
  10097. Cost = dcSub.Cost,
  10098. SubTotal = dcSub.Cost * thisRate,
  10099. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10100. });
  10101. }
  10102. }
  10103. if (opDayCosts.Count > 0)
  10104. {
  10105. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10106. }
  10107. }
  10108. if (dayOtherCosts.Count > 0)
  10109. {
  10110. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10111. foreach (var dc in new_dayOtherCosts)
  10112. {
  10113. var thisCurrency = dc.Key.ToUpper();
  10114. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10115. if (thisRate == 0.00M) continue;
  10116. foreach (var dcSub in dc)
  10117. {
  10118. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10119. {
  10120. Id = dcSub.Id,
  10121. Diid = dcSub.Diid,
  10122. Cost = dcSub.Cost,
  10123. SubTotal = dcSub.Cost * thisRate,
  10124. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10125. });
  10126. }
  10127. }
  10128. if (opDayOtherCosts.Count > 0)
  10129. {
  10130. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10131. }
  10132. }
  10133. #endregion
  10134. //消息通知
  10135. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10136. //汇率信息记录
  10137. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10138. return Ok(JsonView(new { parentId = id }));
  10139. }
  10140. /// <summary>
  10141. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10142. /// </summary>
  10143. /// <returns></returns>
  10144. [HttpPost]
  10145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10146. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10147. {
  10148. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10149. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10150. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10151. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10152. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10153. int id = dto.Id;
  10154. if (id <= 0) //add
  10155. {
  10156. checkboxInfo.CreateUserId = dto.CurrUserId;
  10157. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10158. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10159. if (add < 1) return Ok(JsonView(false));
  10160. }
  10161. else //update
  10162. {
  10163. ////验证编辑权限
  10164. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10165. //if (!isEdit) return Ok(JsonView(false, msg));
  10166. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10167. .UpdateColumns(x => new
  10168. {
  10169. x.ChoiceOne,
  10170. x.ChoiceTwo,
  10171. x.SumJJC,
  10172. x.SumGWC,
  10173. x.SumTDC,
  10174. x.ChoiceThree,
  10175. x.ChoiceFour,
  10176. x.ChoiceFive,
  10177. x.ChoiceSix,
  10178. x.OtherExpenses_Checked
  10179. })
  10180. .Where(x => x.Id == id)
  10181. .ExecuteCommandAsync();
  10182. if (upd < 1) return Ok(JsonView(false));
  10183. }
  10184. return Ok(JsonView(new { parentId = id }));
  10185. }
  10186. /// <summary>
  10187. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10188. /// </summary>
  10189. /// <returns></returns>
  10190. [HttpPost]
  10191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10192. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10193. {
  10194. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10195. // if (provinceId < 1) provinceId = 122;
  10196. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10197. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10198. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10199. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10200. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10201. var checkboxInfo = new Grp_EnterExitCost()
  10202. {
  10203. Id = id,
  10204. //ProvinceId = provinceId,
  10205. DiId = diId,
  10206. CreateUserId = currUserId
  10207. };
  10208. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10209. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10210. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10211. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10212. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10213. if (id <= 0) //add
  10214. {
  10215. checkboxInfo.CreateUserId = dto.CurrUserId;
  10216. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10217. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10218. if (add < 1) return Ok(JsonView(false));
  10219. }
  10220. else //update
  10221. {
  10222. ////验证编辑权限
  10223. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10224. //if (!isEdit) return Ok(JsonView(false, msg));
  10225. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10226. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10227. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10228. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10229. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10230. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10231. .Where(x => x.Id == id)
  10232. .ExecuteCommandAsync();
  10233. if (upd < 1) return Ok(JsonView(false));
  10234. }
  10235. return Ok(JsonView(new { parentId = id }));
  10236. }
  10237. /// <summary>
  10238. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10239. /// </summary>
  10240. /// <returns></returns>
  10241. [HttpPost]
  10242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10243. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10244. {
  10245. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10246. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10247. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10248. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10249. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10250. info.FirstItemRemark = dto.FirstItemRemark;
  10251. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10252. int id = dto.Id;
  10253. if (id <= 0) //add
  10254. {
  10255. info.CreateUserId = dto.CurrUserId;
  10256. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10257. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10258. if (add < 1) return Ok(JsonView(false));
  10259. id = add;
  10260. }
  10261. else //update
  10262. {
  10263. ////验证编辑权限
  10264. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10265. //if (!isEdit) return Ok(JsonView(false, msg));
  10266. var upd = await _sqlSugar.Updateable(info)
  10267. .UpdateColumns(x => new
  10268. {
  10269. x.ChoiceOne,
  10270. x.InsidePay,
  10271. x.VisaRemark,
  10272. x.Visa,
  10273. x.Service,
  10274. x.Safe,
  10275. x.Ticket,
  10276. x.HeSuan,
  10277. x.YiMiao,
  10278. x.FirstItemRemark
  10279. })
  10280. .Where(x => x.Id == id)
  10281. .ExecuteCommandAsync();
  10282. if (upd < 1) return Ok(JsonView(false));
  10283. }
  10284. //消息通知
  10285. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10286. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10287. }
  10288. /// <summary>
  10289. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10290. /// </summary>
  10291. /// <returns></returns>
  10292. [HttpPost]
  10293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10294. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10295. {
  10296. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10297. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10298. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10299. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10300. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10301. info.DiId = dto.DiId;
  10302. //info.ProvinceId = dto.ProvinceId;
  10303. info.OutsideJJPay = dto.OutsideJJPay;
  10304. info.OutsideGWPay = dto.OutsideGWPay;
  10305. info.OutsideTDPay = dto.OutsideTDPay;
  10306. info.AirJJ = dto.AirJJ;
  10307. info.AirGW = dto.AirGW;
  10308. info.AirTD = dto.AirTD;
  10309. info.CityTranffic = dto.CityTranffic;
  10310. info.TwoItemRemark = dto.TwoItemRemark;
  10311. info.SumJJC = dto.ChoiceTwoJJ;
  10312. info.SumGWC = dto.ChoiceTwoGW;
  10313. info.SumTDC = dto.ChoiceTwoTD;
  10314. int id = dto.Id;
  10315. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10316. if (id <= 0) //add
  10317. {
  10318. info.CreateUserId = dto.CurrUserId;
  10319. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10320. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10321. if (addId <= 0) return Ok(JsonView(false));
  10322. id = addId;
  10323. }
  10324. else //update
  10325. {
  10326. ////验证编辑权限
  10327. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10328. //if (!isEdit) return Ok(JsonView(false, msg));
  10329. var upd = await _sqlSugar.Updateable(info)
  10330. .UpdateColumns(x => new
  10331. {
  10332. x.SumJJC,
  10333. x.OutsideJJPay,
  10334. x.SumGWC,
  10335. x.OutsideGWPay,
  10336. x.SumTDC,
  10337. x.OutsideTDPay,
  10338. x.AirJJ,
  10339. x.AirGW,
  10340. x.AirTD,
  10341. x.CityTranffic,
  10342. x.TwoItemRemark
  10343. })
  10344. .Where(x => x.Id == id)
  10345. .ExecuteCommandAsync();
  10346. if (upd < 1) return Ok(JsonView(false));
  10347. }
  10348. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10349. gwcItemTotal = info.AirGW + info.CityTranffic;
  10350. tdcItemTotal = info.AirTD + info.CityTranffic;
  10351. //消息通知
  10352. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10353. return Ok(JsonView(new
  10354. {
  10355. parentId = id,
  10356. choiceTwoJJ = dto.ChoiceTwoJJ,
  10357. jjcItemTotal = jjcItemTotal,
  10358. choiceTwoGW = dto.ChoiceTwoGW,
  10359. gwcItemTotal = gwcItemTotal,
  10360. choiceTwoTD = dto.ChoiceTwoTD,
  10361. tdcItemTotal = tdcItemTotal
  10362. }));
  10363. }
  10364. /// <summary>
  10365. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10366. /// </summary>
  10367. /// <returns></returns>
  10368. [HttpPost]
  10369. [ApiExplorerSettings(IgnoreApi = true)]
  10370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10371. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10372. {
  10373. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10374. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10375. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10376. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10377. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10378. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10379. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10380. var infos = infos1.Select(x => new Grp_DayAndCost
  10381. {
  10382. Id = x.Id,
  10383. DiId = dto.DiId,
  10384. Type = dto.FeeType,
  10385. Days = x.Days,
  10386. NationalTravelFeeId = x.NationalTravelFeeId,
  10387. Cost = x.Cost,
  10388. Currency = x.Currency,
  10389. SubTotal = x.SubTotal,
  10390. CreateUserId = dto.CurrUserId
  10391. })
  10392. .ToList();
  10393. var adds = infos.Where(x => x.Id <= 0).ToList();
  10394. var upds = infos.Where(x => x.Id > 0).ToList();
  10395. if (adds.Count > 0)
  10396. {
  10397. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10398. if (add < 1) return Ok(JsonView(false));
  10399. }
  10400. if (upds.Count > 0)
  10401. {
  10402. var upd = await _sqlSugar.Updateable(adds)
  10403. .UpdateColumns(x => new
  10404. {
  10405. x.Days,
  10406. x.NationalTravelFeeId,
  10407. x.Cost,
  10408. x.Currency,
  10409. x.SubTotal
  10410. })
  10411. .WhereColumns(x => new { x.Id })
  10412. .ExecuteCommandAsync();
  10413. if (upd < 1) return Ok(JsonView(false));
  10414. }
  10415. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10416. //消息通知
  10417. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10418. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10419. return Ok(JsonView(new { itemTotal = itemTotal }));
  10420. }
  10421. /// <summary>
  10422. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10423. /// </summary>
  10424. /// <returns></returns>
  10425. [HttpPost]
  10426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10427. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10428. {
  10429. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10430. int subId = dto.SubId, feeType = dto.FeeType;
  10431. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10432. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10433. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10434. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10435. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10436. subInfo.Id = subId;
  10437. subInfo.DiId = dto.DiId;
  10438. if (feeType == 3) subInfo.Type = 1;
  10439. else if (feeType == 4) subInfo.Type = 2;
  10440. else if (feeType == 5) subInfo.Type = 3;
  10441. else if (feeType == 6) subInfo.Type = 4;
  10442. subInfo.CreateUserId = dto.CurrUserId;
  10443. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10444. if (parentId < 1) return Ok(JsonView(false));
  10445. //子表op
  10446. if (subId < 1)
  10447. {
  10448. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10449. if (subAdd < 1) return Ok(JsonView(false));
  10450. }
  10451. else
  10452. {
  10453. ////验证编辑权限
  10454. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10455. //if (!isEdit) return Ok(JsonView(false, msg));
  10456. var subUpd = await _sqlSugar.Updateable(subInfo)
  10457. .UpdateColumns(x => new
  10458. {
  10459. x.Days,
  10460. x.NationalTravelFeeId,
  10461. x.Cost,
  10462. x.Currency,
  10463. x.SubTotal
  10464. })
  10465. .WhereColumns(x => new { x.Id })
  10466. .ExecuteCommandAsync();
  10467. if (subUpd < 1) return Ok(JsonView(false));
  10468. }
  10469. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10470. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10471. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10472. }
  10473. /// <summary>
  10474. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10475. /// </summary>
  10476. /// <returns></returns>
  10477. [HttpPost]
  10478. [ApiExplorerSettings(IgnoreApi = true)]
  10479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10480. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10481. {
  10482. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10483. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10484. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10485. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10486. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10487. {
  10488. Id = x.Id,
  10489. Diid = dto.DiId,
  10490. SetDataId = x.SetDataId,
  10491. Index = x.Index,
  10492. Cost = x.Cost,
  10493. Currency = x.Currency,
  10494. SubTotal = x.SubTotal,
  10495. CreateUserId = dto.CurrUserId,
  10496. Remark = x.Remark
  10497. }).ToList();
  10498. var adds = infos.Where(x => x.Id <= 0).ToList();
  10499. var upds = infos.Where(x => x.Id > 0).ToList();
  10500. if (adds.Count > 0)
  10501. {
  10502. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10503. if (add < 1) return Ok(JsonView(false));
  10504. }
  10505. if (upds.Count > 0)
  10506. {
  10507. var upd = await _sqlSugar.Updateable(adds)
  10508. .UpdateColumns(x => new
  10509. {
  10510. x.Index,
  10511. x.SetDataId,
  10512. x.Cost,
  10513. x.Currency,
  10514. x.SubTotal,
  10515. x.Remark
  10516. })
  10517. .WhereColumns(x => new { x.Id })
  10518. .ExecuteCommandAsync();
  10519. if (upd < 1) return Ok(JsonView(false));
  10520. }
  10521. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10522. //消息通知
  10523. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10524. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10525. return Ok(JsonView(new { itemTotal = itemTotal }));
  10526. }
  10527. /// <summary>
  10528. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10529. /// </summary>
  10530. /// <returns></returns>
  10531. [HttpPost]
  10532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10533. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10534. {
  10535. int subId = dto.SubId;
  10536. int diId = dto.Diid;
  10537. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10538. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10539. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10540. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10541. subInfo.Id = subId;
  10542. subInfo.Diid = dto.Diid;
  10543. subInfo.CreateUserId = dto.CurrUserId;
  10544. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10545. if (parentId < 1) return Ok(JsonView(false));
  10546. #region 子表op
  10547. if (subId < 1)//add
  10548. {
  10549. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10550. if (subAdd < 1) return Ok(JsonView(false));
  10551. }
  10552. else //upd
  10553. {
  10554. ////验证编辑权限
  10555. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10556. //if (!isEdit) return Ok(JsonView(false, msg));
  10557. var subUpd = await _sqlSugar.Updateable(subInfo)
  10558. .UpdateColumns(x => new
  10559. {
  10560. x.Index,
  10561. x.SetDataId,
  10562. x.Cost,
  10563. x.Currency,
  10564. x.SubTotal,
  10565. x.Remark
  10566. })
  10567. .WhereColumns(x => new { x.Id })
  10568. .ExecuteCommandAsync();
  10569. if (subUpd < 1) return Ok(JsonView(false));
  10570. }
  10571. #endregion
  10572. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10573. //消息通知
  10574. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10575. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10576. }
  10577. /// <summary>
  10578. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10579. /// </summary>
  10580. /// <returns></returns>
  10581. [HttpPost]
  10582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10583. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10584. {
  10585. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10586. if (data.Code != 0)
  10587. {
  10588. return Ok(JsonView(false, data.Msg));
  10589. }
  10590. return Ok(JsonView(true, "操作成功!", data.Data));
  10591. }
  10592. /// <summary>
  10593. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10594. /// </summary>
  10595. /// <param name="dto"></param>
  10596. /// <returns></returns>
  10597. [HttpPost]
  10598. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10599. {
  10600. var data = new Grp_DayOtherPrice()
  10601. {
  10602. Id = dto.Id,
  10603. IsDel = 1,
  10604. DeleteUserId = dto.DeleteUserId,
  10605. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10606. };
  10607. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10608. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10609. return Ok(JsonView(false, "删除失败!"));
  10610. }
  10611. #endregion
  10612. #endregion
  10613. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10614. /// <summary>
  10615. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10616. /// </summary>
  10617. /// <returns></returns>
  10618. [HttpGet]
  10619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10620. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10621. {
  10622. var provData = await _groupRepository.ProvinceBasicSource();
  10623. return Ok(JsonView(true, "查询成功!", provData));
  10624. }
  10625. /// <summary>
  10626. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10627. /// </summary>
  10628. /// <returns></returns>
  10629. [HttpPost]
  10630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10631. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10632. {
  10633. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10634. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10635. RefAsync<int> total = 0;
  10636. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10637. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10638. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10639. .Select(x => new
  10640. {
  10641. Id = x.Id,
  10642. DraftName = x.DraftName,
  10643. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10644. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10645. .Any()
  10646. })
  10647. .OrderByDescending(x => x.Id)
  10648. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10649. return Ok(JsonView(true, "查询成功!", data, total));
  10650. }
  10651. /// <summary>
  10652. /// 出入境费用-草稿 移动端
  10653. /// 获取币种基础数据(含逻辑处理)
  10654. /// </summary>
  10655. /// <returns></returns>
  10656. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10657. {
  10658. return await GeneralMethod.EnterExitCostInitRate();
  10659. }
  10660. /// <summary>
  10661. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10662. /// </summary>
  10663. /// <returns></returns>
  10664. [HttpPost]
  10665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10666. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10667. {
  10668. //验证城市归属并给默认值
  10669. int provinceId = dto.ProvinceId;
  10670. if (provinceId < 1) provinceId = 122;
  10671. var dataSource = await _sqlSugar
  10672. .Queryable<Sys_SetData>()
  10673. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10674. .ToListAsync();
  10675. //三公费用-Word明细类型
  10676. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10677. .Select(x => new SetDataInfoView
  10678. {
  10679. Id = x.Id,
  10680. Name = x.Name,
  10681. Remark = x.Remark
  10682. })
  10683. .ToList();
  10684. //三公费用-Excel明细类型
  10685. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10686. .Select(x => new SetDataInfoView
  10687. {
  10688. Id = x.Id,
  10689. Name = x.Name,
  10690. Remark = x.Remark
  10691. })
  10692. .ToList();
  10693. //默认币种显示
  10694. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10695. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10696. return Ok(JsonView(true, "查询成功!", new
  10697. {
  10698. WordTypeData = wordTypeData,
  10699. ExcelTypeData = excelTypeData,
  10700. CurrencyInit = _currencyInfos,
  10701. viewPermissionData = viewPermissionData
  10702. }));
  10703. }
  10704. /// <summary>
  10705. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10706. /// </summary>
  10707. /// <returns></returns>
  10708. [HttpPost]
  10709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10710. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10711. {
  10712. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10713. RefAsync<int> total = 0;
  10714. int diId = 0;
  10715. var status = int.TryParse(dto.GroupName, out diId);
  10716. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10717. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10718. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10719. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10720. .OrderByDescending(x => x.VisitStartDate)
  10721. .Select(x => new
  10722. {
  10723. Id = x.Id,
  10724. GroupName = x.TeamName
  10725. })
  10726. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10727. return Ok(JsonView(true, "查询成功!", data, total));
  10728. }
  10729. /// <summary>
  10730. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10731. /// </summary>
  10732. /// <returns></returns>
  10733. [HttpPost]
  10734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10735. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10736. {
  10737. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10738. RefAsync<int> total = 0;
  10739. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10740. .Where(x => x.IsDel == 0 && x.STid == 66)
  10741. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10742. .Select(x => new
  10743. {
  10744. id = x.Id,
  10745. name = x.Name,
  10746. remark = x.Remark,
  10747. })
  10748. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10749. return Ok(JsonView(true, "查询成功!", data, total));
  10750. }
  10751. /// <summary>
  10752. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10753. /// </summary>
  10754. /// <returns></returns>
  10755. [HttpPost]
  10756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10757. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10758. {
  10759. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10760. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10761. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10762. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10763. var groupOtherRateData = groupRateData.TeamRates;
  10764. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10765. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10766. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10767. groupOtherRateData = groupOtherRateData
  10768. .Select(x => new TeamRateDescAddCurrencyIdView
  10769. {
  10770. CurrencyId = x.CurrencyId,
  10771. CurrencyName = x.CurrencyName,
  10772. CurrencyCode = x.CurrencyCode,
  10773. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10774. }).ToList();
  10775. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10776. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10777. }
  10778. /// <summary>
  10779. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10780. /// </summary>
  10781. /// <returns></returns>
  10782. [HttpPost]
  10783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10784. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10785. {
  10786. int portType = dto.PortType;
  10787. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10788. var tipsData = new List<int>() { 1, 2, 3 };
  10789. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10790. if (dto.TipsType == 1)
  10791. {
  10792. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10793. }
  10794. else if (dto.TipsType == 2)
  10795. {
  10796. if (portType == 2)
  10797. {
  10798. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10799. }
  10800. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10801. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10802. .Select(x => x.NationalTravelFeeId)
  10803. .Distinct()
  10804. .ToListAsync();
  10805. if (portType == 2)
  10806. {
  10807. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10808. }
  10809. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10810. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10811. .Select(x => x.Country)
  10812. .Distinct()
  10813. .ToArrayAsync();
  10814. if (portType == 2)
  10815. {
  10816. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10817. }
  10818. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10819. return Ok(JsonView(true, "查询成功!", new
  10820. {
  10821. totalAmt = totalAmt,
  10822. remark = remark
  10823. }));
  10824. }
  10825. else if (dto.TipsType == 3)
  10826. {
  10827. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10828. }
  10829. return Ok(JsonView(false));
  10830. }
  10831. /// <summary>
  10832. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10833. /// </summary>
  10834. /// <returns></returns>
  10835. [HttpPost]
  10836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10837. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10838. {
  10839. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10840. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10841. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10842. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10843. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10844. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10845. var info = new Grp_EnterExitCostDraft()
  10846. {
  10847. ProvinceId = dto.ProvinceId,
  10848. DraftName = dto.DraftName,
  10849. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10850. CreateUserId = dto.CurrUserId
  10851. };
  10852. _sqlSugar.BeginTran();
  10853. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10854. if (draftId < 1)
  10855. {
  10856. _sqlSugar.RollbackTran();
  10857. return Ok(JsonView(false, "草稿创建失败!"));
  10858. }
  10859. //添加默认权限
  10860. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10861. _sqlSugar.CommitTran();
  10862. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10863. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10864. mobileInfo.Id = draftId;
  10865. mobileInfo.DraftName = dto.DraftName;
  10866. mobileInfo.Currencys = rateInfos;
  10867. mobileInfo.IsAssignPerm = assignPerm;
  10868. return Ok(JsonView(mobileInfo));
  10869. }
  10870. /// <summary>
  10871. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10872. /// </summary>
  10873. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10874. /// <summary>
  10875. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10876. /// </summary>
  10877. /// <returns></returns>
  10878. [HttpPost]
  10879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10880. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10881. {
  10882. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10883. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10884. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10885. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10886. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10887. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10888. //验证查看编辑权限
  10889. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10890. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10891. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10892. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10893. mobileInfo.IsAssignPerm = assignPerm;
  10894. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10895. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10896. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10897. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10898. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10899. {
  10900. ParentId = dac.ParentId,
  10901. SubId = dac.Id,
  10902. Type = dac.Type,
  10903. Days = dac.Days,
  10904. NationalTravelFeeId = dac.NationalTravelFeeId,
  10905. Arae = $"{ntf.Country}-{ntf.City}",
  10906. Cost = dac.Cost,
  10907. Currency = dac.Currency,
  10908. CurrencyName = sd.Name,
  10909. SubTotal = dac.SubTotal,
  10910. })
  10911. .ToList();
  10912. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10913. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10914. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10915. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10916. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10917. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10918. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10919. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10920. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10921. //其他款项
  10922. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10923. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10924. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10925. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10926. .OrderBy((dop, sd1, sd2) => dop.Index)
  10927. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10928. {
  10929. ParentId = dop.ParentId,
  10930. SubId = dop.Id,
  10931. Index = dop.Index,
  10932. SetDataId = dop.SetDataId,
  10933. SetDataName = sd1.Name,
  10934. Cost = dop.Cost,
  10935. Currency = dop.Currency,
  10936. CurrencyName = sd2.Remark,
  10937. SubTotal = dop.SubTotal,
  10938. Remark = dop.Remark,
  10939. })
  10940. .ToArray();
  10941. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10942. return Ok(mobileInfo);
  10943. }
  10944. /// <summary>
  10945. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10946. /// </summary>
  10947. /// <returns></returns>
  10948. [HttpPost]
  10949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10950. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10951. {
  10952. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10953. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10954. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10955. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10956. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10957. //验证查看编辑权限
  10958. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10959. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10960. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10961. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10962. var subType = dto.SubType;
  10963. if (subType == 1) //1:境内费用
  10964. {
  10965. var oneData = new ChoiceOneMobileSubInfoView()
  10966. {
  10967. Id = eecInfo.Id,
  10968. ChoiceOne = eecInfo.ChoiceOne,
  10969. ChoiceOneTotalCost = eecInfo.InsidePay,
  10970. Visa = eecInfo.Visa,
  10971. VisaRemark = eecInfo.VisaRemark,
  10972. YiMiao = eecInfo.YiMiao,
  10973. HeSuan = eecInfo.HeSuan,
  10974. Service = eecInfo.Service,
  10975. Ticket = eecInfo.Ticket,
  10976. Safe = eecInfo.Safe,
  10977. FirstItemRemark = eecInfo.FirstItemRemark
  10978. };
  10979. return Ok(JsonView(oneData));
  10980. }
  10981. else if (subType == 2) //2:国际旅费
  10982. {
  10983. var twoData = new ChoiceTwoMobileSubInfoView()
  10984. {
  10985. Id = eecInfo.Id,
  10986. ChoiceTwoJJ = eecInfo.SumJJC,
  10987. OutsideJJPay = eecInfo.OutsideJJPay,
  10988. ChoiceTwoGW = eecInfo.SumGWC,
  10989. OutsideGWPay = eecInfo.OutsideGWPay,
  10990. ChoiceTwoTD = eecInfo.SumTDC,
  10991. OutsideTDPay = eecInfo.OutsideTDPay,
  10992. AirJJ = eecInfo.AirJJ,
  10993. AirGW = eecInfo.AirGW,
  10994. AirTD = eecInfo.AirTD,
  10995. CityTranffic = eecInfo.CityTranffic,
  10996. TwoItemRemark = eecInfo.TwoItemRemark
  10997. };
  10998. return Ok(JsonView(twoData));
  10999. }
  11000. else if (subType == 3) //3:住宿费
  11001. {
  11002. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11003. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11004. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11005. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11006. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11007. {
  11008. ParentId = dac.ParentId,
  11009. SubId = dac.Id,
  11010. Type = dac.Type,
  11011. Days = dac.Days,
  11012. NationalTravelFeeId = dac.NationalTravelFeeId,
  11013. Arae = $"{ntf.Country}-{ntf.City}",
  11014. Cost = dac.Cost,
  11015. Currency = dac.Currency,
  11016. CurrencyName = sd.Name,
  11017. SubTotal = dac.SubTotal,
  11018. })
  11019. .ToArray();
  11020. var data = new ChoiceDraftMobileSubInfo3To6View()
  11021. {
  11022. ParentId = eecInfo.Id,
  11023. Choice = eecInfo.ChoiceThree,
  11024. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11025. Details = dayAndCostDatas
  11026. };
  11027. return Ok(JsonView(data));
  11028. }
  11029. else if (subType == 4) //4:伙食费
  11030. {
  11031. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11032. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11033. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11034. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11035. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11036. {
  11037. ParentId = dac.ParentId,
  11038. SubId = dac.Id,
  11039. Type = dac.Type,
  11040. Days = dac.Days,
  11041. NationalTravelFeeId = dac.NationalTravelFeeId,
  11042. Arae = $"{ntf.Country}-{ntf.City}",
  11043. Cost = dac.Cost,
  11044. Currency = dac.Currency,
  11045. CurrencyName = sd.Name,
  11046. SubTotal = dac.SubTotal,
  11047. })
  11048. .ToArray();
  11049. var data = new ChoiceDraftMobileSubInfo3To6View()
  11050. {
  11051. ParentId = eecInfo.Id,
  11052. Choice = eecInfo.ChoiceFour,
  11053. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11054. Details = dayAndCostDatas
  11055. };
  11056. return Ok(JsonView(data));
  11057. }
  11058. else if (subType == 5) //5:公杂费
  11059. {
  11060. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11061. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11062. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11063. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11064. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11065. {
  11066. ParentId = dac.ParentId,
  11067. SubId = dac.Id,
  11068. Type = dac.Type,
  11069. Days = dac.Days,
  11070. NationalTravelFeeId = dac.NationalTravelFeeId,
  11071. Arae = $"{ntf.Country}-{ntf.City}",
  11072. Cost = dac.Cost,
  11073. Currency = dac.Currency,
  11074. CurrencyName = sd.Name,
  11075. SubTotal = dac.SubTotal,
  11076. })
  11077. .ToArray();
  11078. var data = new ChoiceDraftMobileSubInfo3To6View()
  11079. {
  11080. ParentId = eecInfo.Id,
  11081. Choice = eecInfo.ChoiceFive,
  11082. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11083. Details = dayAndCostDatas
  11084. };
  11085. return Ok(JsonView(data));
  11086. }
  11087. else if (subType == 6) //6:培训费
  11088. {
  11089. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11090. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11091. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11092. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11093. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11094. {
  11095. ParentId = dac.ParentId,
  11096. SubId = dac.Id,
  11097. Type = dac.Type,
  11098. Days = dac.Days,
  11099. NationalTravelFeeId = dac.NationalTravelFeeId,
  11100. Arae = $"{ntf.Country}-{ntf.City}",
  11101. Cost = dac.Cost,
  11102. Currency = dac.Currency,
  11103. CurrencyName = sd.Name,
  11104. SubTotal = dac.SubTotal,
  11105. })
  11106. .ToArray();
  11107. var data = new ChoiceDraftMobileSubInfo3To6View()
  11108. {
  11109. ParentId = eecInfo.Id,
  11110. Choice = eecInfo.ChoiceSix,
  11111. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11112. Details = dayAndCostDatas
  11113. };
  11114. return Ok(JsonView(data));
  11115. }
  11116. else if (subType == 7) //7:其他
  11117. {
  11118. //其他款项
  11119. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11120. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11121. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11122. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11123. .OrderBy((dop, sd1, sd2) => dop.Index)
  11124. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11125. {
  11126. ParentId = dop.ParentId,
  11127. SubId = dop.Id,
  11128. Index = dop.Index,
  11129. SetDataId = dop.SetDataId,
  11130. SetDataName = sd1.Name,
  11131. Cost = dop.Cost,
  11132. Currency = dop.Currency,
  11133. CurrencyName = sd2.Name,
  11134. SubTotal = dop.SubTotal,
  11135. Remark = dop.Remark,
  11136. })
  11137. .ToArray();
  11138. var data = new ChoiceSevenDraftMobileSubInfoView()
  11139. {
  11140. ParentId = eecInfo.Id,
  11141. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11142. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11143. Details = otherData
  11144. };
  11145. return Ok(JsonView(data));
  11146. }
  11147. return Ok(JsonView(false));
  11148. }
  11149. #region op
  11150. ///// <summary>
  11151. ///// 移动端更新费用消息通知
  11152. ///// </summary>
  11153. ///// <param name="draftId"></param>
  11154. ///// <param name="id"></param>
  11155. ///// <param name="currUserId"></param>
  11156. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11157. //{
  11158. // try
  11159. // {
  11160. // ////生成默认文件pdf并且通知人员
  11161. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11162. // //{
  11163. // // DiId = draftId,
  11164. // // ExportType = 1,
  11165. // // SubTypeId = 1005
  11166. // //}, "pdf");
  11167. // ////发送通知
  11168. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11169. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11170. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11171. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11172. // ////汇率信息记录
  11173. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11174. // }
  11175. // catch (Exception ex)
  11176. // {
  11177. // //记录日志
  11178. // throw;
  11179. // }
  11180. //}
  11181. /// <summary>
  11182. /// 验证出入境费用数据是否存在
  11183. /// 不存在添加
  11184. /// </summary>
  11185. /// <param name="draftId"></param>
  11186. /// <param name="currUserId"></param>
  11187. /// <returns></returns>
  11188. /// <exception cref="CustomException"></exception>
  11189. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11190. {
  11191. var parentId = 0;
  11192. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11193. if (info != null) parentId = info.Id;
  11194. else
  11195. {
  11196. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11197. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11198. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11199. parentId = addId;
  11200. }
  11201. return parentId;
  11202. }
  11203. /// <summary>
  11204. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11205. /// </summary>
  11206. /// <returns></returns>
  11207. [HttpPost]
  11208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11209. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11210. {
  11211. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11212. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11213. //验证查看权限
  11214. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11215. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11216. var userIds = await _sqlSugar
  11217. .Queryable<Grp_EnterExitCostDraftPermission>()
  11218. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11219. .Select(x => x.UserId)
  11220. .ToArrayAsync();
  11221. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11222. var perUsersView = new List<dynamic>();
  11223. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11224. var viewPermissionData = new List<PermissionViewUserview>();
  11225. if (feeBasePerm.Any())
  11226. {
  11227. foreach (var item in feeBasePerm)
  11228. {
  11229. if (item.Users.Any())
  11230. {
  11231. viewPermissionData.AddRange(item.Users);
  11232. }
  11233. }
  11234. }
  11235. foreach (var item in perUsers)
  11236. {
  11237. bool isView1 = false;
  11238. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11239. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11240. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11241. }
  11242. return Ok(JsonView(perUsersView));
  11243. }
  11244. /// <summary>
  11245. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11246. /// </summary>
  11247. /// <returns></returns>
  11248. [HttpPost]
  11249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11250. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11251. {
  11252. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11253. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11254. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11255. //验证查看编辑权限
  11256. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11257. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11258. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11259. foreach (var userId in dto.UserIds)
  11260. {
  11261. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11262. }
  11263. if (permissions.Any())
  11264. {
  11265. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11266. {
  11267. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11268. }
  11269. _sqlSugar.BeginTran();
  11270. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11271. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11272. if (result < 1)
  11273. {
  11274. _sqlSugar.RollbackTran();
  11275. return Ok(JsonView(false));
  11276. }
  11277. _sqlSugar.CommitTran();
  11278. return Ok(JsonView(true));
  11279. }
  11280. return Ok(JsonView(false));
  11281. }
  11282. /// <summary>
  11283. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11284. /// </summary>
  11285. /// <returns></returns>
  11286. [HttpPost]
  11287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11288. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11289. {
  11290. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11291. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11292. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11293. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11294. int id = dto.DraftId;
  11295. if (id <= 0) //add
  11296. {
  11297. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11298. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11299. if (add < 1) return Ok(JsonView(false));
  11300. id = add;
  11301. }
  11302. else //update
  11303. {
  11304. //验证查看编辑权限
  11305. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11306. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11307. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11308. if (upd < 1) return Ok(JsonView(false));
  11309. }
  11310. return Ok(JsonView(new { parentId = id }));
  11311. }
  11312. /// <summary>
  11313. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11314. /// </summary>
  11315. /// <returns></returns>
  11316. [HttpPost]
  11317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11318. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11319. {
  11320. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11321. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11322. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11323. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11324. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11325. int id = dto.DraftId;
  11326. if (id <= 0) //add
  11327. {
  11328. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11329. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11330. if (add < 1) return Ok(JsonView(false));
  11331. id = add;
  11332. }
  11333. else //update
  11334. {
  11335. //验证查看编辑权限
  11336. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11337. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11338. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11339. if (upd < 1) return Ok(JsonView(false));
  11340. }
  11341. #region 汇率变更时更改币种相关费用
  11342. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11343. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11344. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11345. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11346. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11347. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11348. .Select((dac, sd) => new
  11349. {
  11350. dac.Id,
  11351. dac.ParentId,
  11352. CurrencyCode = sd.Name,
  11353. dac.Cost
  11354. })
  11355. .ToList();
  11356. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11357. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11358. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11359. .Select((dop, sd) => new
  11360. {
  11361. dop.Id,
  11362. dop.ParentId,
  11363. CurrencyCode = sd.Name,
  11364. dop.Cost
  11365. })
  11366. .ToList();
  11367. if (dayCosts.Count > 0)
  11368. {
  11369. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11370. foreach (var dc in new_dayCosts)
  11371. {
  11372. var thisCurrency = dc.Key.ToUpper();
  11373. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11374. if (thisRate == 0.00M) continue;
  11375. foreach (var dcSub in dc)
  11376. {
  11377. opDayCosts.Add(new Grp_DayAndCostDraft()
  11378. {
  11379. Id = dcSub.Id,
  11380. ParentId = dcSub.ParentId,
  11381. Cost = dcSub.Cost,
  11382. SubTotal = dcSub.Cost * thisRate,
  11383. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11384. });
  11385. }
  11386. }
  11387. if (opDayCosts.Count > 0)
  11388. {
  11389. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11390. }
  11391. }
  11392. if (dayOtherCosts.Count > 0)
  11393. {
  11394. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11395. foreach (var dc in new_dayOtherCosts)
  11396. {
  11397. var thisCurrency = dc.Key.ToUpper();
  11398. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11399. if (thisRate == 0.00M) continue;
  11400. foreach (var dcSub in dc)
  11401. {
  11402. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11403. {
  11404. Id = dcSub.Id,
  11405. ParentId = dcSub.ParentId,
  11406. Cost = dcSub.Cost,
  11407. SubTotal = dcSub.Cost * thisRate,
  11408. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11409. });
  11410. }
  11411. }
  11412. if (opDayOtherCosts.Count > 0)
  11413. {
  11414. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11415. }
  11416. }
  11417. #endregion
  11418. ////消息通知
  11419. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11420. ////汇率信息记录
  11421. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11422. return Ok(JsonView(new { parentId = id }));
  11423. }
  11424. /// <summary>
  11425. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11426. /// </summary>
  11427. /// <returns></returns>
  11428. [HttpPost]
  11429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11430. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11431. {
  11432. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11433. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11434. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11435. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11436. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11437. int id = dto.DraftId;
  11438. if (id <= 0) //add
  11439. {
  11440. checkboxInfo.ProvinceId = dto.ProvinceId;
  11441. checkboxInfo.CreateUserId = dto.CurrUserId;
  11442. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11443. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11444. if (add < 1) return Ok(JsonView(false));
  11445. }
  11446. else //update
  11447. {
  11448. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11449. .UpdateColumns(x => new
  11450. {
  11451. x.ChoiceOne,
  11452. x.ChoiceTwo,
  11453. x.SumJJC,
  11454. x.SumGWC,
  11455. x.SumTDC,
  11456. x.ChoiceThree,
  11457. x.ChoiceFour,
  11458. x.ChoiceFive,
  11459. x.ChoiceSix,
  11460. x.OtherExpenses_Checked
  11461. })
  11462. .Where(x => x.Id == id)
  11463. .ExecuteCommandAsync();
  11464. if (upd < 1) return Ok(JsonView(false));
  11465. }
  11466. return Ok(JsonView(new { parentId = id }));
  11467. }
  11468. /// <summary>
  11469. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11470. /// </summary>
  11471. /// <returns></returns>
  11472. [HttpPost]
  11473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11474. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11475. {
  11476. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11477. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11478. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11479. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11480. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11481. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11482. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11483. var checkboxInfo = new Grp_EnterExitCostDraft()
  11484. {
  11485. Id = draftId,
  11486. ProvinceId = dto.ProvinceId,
  11487. CreateUserId = currUserId
  11488. };
  11489. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11490. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11491. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11492. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11493. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11494. if (draftId <= 0) //add
  11495. {
  11496. checkboxInfo.CreateUserId = dto.CurrUserId;
  11497. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11498. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11499. if (add < 1) return Ok(JsonView(false));
  11500. }
  11501. else //update
  11502. {
  11503. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11504. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11505. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11506. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11507. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11508. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11509. .Where(x => x.Id == draftId)
  11510. .ExecuteCommandAsync();
  11511. if (upd < 1) return Ok(JsonView(false));
  11512. }
  11513. return Ok(JsonView(new { parentId = draftId }));
  11514. }
  11515. /// <summary>
  11516. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11517. /// </summary>
  11518. /// <returns></returns>
  11519. [HttpPost]
  11520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11521. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11522. {
  11523. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11524. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11525. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11526. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11527. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11528. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11529. info.ProvinceId = dto.ProvinceId;
  11530. info.FirstItemRemark = dto.FirstItemRemark;
  11531. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11532. if (id <= 0) //add
  11533. {
  11534. info.CreateUserId = dto.CurrUserId;
  11535. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11536. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11537. if (add < 1) return Ok(JsonView(false));
  11538. id = add;
  11539. }
  11540. else //update
  11541. {
  11542. var upd = await _sqlSugar.Updateable(info)
  11543. .UpdateColumns(x => new
  11544. {
  11545. x.ChoiceOne,
  11546. x.InsidePay,
  11547. x.VisaRemark,
  11548. x.Visa,
  11549. x.Service,
  11550. x.Safe,
  11551. x.Ticket,
  11552. x.HeSuan,
  11553. x.YiMiao,
  11554. x.FirstItemRemark
  11555. })
  11556. .Where(x => x.Id == id)
  11557. .ExecuteCommandAsync();
  11558. if (upd < 1) return Ok(JsonView(false));
  11559. }
  11560. ////消息通知
  11561. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11562. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11563. }
  11564. /// <summary>
  11565. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11566. /// </summary>
  11567. /// <returns></returns>
  11568. [HttpPost]
  11569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11570. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11571. {
  11572. int id = dto.DraftId;
  11573. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11574. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11575. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11576. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11577. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11578. info.ProvinceId = dto.ProvinceId;
  11579. info.OutsideJJPay = dto.OutsideJJPay;
  11580. info.OutsideGWPay = dto.OutsideGWPay;
  11581. info.OutsideTDPay = dto.OutsideTDPay;
  11582. info.AirJJ = dto.AirJJ;
  11583. info.AirGW = dto.AirGW;
  11584. info.AirTD = dto.AirTD;
  11585. info.CityTranffic = dto.CityTranffic;
  11586. info.TwoItemRemark = dto.TwoItemRemark;
  11587. info.SumJJC = dto.ChoiceTwoJJ;
  11588. info.SumGWC = dto.ChoiceTwoGW;
  11589. info.SumTDC = dto.ChoiceTwoTD;
  11590. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11591. if (id <= 0) //add
  11592. {
  11593. info.CreateUserId = dto.CurrUserId;
  11594. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11595. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11596. if (addId <= 0) return Ok(JsonView(false));
  11597. id = addId;
  11598. }
  11599. else //update
  11600. {
  11601. var upd = await _sqlSugar.Updateable(info)
  11602. .UpdateColumns(x => new
  11603. {
  11604. x.SumJJC,
  11605. x.OutsideJJPay,
  11606. x.SumGWC,
  11607. x.OutsideGWPay,
  11608. x.SumTDC,
  11609. x.OutsideTDPay,
  11610. x.AirJJ,
  11611. x.AirGW,
  11612. x.AirTD,
  11613. x.CityTranffic,
  11614. x.TwoItemRemark
  11615. })
  11616. .Where(x => x.Id == id)
  11617. .ExecuteCommandAsync();
  11618. if (upd < 1) return Ok(JsonView(false));
  11619. }
  11620. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11621. gwcItemTotal = info.AirGW + info.CityTranffic;
  11622. tdcItemTotal = info.AirTD + info.CityTranffic;
  11623. ////消息通知
  11624. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11625. return Ok(JsonView(new
  11626. {
  11627. parentId = id,
  11628. choiceTwoJJ = dto.ChoiceTwoJJ,
  11629. jjcItemTotal = jjcItemTotal,
  11630. choiceTwoGW = dto.ChoiceTwoGW,
  11631. gwcItemTotal = gwcItemTotal,
  11632. choiceTwoTD = dto.ChoiceTwoTD,
  11633. tdcItemTotal = tdcItemTotal
  11634. }));
  11635. }
  11636. /// <summary>
  11637. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11638. /// </summary>
  11639. /// <returns></returns>
  11640. [HttpPost]
  11641. [ApiExplorerSettings(IgnoreApi = true)]
  11642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11643. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11644. {
  11645. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11646. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11647. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11648. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11649. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11650. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11651. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11652. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11653. {
  11654. Id = x.Id,
  11655. ParentId = dto.DraftId,
  11656. Type = dto.FeeType,
  11657. Days = x.Days,
  11658. NationalTravelFeeId = x.NationalTravelFeeId,
  11659. Cost = x.Cost,
  11660. Currency = x.Currency,
  11661. SubTotal = x.SubTotal,
  11662. CreateUserId = dto.CurrUserId
  11663. })
  11664. .ToList();
  11665. var adds = infos.Where(x => x.Id <= 0).ToList();
  11666. var upds = infos.Where(x => x.Id > 0).ToList();
  11667. if (adds.Count > 0)
  11668. {
  11669. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11670. if (add < 1) return Ok(JsonView(false));
  11671. }
  11672. if (upds.Count > 0)
  11673. {
  11674. var upd = await _sqlSugar.Updateable(adds)
  11675. .UpdateColumns(x => new
  11676. {
  11677. x.Days,
  11678. x.NationalTravelFeeId,
  11679. x.Cost,
  11680. x.Currency,
  11681. x.SubTotal
  11682. })
  11683. .WhereColumns(x => new { x.Id })
  11684. .ExecuteCommandAsync();
  11685. if (upd < 1) return Ok(JsonView(false));
  11686. }
  11687. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11688. ////消息通知
  11689. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11690. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11691. return Ok(JsonView(new { itemTotal = itemTotal }));
  11692. }
  11693. /// <summary>
  11694. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11695. /// </summary>
  11696. /// <returns></returns>
  11697. [HttpPost]
  11698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11699. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11700. {
  11701. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11702. int subId = dto.SubId, feeType = dto.FeeType;
  11703. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11704. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11705. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11706. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11707. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11708. subInfo.Id = subId;
  11709. subInfo.ParentId = dto.DraftId;
  11710. if (feeType == 3) subInfo.Type = 1;
  11711. else if (feeType == 4) subInfo.Type = 2;
  11712. else if (feeType == 5) subInfo.Type = 3;
  11713. else if (feeType == 6) subInfo.Type = 4;
  11714. subInfo.CreateUserId = dto.CurrUserId;
  11715. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11716. if (parentId < 1) return Ok(JsonView(false));
  11717. //子表op
  11718. if (subId < 1)
  11719. {
  11720. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11721. if (subAdd < 1) return Ok(JsonView(false));
  11722. }
  11723. else
  11724. {
  11725. var subUpd = await _sqlSugar.Updateable(subInfo)
  11726. .UpdateColumns(x => new
  11727. {
  11728. x.Days,
  11729. x.NationalTravelFeeId,
  11730. x.Cost,
  11731. x.Currency,
  11732. x.SubTotal
  11733. })
  11734. .WhereColumns(x => new { x.Id })
  11735. .ExecuteCommandAsync();
  11736. if (subUpd < 1) return Ok(JsonView(false));
  11737. }
  11738. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11739. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11740. }
  11741. /// <summary>
  11742. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11743. /// </summary>
  11744. /// <returns></returns>
  11745. [HttpPost]
  11746. [ApiExplorerSettings(IgnoreApi = true)]
  11747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11748. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11749. {
  11750. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11751. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11752. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11753. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11754. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11755. {
  11756. Id = x.Id,
  11757. ParentId = dto.DraftId,
  11758. SetDataId = x.SetDataId,
  11759. Index = x.Index,
  11760. Cost = x.Cost,
  11761. Currency = x.Currency,
  11762. SubTotal = x.SubTotal,
  11763. CreateUserId = dto.CurrUserId,
  11764. Remark = x.Remark
  11765. }).ToList();
  11766. var adds = infos.Where(x => x.Id <= 0).ToList();
  11767. var upds = infos.Where(x => x.Id > 0).ToList();
  11768. if (adds.Count > 0)
  11769. {
  11770. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11771. if (add < 1) return Ok(JsonView(false));
  11772. }
  11773. if (upds.Count > 0)
  11774. {
  11775. var upd = await _sqlSugar.Updateable(adds)
  11776. .UpdateColumns(x => new
  11777. {
  11778. x.Index,
  11779. x.SetDataId,
  11780. x.Cost,
  11781. x.Currency,
  11782. x.SubTotal,
  11783. x.Remark
  11784. })
  11785. .WhereColumns(x => new { x.Id })
  11786. .ExecuteCommandAsync();
  11787. if (upd < 1) return Ok(JsonView(false));
  11788. }
  11789. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11790. //消息通知
  11791. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11792. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11793. return Ok(JsonView(new { itemTotal = itemTotal }));
  11794. }
  11795. /// <summary>
  11796. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11797. /// </summary>
  11798. /// <returns></returns>
  11799. [HttpPost]
  11800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11801. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11802. {
  11803. int subId = dto.SubId, id = dto.DraftId;
  11804. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11805. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11806. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11807. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11808. subInfo.Id = subId;
  11809. subInfo.ParentId = id;
  11810. subInfo.CreateUserId = dto.CurrUserId;
  11811. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11812. if (parentId < 1) return Ok(JsonView(false));
  11813. #region 子表op
  11814. if (subId < 1)//add
  11815. {
  11816. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11817. if (subAdd < 1) return Ok(JsonView(false));
  11818. }
  11819. else //upd
  11820. {
  11821. var subUpd = await _sqlSugar.Updateable(subInfo)
  11822. .UpdateColumns(x => new
  11823. {
  11824. x.Index,
  11825. x.SetDataId,
  11826. x.Cost,
  11827. x.Currency,
  11828. x.SubTotal,
  11829. x.Remark
  11830. })
  11831. .WhereColumns(x => new { x.Id })
  11832. .ExecuteCommandAsync();
  11833. if (subUpd < 1) return Ok(JsonView(false));
  11834. }
  11835. #endregion
  11836. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11837. ////消息通知
  11838. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11839. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11840. }
  11841. /// <summary>
  11842. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11843. /// </summary>
  11844. /// <returns></returns>
  11845. [HttpPost]
  11846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11847. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11848. {
  11849. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11850. if (data.Code != 0)
  11851. {
  11852. return Ok(JsonView(false, data.Msg));
  11853. }
  11854. return Ok(JsonView(true, "操作成功!", data.Data));
  11855. }
  11856. /// <summary>
  11857. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11858. /// </summary>
  11859. /// <param name="dto"></param>
  11860. /// <returns></returns>
  11861. [HttpPost]
  11862. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11863. {
  11864. var data = new Grp_DayOtherPriceDraft()
  11865. {
  11866. Id = dto.Id,
  11867. IsDel = 1,
  11868. DeleteUserId = dto.DeleteUserId,
  11869. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11870. };
  11871. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11872. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11873. return Ok(JsonView(false, "删除失败!"));
  11874. }
  11875. #endregion
  11876. #endregion
  11877. #region 团组经理模块 出入境费用报价表
  11878. /// <summary>
  11879. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11880. /// </summary>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11884. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11885. {
  11886. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11887. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11888. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11889. initRates.Insert(0, cnyInfo);
  11890. liveRates.Insert(0, cnyInfo);
  11891. return Ok(JsonView(true, "查询成功!", new
  11892. {
  11893. InitRates = initRates,
  11894. LiveRates = liveRates
  11895. }));
  11896. }
  11897. /// <summary>
  11898. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11899. /// </summary>
  11900. /// <returns></returns>
  11901. [HttpPost]
  11902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11903. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11904. {
  11905. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11906. }
  11907. /// <summary>
  11908. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11909. /// </summary>
  11910. /// <returns></returns>
  11911. [HttpPost]
  11912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11913. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11914. {
  11915. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11916. }
  11917. /// <summary>
  11918. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11919. /// </summary>
  11920. /// <returns></returns>
  11921. [HttpPost]
  11922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11923. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11924. {
  11925. int groupId = dto.DiId,
  11926. currUserId = dto.CurrUserId;
  11927. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11928. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11929. //验证报价数据是否存在
  11930. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11931. if (isNull != null)
  11932. {
  11933. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11934. if (!info1.Rates.Any())
  11935. {
  11936. var rates = await GeneralMethod.EnterExitCostInitRate();
  11937. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11938. info1.Rates = rates.ToArray();
  11939. }
  11940. return Ok(JsonView(info1));
  11941. }
  11942. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11943. result.GroupId = groupId;
  11944. //处理报价名称
  11945. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11946. if (groupInfo != null)
  11947. {
  11948. var visitCountry = groupInfo.VisitCountry;
  11949. if (!string.IsNullOrEmpty(visitCountry))
  11950. {
  11951. string quoteName = string.Empty;
  11952. if (visitCountry.Contains("|"))
  11953. {
  11954. var countrys = visitCountry.Split("|");
  11955. quoteName = string.Join("、", countrys);
  11956. }
  11957. else quoteName = visitCountry;
  11958. quoteName += $"团组报价表";
  11959. result.Name = quoteName;
  11960. }
  11961. }
  11962. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11963. if (info.Code != StatusCodes.Status200OK)
  11964. {
  11965. if (!result.Rates.Any())
  11966. {
  11967. var rates = await GeneralMethod.EnterExitCostInitRate();
  11968. result.Rates = rates.ToArray();
  11969. }
  11970. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11971. }
  11972. var infoView = info.Data as EnterExitCostInfoView;
  11973. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11974. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11975. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11976. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11977. var eecRates = infoView.Currencys;
  11978. //默认添加人名币
  11979. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11980. {
  11981. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11982. }
  11983. //处理团组人数
  11984. int pplNum = 1;
  11985. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11986. var views = new List<QuoteSubItemInfo>();
  11987. #region 数据填充
  11988. var intTravelCosts = new List<QuoteSubItemInfo>();
  11989. #region 机票费用 1354
  11990. int intTravelIndex = 1;
  11991. if (infoView.SumJJC == 1)
  11992. {
  11993. intTravelCosts.Add(new QuoteSubItemInfo
  11994. {
  11995. ItemId = 1354,
  11996. Index = intTravelIndex,
  11997. FeeName = "经济舱",
  11998. UnitPrice = infoView.AirJJ,
  11999. Currency = "CNY",
  12000. Quantity = 1,
  12001. PplNum = 1,
  12002. TotalAmt = infoView.AirJJ,
  12003. Remark = "",
  12004. });
  12005. intTravelIndex++;
  12006. }
  12007. if (infoView.SumGWC == 1)
  12008. {
  12009. intTravelCosts.Add(new QuoteSubItemInfo
  12010. {
  12011. ItemId = 1354,
  12012. Index = intTravelIndex,
  12013. FeeName = "公务舱",
  12014. UnitPrice = infoView.AirGW,
  12015. Currency = "CNY",
  12016. Quantity = 1,
  12017. PplNum = 1,
  12018. TotalAmt = infoView.AirGW,
  12019. Remark = "",
  12020. });
  12021. intTravelIndex++;
  12022. }
  12023. if (infoView.SumTDC == 1)
  12024. {
  12025. intTravelCosts.Add(new QuoteSubItemInfo
  12026. {
  12027. ItemId = 1354,
  12028. Index = intTravelIndex,
  12029. FeeName = "头等舱",
  12030. UnitPrice = infoView.AirTD,
  12031. Currency = "CNY",
  12032. Quantity = 1,
  12033. PplNum = 1,
  12034. TotalAmt = infoView.AirTD,
  12035. Remark = "",
  12036. });
  12037. intTravelIndex++;
  12038. }
  12039. intTravelCosts.Add(new QuoteSubItemInfo
  12040. {
  12041. ItemId = 1354,
  12042. Index = intTravelIndex,
  12043. FeeName = "城市间交通费用",
  12044. UnitPrice = infoView.CityTranffic,
  12045. Currency = "CNY",
  12046. Quantity = 1,
  12047. PplNum = pplNum,
  12048. TotalAmt = infoView.CityTranffic * pplNum,
  12049. Remark = "",
  12050. });
  12051. views.AddRange(intTravelCosts);
  12052. #endregion
  12053. var accomCosts = new List<QuoteSubItemInfo>();
  12054. #region 住宿费 1355
  12055. if (infoView.QuarterageData.Any())
  12056. {
  12057. int accomIndex = 1;
  12058. int accomItemTypeId = 1355;
  12059. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12060. foreach (var item in groupData)
  12061. {
  12062. string feeName = string.Empty;
  12063. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12064. if (countryInfo != null)
  12065. {
  12066. feeName = countryInfo.Country;
  12067. var city = countryInfo.City;
  12068. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12069. {
  12070. feeName += $"-{city}";
  12071. }
  12072. }
  12073. var hotelInfo = item.FirstOrDefault();
  12074. if (hotelInfo == null) continue;
  12075. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12076. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12077. int quantity = item.ToList().Count;
  12078. accomCosts.Add(new QuoteSubItemInfo
  12079. {
  12080. ItemId = accomItemTypeId,
  12081. Index = accomIndex,
  12082. FeeName = feeName,
  12083. UnitPrice = hotelInfo.Cost,
  12084. Currency = thisCurrency,
  12085. Quantity = quantity,
  12086. PplNum = pplNum,
  12087. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12088. Remark = "",
  12089. });
  12090. accomIndex++;
  12091. }
  12092. views.AddRange(accomCosts);
  12093. }
  12094. #endregion
  12095. var mealCosts = new List<QuoteSubItemInfo>();
  12096. #region 餐饮费 1356
  12097. if (infoView.BoardWagesData.Any())
  12098. {
  12099. var mealIndex = 1;
  12100. int mealItemTypeId = 1356;
  12101. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12102. foreach (var item in groupData)
  12103. {
  12104. string feeName = string.Empty;
  12105. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12106. if (countryInfo != null)
  12107. {
  12108. feeName = countryInfo.Country;
  12109. var city = countryInfo.City;
  12110. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12111. {
  12112. feeName += $"-{city}";
  12113. }
  12114. }
  12115. var mealInfo = item.FirstOrDefault();
  12116. if (mealInfo == null) continue;
  12117. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12118. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12119. int quantity = item.ToList().Count;
  12120. mealCosts.Add(new QuoteSubItemInfo
  12121. {
  12122. ItemId = mealItemTypeId,
  12123. Index = mealIndex,
  12124. FeeName = feeName,
  12125. UnitPrice = mealInfo.Cost,
  12126. Currency = thisCurrency,
  12127. Quantity = quantity,
  12128. PplNum = pplNum,
  12129. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12130. Remark = "",
  12131. });
  12132. mealIndex++;
  12133. }
  12134. views.AddRange(mealCosts);
  12135. }
  12136. #endregion
  12137. var miscCosts = new List<QuoteSubItemInfo>();
  12138. #region 公杂费 1364
  12139. if (infoView.MiscellaneousFeeData.Any())
  12140. {
  12141. var miscIndex = 1;
  12142. int miscItemTypeId = 1364;
  12143. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12144. foreach (var item in groupData)
  12145. {
  12146. string feeName = string.Empty;
  12147. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12148. if (countryInfo != null)
  12149. {
  12150. feeName = countryInfo.Country;
  12151. var city = countryInfo.City;
  12152. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12153. {
  12154. feeName += $"-{city}";
  12155. }
  12156. }
  12157. var miscInfo = item.FirstOrDefault();
  12158. if (miscInfo == null) continue;
  12159. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12160. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12161. int quantity = item.ToList().Count;
  12162. miscCosts.Add(new QuoteSubItemInfo
  12163. {
  12164. ItemId = miscItemTypeId,
  12165. Index = miscIndex,
  12166. FeeName = feeName,
  12167. UnitPrice = miscInfo.Cost,
  12168. Currency = thisCurrency,
  12169. Quantity = quantity,
  12170. PplNum = pplNum,
  12171. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12172. Remark = "",
  12173. });
  12174. miscIndex++;
  12175. }
  12176. views.AddRange(miscCosts);
  12177. }
  12178. #endregion
  12179. #region 签证+保险 1362
  12180. int visaInsIndex = 1;
  12181. int visaInsItemTypeId = 1362;
  12182. if (infoView.Visa > 0)
  12183. {
  12184. views.Add(new QuoteSubItemInfo()
  12185. {
  12186. ItemId = visaInsItemTypeId,
  12187. Index = visaInsIndex,
  12188. FeeName = $"签证",
  12189. UnitPrice = infoView.Visa,
  12190. Currency = $"CNY",
  12191. Quantity = 1,
  12192. PplNum = pplNum,
  12193. TotalAmt = infoView.Visa * pplNum,
  12194. Remark = "",
  12195. });
  12196. visaInsIndex++;
  12197. }
  12198. if (infoView.Safe > 0)
  12199. {
  12200. views.Add(new QuoteSubItemInfo()
  12201. {
  12202. ItemId = visaInsItemTypeId,
  12203. Index = visaInsIndex,
  12204. FeeName = $"保险",
  12205. UnitPrice = infoView.Safe,
  12206. Currency = $"CNY",
  12207. Quantity = 1,
  12208. PplNum = pplNum,
  12209. TotalAmt = infoView.Safe * pplNum,
  12210. Remark = "",
  12211. });
  12212. }
  12213. #endregion
  12214. #region 服务费 1363
  12215. int serviceFeeIndex = 1;
  12216. int serviceFeeItemTypeId = 1363;
  12217. if (infoView.Service > 0)
  12218. {
  12219. views.Add(new QuoteSubItemInfo()
  12220. {
  12221. ItemId = serviceFeeItemTypeId,
  12222. Index = serviceFeeIndex,
  12223. FeeName = $"服务费",
  12224. UnitPrice = infoView.Service,
  12225. Currency = $"CNY",
  12226. Quantity = 1,
  12227. PplNum = pplNum,
  12228. TotalAmt = infoView.Service * pplNum,
  12229. Remark = "",
  12230. });
  12231. }
  12232. #endregion
  12233. #endregion
  12234. if (result.FeeItems.Any())
  12235. {
  12236. result.FeeItems.Select(x =>
  12237. {
  12238. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12239. if (feeInfos.Any()) x.Infos = feeInfos;
  12240. return x;
  12241. }
  12242. ).OrderBy(x => x.Index)
  12243. .ToList();
  12244. if (!result.Rates.Any())
  12245. {
  12246. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12247. else
  12248. {
  12249. var rates = await GeneralMethod.EnterExitCostInitRate();
  12250. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12251. result.Rates = rates.ToArray();
  12252. }
  12253. }
  12254. }
  12255. return Ok(JsonView(result));
  12256. }
  12257. /// <summary>
  12258. /// 团组模块 - 出入境费用报价表 - Info
  12259. /// </summary>
  12260. /// <returns></returns>
  12261. [HttpPost]
  12262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12263. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12264. {
  12265. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12266. if (!info.Rates.Any())
  12267. {
  12268. var rates = await GeneralMethod.EnterExitCostInitRate();
  12269. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12270. info.Rates = rates.ToArray();
  12271. }
  12272. return Ok(JsonView(info));
  12273. }
  12274. /// <summary>
  12275. /// 团组模块 - 出入境费用报价表 - OP
  12276. /// </summary>
  12277. /// <returns></returns>
  12278. [HttpPost]
  12279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12280. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12281. {
  12282. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12283. }
  12284. /// <summary>
  12285. /// 团组模块 - 出入境费用报价表 - 删除 项
  12286. /// </summary>
  12287. /// <returns></returns>
  12288. [HttpPost]
  12289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12290. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12291. {
  12292. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12293. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12294. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12295. }
  12296. /// <summary>
  12297. /// 团组模块 - 出入境费用报价表 - 导出
  12298. /// </summary>
  12299. /// <returns></returns>
  12300. [HttpPost]
  12301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12302. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12303. {
  12304. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12305. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12306. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12307. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12308. var rates = info.Rates;
  12309. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12310. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12311. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12312. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12313. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12314. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12315. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12316. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12317. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12318. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12319. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12320. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12321. //获取模板
  12322. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12323. var designer = new WorkbookDesigner();
  12324. designer.Workbook = new Workbook(tempPath);
  12325. designer.SetDataSource("QuoteName", info.Name);
  12326. designer.SetDataSource("CompanyTitle", "公司名称");
  12327. designer.SetDataSource("CompanyLabel", "");
  12328. #region 国际旅费
  12329. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12330. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12331. {
  12332. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12333. var label = new StringBuilder();
  12334. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12335. if (infos.Any())
  12336. {
  12337. label.Append(infos.Sum(x => x.PplNum));
  12338. label.Append("人全程机票:");
  12339. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12340. label.AppendLine("元");
  12341. }
  12342. foreach (var item in intTravelCosts.Infos)
  12343. {
  12344. label.Append(item.FeeName);
  12345. label.Append(":");
  12346. label.Append(item.UnitPrice.TruncDecimals(2));
  12347. label.Append("元/人*");
  12348. label.Append(item.PplNum);
  12349. label.AppendLine("人");
  12350. }
  12351. if (label.HasValue())
  12352. {
  12353. label.Append("\r\n以上小计:");
  12354. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12355. label.Append("元");
  12356. }
  12357. designer.SetDataSource("IntTravelLabel", label.ToString());
  12358. }
  12359. #endregion
  12360. #region 住宿费
  12361. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12362. if (accomCosts != null && accomCosts.Infos.Any())
  12363. {
  12364. string currencyName = string.Empty,
  12365. countryName = string.Empty;
  12366. decimal rate = 1.0000M;
  12367. var label = new StringBuilder();
  12368. label.AppendLine("全程五星酒店,每人1间房");
  12369. foreach (var item in accomCosts.Infos)
  12370. {
  12371. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12372. string name = string.Empty, thisCountryName = string.Empty;
  12373. if (item.FeeName.Contains('-'))
  12374. {
  12375. var feeName = item.FeeName.Split('-');
  12376. thisCountryName = feeName[0];
  12377. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12378. name = feeName[1];
  12379. }
  12380. else name = item.FeeName;
  12381. string thisFeeName = string.Empty;
  12382. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12383. else thisFeeName = $"\r\n{name}:";
  12384. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12385. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12386. rate = rateInfo?.Rate ?? 1.0000M;
  12387. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12388. label.AppendLine(subLabel);
  12389. }
  12390. if (label.HasValue())
  12391. {
  12392. //以上小计:52440元(美金汇率:7.5 )
  12393. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12394. label.AppendLine(subLabel);
  12395. }
  12396. designer.SetDataSource("AccomLabel", label.ToString());
  12397. }
  12398. #endregion
  12399. #region 餐饮费
  12400. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12401. if (mealCosts != null && mealCosts.Infos.Any())
  12402. {
  12403. string currencyName = string.Empty;
  12404. decimal rate = 1.0000M;
  12405. var label = new StringBuilder();
  12406. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12407. foreach (var item in mealCosts.Infos)
  12408. {
  12409. string name = string.Empty;
  12410. if (item.FeeName.Contains('-'))
  12411. {
  12412. var feeName = item.FeeName.Split('-');
  12413. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12414. }
  12415. else name = $"\r\n{item.FeeName}:";
  12416. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12417. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12418. rate = rateInfo?.Rate ?? 1.0000M;
  12419. label.Append(name);
  12420. label.Append(item.UnitPrice.TruncDecimals(2));
  12421. label.Append(currencyName);
  12422. label.Append("/天*");
  12423. label.Append(item.Quantity.ToString("#0"));
  12424. label.Append('*');
  12425. label.Append(item.PplNum);
  12426. label.Append("人\r\n");
  12427. }
  12428. if (label.HasValue())
  12429. {
  12430. label.Append("\r\n以上小计:");
  12431. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12432. label.Append("元\r\n(");
  12433. label.Append("汇率:");
  12434. label.Append(rate.TruncDecimals(4));
  12435. label.Append(')');
  12436. }
  12437. designer.SetDataSource("MealLabel", label.ToString());
  12438. }
  12439. #endregion
  12440. #region 车辆安排
  12441. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12442. if (vehArranges != null && vehArranges.Infos.Any())
  12443. {
  12444. string currencyName = string.Empty;
  12445. //decimal rate = 1.0000M;
  12446. var label = new StringBuilder();
  12447. foreach (var item in vehArranges.Infos)
  12448. {
  12449. label.AppendLine();
  12450. label.AppendLine();
  12451. label.Append(item.FeeName);
  12452. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12453. }
  12454. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12455. }
  12456. #endregion
  12457. #region 邀请函发放对象
  12458. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12459. designer.SetDataSource("InviteToContent", "");
  12460. #endregion
  12461. #region 邀请函费
  12462. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12463. var is_label = new StringBuilder();
  12464. if (inviteCosts != null && inviteCosts.Infos.Any())
  12465. {
  12466. string currencyName = string.Empty;
  12467. decimal rate = 1.0000M;
  12468. foreach (var item in inviteCosts.Infos)
  12469. {
  12470. //乌兹别克斯坦:2000美金
  12471. currencyName = item.Currency;
  12472. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12473. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12474. is_label.AppendLine(label);
  12475. }
  12476. if (is_label.HasValue())
  12477. {
  12478. //以上小计:28500元(美金汇率:7.5)
  12479. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12480. is_label.AppendLine(label);
  12481. }
  12482. }
  12483. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12484. #endregion
  12485. #region 邀请函发放时间
  12486. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12487. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12488. #endregion
  12489. #region 公务活动(含翻译)
  12490. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12491. var oa_label = new StringBuilder();
  12492. if (officialActs != null && officialActs.Infos.Any())
  12493. {
  12494. string currencyName = string.Empty;
  12495. decimal rate = 1.0000M;
  12496. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12497. foreach (var item in officialActs.Infos)
  12498. {
  12499. //乌兹别克斯坦:1000美金/场
  12500. currencyName = item.Currency;
  12501. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12502. string label_remark = string.Empty;
  12503. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12504. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12505. }
  12506. label_content += "*总费用中未含超出公务活动价格";
  12507. //8场公务活动(以上小计:60000元)
  12508. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12509. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12510. oa_label.AppendLine(label_title);
  12511. oa_label.AppendLine(label_content);
  12512. }
  12513. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12514. #endregion
  12515. #region 签证+保险
  12516. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12517. var vi_label = new StringBuilder();
  12518. if (visaIns != null && visaIns.Infos.Any())
  12519. {
  12520. foreach (var item in visaIns.Infos)
  12521. {
  12522. //签证:500元/人
  12523. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12524. vi_label.AppendLine(label);
  12525. }
  12526. if (vi_label.HasValue())
  12527. {
  12528. //以上小计:6000元
  12529. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12530. vi_label.AppendLine(label);
  12531. }
  12532. }
  12533. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12534. #endregion
  12535. #region 服务费
  12536. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12537. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12538. #endregion
  12539. #region 公杂费
  12540. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12541. var pm_label = new StringBuilder();
  12542. if (pubMiscs != null && pubMiscs.Infos.Any())
  12543. {
  12544. string currencyName = string.Empty,
  12545. countryName = string.Empty;
  12546. decimal rate = 1.0000M;
  12547. foreach (var item in pubMiscs.Infos)
  12548. {
  12549. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12550. string name = string.Empty, thisCountryName = string.Empty;
  12551. if (item.FeeName.Contains('-'))
  12552. {
  12553. var feeName = item.FeeName.Split('-');
  12554. thisCountryName = feeName[0];
  12555. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12556. name = feeName[1];
  12557. }
  12558. else name = item.FeeName;
  12559. string thisFeeName = string.Empty;
  12560. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12561. else thisFeeName = $"\r\n{name}:";
  12562. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12563. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12564. rate = rateInfo?.Rate ?? 1.0000M;
  12565. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12566. pm_label.AppendLine(label);
  12567. }
  12568. if (pm_label.HasValue())
  12569. {
  12570. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12571. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12572. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12573. pm_label.AppendLine(string.Format("部分发放成员"));
  12574. }
  12575. }
  12576. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12577. #endregion
  12578. #region 税费
  12579. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12580. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12581. #endregion
  12582. #region 合计(单位:元)
  12583. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12584. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12585. #endregion
  12586. #region 汇率 Remark
  12587. var rate_label = new StringBuilder();
  12588. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12589. foreach (var item in rateGroups)
  12590. {
  12591. //美元汇率按\r\n1:7.5
  12592. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12593. rate_label.AppendLine(label);
  12594. }
  12595. designer.SetDataSource("RateLabel", rate_label.ToString());
  12596. #endregion
  12597. designer.Process();
  12598. //文件名
  12599. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12600. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12601. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12602. return Ok(JsonView(true, "成功", url));
  12603. }
  12604. #endregion
  12605. #region 签证费用录入
  12606. /// <summary>
  12607. /// 根据diid查询签证费用列表
  12608. /// </summary>
  12609. /// <param name="dto"></param>
  12610. /// <returns></returns>
  12611. [HttpPost]
  12612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12613. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12614. {
  12615. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12616. if (groupData.Code != 0)
  12617. {
  12618. return Ok(JsonView(false, groupData.Msg));
  12619. }
  12620. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12621. }
  12622. /// <summary>
  12623. /// 根据签证费用Id查询单条数据及c表数据
  12624. /// </summary>
  12625. /// <param name="dto"></param>
  12626. /// <returns></returns>
  12627. [HttpPost]
  12628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12629. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12630. {
  12631. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12632. if (groupData.Code != 0)
  12633. {
  12634. return Ok(JsonView(false, groupData.Msg));
  12635. }
  12636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12637. }
  12638. /// <summary>
  12639. /// 签证费用删除
  12640. /// </summary>
  12641. /// <param name="dto"></param>
  12642. /// <returns></returns>
  12643. [HttpPost]
  12644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12645. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12646. {
  12647. _sqlSugar.BeginTran();
  12648. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12649. if (!res)
  12650. {
  12651. _sqlSugar.RollbackTran();
  12652. return Ok(JsonView(false, "删除失败"));
  12653. }
  12654. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12655. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12656. .SetColumns(a => new Grp_CreditCardPayment()
  12657. {
  12658. IsDel = 1,
  12659. DeleteUserId = dto.DeleteUserId,
  12660. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12661. })
  12662. .ExecuteCommand();
  12663. if (resSub < 1)
  12664. {
  12665. _sqlSugar.RollbackTran();
  12666. return Ok(JsonView(false, "删除失败"));
  12667. }
  12668. _sqlSugar.CommitTran();
  12669. return Ok(JsonView(true, "删除成功!"));
  12670. }
  12671. /// <summary>
  12672. /// 签证费用录入下拉框初始化
  12673. /// </summary>
  12674. /// <returns></returns>
  12675. [HttpPost]
  12676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12677. public async Task<IActionResult> VisaPriceAddSelect()
  12678. {
  12679. //支付方式
  12680. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12681. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12682. //币种
  12683. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12684. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12685. //乘客类型
  12686. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12687. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12688. //卡类型
  12689. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12690. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12691. //代办费类型
  12692. var agencyFeeTypeData = new List<dynamic>() {
  12693. new { id = 0 , Text = "未选择" },
  12694. new { id = 1 , Text = "小公务" },
  12695. new { id = 2 , Text = "大公务" },
  12696. };
  12697. //签证费用标准国家Data
  12698. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12699. var data = new
  12700. {
  12701. Payment = _Payment,
  12702. CurrencyList = _CurrencyList,
  12703. PassengerType = _PassengerType,
  12704. BankCard = _BankCard,
  12705. AgencyFeeType = agencyFeeTypeData,
  12706. CountryFeeData = visaCountryFeeData
  12707. };
  12708. return Ok(JsonView(true, "查询成功!", data));
  12709. }
  12710. /// <summary>
  12711. /// 签证费用录入操作(Status:1.新增,2.修改)
  12712. /// </summary>
  12713. /// <param name="dto"></param>
  12714. /// <returns></returns>
  12715. [HttpPost]
  12716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12717. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12718. {
  12719. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12720. if (groupData.Code != 0)
  12721. {
  12722. return Ok(JsonView(false, groupData.Msg));
  12723. }
  12724. #region 应用推送
  12725. try
  12726. {
  12727. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12728. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12729. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12730. //2024-10-21 新增LZ UID
  12731. var userIds = new List<int>() { 21 };
  12732. string title = $"系统通知";
  12733. string content = "";
  12734. var diId = dto.DiId;
  12735. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12736. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12737. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12738. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12739. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12740. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12741. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12742. }
  12743. catch (Exception ex)
  12744. {
  12745. }
  12746. #endregion
  12747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12748. }
  12749. #endregion
  12750. #region 签证提成录入
  12751. /// <summary>
  12752. /// 签证提成录入
  12753. /// 基础数据
  12754. /// </summary>
  12755. /// <returns></returns>
  12756. [HttpGet]
  12757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12758. public async Task<IActionResult> VisaCommissionInit()
  12759. {
  12760. return Ok(await _visaCommissionRep.Init());
  12761. }
  12762. /// <summary>
  12763. /// 签证提成录入
  12764. /// Item
  12765. /// </summary>
  12766. /// <param name="_dto"></param>
  12767. /// <returns></returns>
  12768. [HttpPost]
  12769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12770. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12771. {
  12772. var validator = new VisaCommissionItemDtoValidator();
  12773. var validatorRes = await validator.ValidateAsync(_dto);
  12774. if (!validatorRes.IsValid)
  12775. {
  12776. var sb = new StringBuilder();
  12777. foreach (var item in validatorRes.Errors)
  12778. {
  12779. sb.AppendLine(item.ErrorMessage);
  12780. }
  12781. return Ok(JsonView(false, sb.ToString()));
  12782. }
  12783. return Ok(await _visaCommissionRep.Item(_dto));
  12784. }
  12785. /// <summary>
  12786. /// 签证提成录入
  12787. /// Save
  12788. /// </summary>
  12789. /// <param name="_dto"></param>
  12790. /// <returns></returns>
  12791. [HttpPost]
  12792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12793. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12794. {
  12795. //参数验证
  12796. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12797. foreach (var item in _dto.Items)
  12798. {
  12799. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12800. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12801. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12802. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12803. }
  12804. return Ok(await _visaCommissionRep.Save(_dto));
  12805. }
  12806. /// <summary>
  12807. /// 签证提成录入
  12808. /// Create
  12809. /// </summary>
  12810. /// <param name="_dto"></param>
  12811. /// <returns></returns>
  12812. [HttpPost]
  12813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12814. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12815. {
  12816. var validator = new VisaCommissionCreateDtoValidator();
  12817. var validatorRes = await validator.ValidateAsync(_dto);
  12818. if (!validatorRes.IsValid)
  12819. {
  12820. var sb = new StringBuilder();
  12821. foreach (var item in validatorRes.Errors)
  12822. {
  12823. sb.AppendLine(item.ErrorMessage);
  12824. }
  12825. return Ok(JsonView(false, sb.ToString()));
  12826. }
  12827. return Ok(await _visaCommissionRep.Create(_dto));
  12828. }
  12829. /// <summary>
  12830. /// 签证提成录入
  12831. /// Put(编辑)
  12832. /// </summary>
  12833. /// <param name="id"></param>
  12834. /// <param name="_dto"></param>
  12835. /// <returns></returns>
  12836. [HttpPut]
  12837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12838. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12839. {
  12840. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12841. var validator = new VisaCommissionCreateDtoValidator();
  12842. var validatorRes = await validator.ValidateAsync(_dto);
  12843. if (!validatorRes.IsValid)
  12844. {
  12845. var sb = new StringBuilder();
  12846. foreach (var item in validatorRes.Errors)
  12847. {
  12848. sb.AppendLine(item.ErrorMessage);
  12849. }
  12850. return Ok(JsonView(false, sb.ToString()));
  12851. }
  12852. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12853. }
  12854. /// <summary>
  12855. /// 签证提成录入
  12856. /// Del
  12857. /// </summary>
  12858. /// <param name="id"></param>
  12859. /// <param name="currUserId"></param>
  12860. /// <returns></returns>
  12861. [HttpPost]
  12862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12863. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12864. {
  12865. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12866. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12867. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12868. }
  12869. #endregion
  12870. #region op费用录入
  12871. /// <summary>
  12872. /// 根据diid查询op费用列表
  12873. /// </summary>
  12874. /// <param name="dto"></param>
  12875. /// <returns></returns>
  12876. [HttpPost]
  12877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12878. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12879. {
  12880. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12881. if (groupData.Code != 0)
  12882. {
  12883. return Ok(JsonView(false, groupData.Msg));
  12884. }
  12885. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12886. }
  12887. /// <summary>
  12888. /// 根据op费用Id查询单条数据及c表数据
  12889. /// </summary>
  12890. /// <param name="dto"></param>
  12891. /// <returns></returns>
  12892. [HttpPost]
  12893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12894. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12895. {
  12896. try
  12897. {
  12898. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12899. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12900. var data = new
  12901. {
  12902. CarTouristGuideGround = _groupData,
  12903. CreditCardPayment = _creditCardPayment
  12904. };
  12905. return Ok(JsonView(true, "查询成功!", data));
  12906. }
  12907. catch (Exception ex)
  12908. {
  12909. return Ok(JsonView(false, "程序错误!"));
  12910. }
  12911. }
  12912. /// <summary>
  12913. /// op费用删除
  12914. /// </summary>
  12915. /// <param name="dto"></param>
  12916. /// <returns></returns>
  12917. [HttpPost]
  12918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12919. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12920. {
  12921. try
  12922. {
  12923. _sqlSugar.BeginTran();
  12924. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12925. if (!res)
  12926. {
  12927. return Ok(JsonView(false, "删除失败"));
  12928. }
  12929. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12930. {
  12931. IsDel = 1,
  12932. DeleteUserId = dto.DeleteUserId,
  12933. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12934. }).ExecuteCommandAsync();
  12935. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12936. {
  12937. IsDel = 1,
  12938. DeleteUserId = dto.DeleteUserId,
  12939. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12940. }).ExecuteCommandAsync();
  12941. #region 删除超支相关数据
  12942. //删除导入的超支数据
  12943. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12944. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12945. {
  12946. IsDel = 1,
  12947. DeleteUserId = dto.DeleteUserId,
  12948. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12949. }).ExecuteCommand();
  12950. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12951. {
  12952. IsDel = 1,
  12953. DeleteUserId = dto.DeleteUserId,
  12954. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12955. }).ExecuteCommand();
  12956. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12957. {
  12958. IsDel = 1,
  12959. DeleteUserId = dto.DeleteUserId,
  12960. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12961. }).ExecuteCommand();
  12962. #endregion
  12963. _sqlSugar.CommitTran();
  12964. return Ok(JsonView(true, "删除成功!"));
  12965. }
  12966. catch (Exception ex)
  12967. {
  12968. _sqlSugar.RollbackTran();
  12969. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12970. }
  12971. }
  12972. /// <summary>
  12973. /// op费用录入操作(Status:1.新增,2.修改)
  12974. /// </summary>
  12975. /// <param name="dto"></param>
  12976. /// <returns></returns>
  12977. [HttpPost]
  12978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12979. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12980. {
  12981. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12982. if (groupData.Code != 0)
  12983. {
  12984. return Ok(JsonView(false, groupData.Msg));
  12985. }
  12986. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12987. }
  12988. /// <summary>
  12989. /// 填写费用详细页面初始化绑定
  12990. /// </summary>
  12991. /// <param name="dto"></param>
  12992. /// <returns></returns>
  12993. [HttpPost]
  12994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12995. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12996. {
  12997. try
  12998. {
  12999. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13000. if (groupData.Code != 0)
  13001. {
  13002. return Ok(JsonView(false, groupData.Msg));
  13003. }
  13004. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13005. }
  13006. catch (Exception ex)
  13007. {
  13008. return Ok(JsonView(false, ex.Message));
  13009. }
  13010. }
  13011. /// <summary>
  13012. /// 根据op费用Id查询详细数据
  13013. /// </summary>
  13014. /// <param name="dto"></param>
  13015. /// <returns></returns>
  13016. [HttpPost]
  13017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13018. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13019. {
  13020. try
  13021. {
  13022. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13023. if (groupData.Code != 0)
  13024. {
  13025. return Ok(JsonView(false, groupData.Msg));
  13026. }
  13027. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13028. }
  13029. catch (Exception ex)
  13030. {
  13031. return Ok(JsonView(false, ex.Message));
  13032. }
  13033. }
  13034. /// <summary>
  13035. /// OP费用录入填写详情
  13036. /// </summary>
  13037. /// <param name="dto"></param>
  13038. /// <returns></returns>
  13039. [HttpPost]
  13040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13041. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13042. {
  13043. try
  13044. {
  13045. #region 参数校验
  13046. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13047. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13048. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13049. #endregion
  13050. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13051. if (groupData.Code != 0)
  13052. {
  13053. return Ok(JsonView(false, groupData.Msg));
  13054. }
  13055. //自动审核
  13056. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13057. #region 应用推送
  13058. try
  13059. {
  13060. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13061. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13062. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13063. //2024-10-21 新增LZ UID
  13064. var userIds = new List<int>() { 21 };
  13065. string title = $"系统通知";
  13066. var diId = dto.DiId;
  13067. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13068. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13069. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13070. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13071. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13072. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13073. }
  13074. catch (Exception ex)
  13075. {
  13076. }
  13077. #endregion
  13078. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13079. }
  13080. catch (Exception ex)
  13081. {
  13082. return Ok(JsonView(false, ex.Message));
  13083. }
  13084. }
  13085. /// <summary>
  13086. /// 获取三公详细所有城市
  13087. /// </summary>
  13088. /// <returns></returns>
  13089. [HttpGet]
  13090. public IActionResult OpCarCityResult()
  13091. {
  13092. var jw = JsonView(false);
  13093. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13094. {
  13095. x.Id,
  13096. x.Country,
  13097. x.City,
  13098. }).ToList();
  13099. if (data.Count > 0)
  13100. {
  13101. jw = JsonView(true, "获取成功!", data);
  13102. }
  13103. else
  13104. {
  13105. jw.Msg = "城市数据为空!";
  13106. jw.Data = Array.Empty<string>();
  13107. }
  13108. return Ok(jw);
  13109. }
  13110. /// <summary>
  13111. /// 导出地接费用明细
  13112. /// </summary>
  13113. /// <param name="dto"></param>
  13114. /// <returns></returns>
  13115. [HttpPost]
  13116. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13117. {
  13118. var jw = JsonView(false);
  13119. if (dto.Diid < 1)
  13120. {
  13121. jw.Msg = "请输入正确的diid!";
  13122. return Ok(jw);
  13123. }
  13124. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13125. if (group == null)
  13126. {
  13127. jw.Msg = "未找到团组信息!";
  13128. return Ok(jw);
  13129. }
  13130. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13131. if (localGuideArr.Count == 0)
  13132. {
  13133. jw.Msg = "该团组暂无地接信息!";
  13134. return Ok(jw);
  13135. }
  13136. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13137. var overspendSoure = new Dictionary<int, int>
  13138. {
  13139. { 91, 982 }, //车
  13140. { 92 , 1059} ,//导游
  13141. { 994 , 1073}, //翻译
  13142. { 988 , 1074 }, //早餐
  13143. { 93 , 1075 }, //午餐
  13144. { 989 , 1076 }, //晚餐
  13145. };
  13146. var Zips = new Dictionary<string, Stream>();
  13147. foreach (var groupArr in localGroup)
  13148. {
  13149. var keyValue = groupArr.Key;
  13150. if (int.TryParse(keyValue, out int cityid))
  13151. {
  13152. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13153. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13154. }
  13155. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13156. foreach (var item in groupArr)
  13157. {
  13158. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13159. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13160. new Grp_CarTouristGuideGroundReservationsContentExtend
  13161. {
  13162. Count = a.Count,
  13163. CreateTime = a.CreateTime,
  13164. CreateUserId = a.CreateUserId,
  13165. CTGGRId = a.CTGGRId,
  13166. Currency = a.Currency,
  13167. DatePrice = a.DatePrice,
  13168. DeleteTime = a.DeleteTime,
  13169. DeleteUserId = a.DeleteUserId,
  13170. DiId = a.DiId,
  13171. Id = a.Id,
  13172. IsDel = a.IsDel,
  13173. Price = a.Price,
  13174. PriceContent = a.PriceContent,
  13175. Remark = a.Remark,
  13176. SId = a.SId,
  13177. SidName = b.Name,
  13178. Units = a.Units,
  13179. }
  13180. ).ToList();
  13181. if (content.Count > 0)
  13182. {
  13183. contentArr.Add(content);
  13184. }
  13185. }
  13186. //open excel
  13187. //set excel
  13188. //save excel
  13189. try
  13190. {
  13191. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13192. IWorkbook workbook;
  13193. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13194. {
  13195. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13196. }
  13197. else
  13198. {
  13199. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13200. }
  13201. ISheet sheet = workbook.GetSheetAt(0);
  13202. var rowStartIndex = 2;
  13203. var clounmCount = 10;
  13204. var initStyleRow = sheet.GetRow(2);
  13205. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13206. //var overspendArrDetail =
  13207. var existsId = new List<CarCompare>();
  13208. var lastElem = arr.Last();
  13209. var thisSid = -1;
  13210. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13211. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13212. {
  13213. Name = "未知币种!",
  13214. Remark = "未知币种!",
  13215. };
  13216. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13217. Action cloneRowFn = () =>
  13218. {
  13219. rowStartIndex++;
  13220. var cloneRow = sheet.CreateRow(rowStartIndex);
  13221. // 复制样式
  13222. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13223. {
  13224. ICell sourceCell = initStyleRow.GetCell(i);
  13225. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13226. // 确保单元格存在样式
  13227. if (sourceCell.CellStyle != null)
  13228. {
  13229. targetCell.CellStyle = sourceCell.CellStyle;
  13230. }
  13231. }
  13232. };
  13233. var mergeRow = () =>
  13234. {
  13235. for (int i = 2; i < sheet.LastRowNum; i++)
  13236. {
  13237. var row = sheet.GetRow(i);
  13238. var cellFirst = row.GetCell(0);
  13239. var thisIndex = i + 1;
  13240. while (thisIndex < sheet.LastRowNum)
  13241. {
  13242. var nextRow = sheet.GetRow(thisIndex);
  13243. var nextCellFirst = nextRow.GetCell(0);
  13244. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13245. {
  13246. thisIndex++;
  13247. }
  13248. else
  13249. {
  13250. break;
  13251. }
  13252. }
  13253. thisIndex--;
  13254. if (thisIndex != i)
  13255. {
  13256. //合并row
  13257. var cellRangeAddress = new CellRangeAddress(
  13258. i, // 起始行索引(0-based)
  13259. thisIndex, // 结束行索引(0-based)
  13260. 0, // 起始列索引(0-based)
  13261. 0 // 结束列索引(0-based)
  13262. );
  13263. sheet.AddMergedRegion(cellRangeAddress);
  13264. i = thisIndex;
  13265. }
  13266. }
  13267. };
  13268. var chaoshiNumber = 0;
  13269. var totalNumber = 0.00M;
  13270. string lastStr = "";
  13271. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13272. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13273. {
  13274. b.IsAuditGM,
  13275. x.Id,
  13276. x.Area,
  13277. b.PayPercentage,
  13278. b.PayMoney,
  13279. }).ToList();
  13280. string yesPayment = "", noPayment = "";
  13281. foreach (var item in queryCarArrByCityAndDiid)
  13282. {
  13283. if (item.IsAuditGM == 1)
  13284. {
  13285. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13286. }
  13287. else
  13288. {
  13289. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13290. }
  13291. }
  13292. lastStr = yesPayment + noPayment;
  13293. foreach (var item in arr)
  13294. {
  13295. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13296. {
  13297. if (thisSid != item.SId)
  13298. {
  13299. if (thisSid == -1)
  13300. {
  13301. thisSid = item.SId;
  13302. }
  13303. else
  13304. {
  13305. //合并小计行
  13306. //创建合并区域的实例
  13307. var cellRangeAddress = new CellRangeAddress(
  13308. rowStartIndex, // 起始行索引(0-based)
  13309. rowStartIndex, // 结束行索引(0-based)
  13310. 0, // 起始列索引(0-based)
  13311. 3 // 结束列索引(0-based)
  13312. );
  13313. sheet.AddMergedRegion(cellRangeAddress);
  13314. var CellStyle = workbook.CreateCellStyle();
  13315. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13316. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13317. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13318. for (int i = 0; i <= clounmCount; i++)
  13319. {
  13320. if (i > 6)
  13321. {
  13322. var CellStyle1 = workbook.CreateCellStyle();
  13323. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13324. IFont Font = workbook.CreateFont(); // 创建字体
  13325. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13326. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13327. CellStyle1.SetFont(Font);
  13328. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13329. }
  13330. else
  13331. {
  13332. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13333. }
  13334. }
  13335. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13336. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13337. //超时合计
  13338. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13339. //超时数
  13340. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13341. //超时合计费用
  13342. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13343. thisSid = item.SId;
  13344. cloneRowFn();
  13345. chaoshiNumber = 0;
  13346. totalNumber = 0;
  13347. }
  13348. }
  13349. IRow row = sheet.GetRow(rowStartIndex);
  13350. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13351. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13352. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13353. if (isOpenOverspendSoure)
  13354. {
  13355. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13356. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13357. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13358. }
  13359. for (int i = 0; i <= clounmCount; i++)
  13360. {
  13361. var cell = row.GetCell(i);
  13362. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13363. if (cell == null)
  13364. {
  13365. cell = row.CreateCell(i);
  13366. }
  13367. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13368. fontRed.CloneStyleFrom(cell.CellStyle);
  13369. IFont Font = workbook.CreateFont(); // 创建字体
  13370. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13371. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13372. fontRed.SetFont(Font);
  13373. byte[] rgb = new byte[3] { 255, 242, 204 };
  13374. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13375. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13376. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13377. if (workbook is XSSFWorkbook)
  13378. {
  13379. BackgroundColor255_242_204.FillForegroundColor = 0;
  13380. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13381. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13382. }
  13383. else
  13384. {
  13385. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13386. }
  13387. if (i == 1 || i > 6)
  13388. {
  13389. if (i > 6)
  13390. {
  13391. fontRed.FillForegroundColor = 0;
  13392. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13393. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13394. }
  13395. cell.CellStyle = fontRed;
  13396. }
  13397. if (i > 2 && i < 7)
  13398. {
  13399. cell.CellStyle = BackgroundColor255_242_204;
  13400. }
  13401. cell.SetCellValue(setCellValue); //写入单元格
  13402. }
  13403. if (overspendSoure.ContainsKey(thisSid))
  13404. {
  13405. var overspendId = overspendSoure[thisSid];
  13406. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13407. }
  13408. cloneRowFn();
  13409. existsId.Add(new CarCompare
  13410. {
  13411. DataPrice = item.DatePrice.ObjToDate(),
  13412. Sid = item.SId
  13413. });
  13414. }
  13415. if (item.Equals(lastElem))
  13416. {
  13417. //合并小计行
  13418. //创建合并区域的实例
  13419. var cellRangeAddress = new CellRangeAddress(
  13420. rowStartIndex, // 起始行索引(0-based)
  13421. rowStartIndex, // 结束行索引(0-based)
  13422. 0, // 起始列索引(0-based)
  13423. 3 // 结束列索引(0-based)
  13424. );
  13425. sheet.AddMergedRegion(cellRangeAddress);
  13426. var CellStyle = workbook.CreateCellStyle();
  13427. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13428. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13429. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13430. for (int i = 0; i <= clounmCount; i++)
  13431. {
  13432. if (i > 6)
  13433. {
  13434. var CellStyle1 = workbook.CreateCellStyle();
  13435. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13436. IFont Font = workbook.CreateFont(); // 创建字体
  13437. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13438. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13439. CellStyle1.SetFont(Font);
  13440. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13441. }
  13442. else
  13443. {
  13444. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13445. }
  13446. }
  13447. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13448. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13449. //超时合计
  13450. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13451. //超时数
  13452. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13453. //超时合计费用
  13454. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13455. cloneRowFn();
  13456. // 创建合并区域的实例
  13457. cellRangeAddress = new CellRangeAddress(
  13458. rowStartIndex, // 起始行索引(0-based)
  13459. rowStartIndex, // 结束行索引(0-based)
  13460. 0, // 起始列索引(0-based)
  13461. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13462. );
  13463. // 添加合并区域
  13464. sheet.AddMergedRegion(cellRangeAddress);
  13465. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13466. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13467. }
  13468. }
  13469. mergeRow();
  13470. // 保存修改后的Excel文件到新文件
  13471. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13472. // new FileStream(newFilePath, FileMode.CreateNew)
  13473. using (var stream = new MemoryStream())
  13474. {
  13475. workbook.Write(stream, true);
  13476. stream.Flush();
  13477. stream.Seek(0, SeekOrigin.Begin);
  13478. var memoryStream = new MemoryStream();
  13479. stream.CopyTo(memoryStream);
  13480. memoryStream.Seek(0, SeekOrigin.Begin);
  13481. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13482. }
  13483. workbook.Close();
  13484. workbook.Dispose();
  13485. }
  13486. catch (Exception ex)
  13487. {
  13488. jw.Msg = "出现异常!" + ex.Message;
  13489. return Ok(jw);
  13490. }
  13491. }
  13492. if (Zips.Count > 0)
  13493. {
  13494. var io = new IOOperatorHelper();
  13495. var byts = io.ConvertZipStream(Zips);
  13496. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13497. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13498. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13499. }
  13500. else
  13501. {
  13502. jw.Msg = "暂无生成文件!";
  13503. }
  13504. return Ok(jw);
  13505. }
  13506. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13507. {
  13508. string outStr = string.Empty;
  13509. switch (i)
  13510. {
  13511. case 0:
  13512. outStr = arr[0].SidName;
  13513. break;
  13514. case 1:
  13515. outStr = arr[0].DataPriceStr;
  13516. break;
  13517. case 2:
  13518. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13519. break;
  13520. case 4:
  13521. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13522. break;
  13523. case 7:
  13524. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13525. {
  13526. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13527. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13528. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13529. }
  13530. break;
  13531. case 8:
  13532. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13533. {
  13534. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13535. }
  13536. break;
  13537. case 9:
  13538. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13539. {
  13540. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13541. }
  13542. break;
  13543. case 10:
  13544. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13545. {
  13546. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13547. }
  13548. break;
  13549. }
  13550. return outStr;
  13551. }
  13552. #region OP行程单
  13553. /// <summary>
  13554. /// OP行程单初始化
  13555. /// </summary>
  13556. /// <param name="dto"></param>
  13557. /// <returns></returns>
  13558. [HttpPost]
  13559. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13560. {
  13561. var jw = JsonView(false);
  13562. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13563. var group = groupList.First();
  13564. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13565. if (group == null)
  13566. {
  13567. jw.Msg = "暂无团组!";
  13568. return Ok(jw);
  13569. }
  13570. group = groupList.Find(x => x.Id == diid);
  13571. if (group == null)
  13572. {
  13573. jw.Msg = "请输入正确的团组ID!";
  13574. return Ok(jw);
  13575. }
  13576. string city = string.Empty;
  13577. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13578. if (blackCode.Count > 0)
  13579. {
  13580. var black = blackCode.First();
  13581. black.BlackCode = black.BlackCode ?? "";
  13582. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13583. if (blackSp.Length > 0)
  13584. {
  13585. try
  13586. {
  13587. var cityArrCode = new List<string>(20);
  13588. foreach (var item in blackSp)
  13589. {
  13590. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13591. var IndexSelect = itemSp[2];
  13592. var cityArrCodeLength = cityArrCode.Count - 1;
  13593. var startCity = IndexSelect.Substring(0, 3);
  13594. if (cityArrCodeLength > 0)
  13595. {
  13596. var arrEndCity = cityArrCode[cityArrCodeLength];
  13597. if (arrEndCity != startCity)
  13598. {
  13599. cityArrCode.Add(startCity.ToUpper());
  13600. }
  13601. }
  13602. else
  13603. {
  13604. cityArrCode.Add(startCity.ToUpper());
  13605. }
  13606. var endCity = IndexSelect.Substring(3, 3);
  13607. cityArrCode.Add(endCity.ToUpper());
  13608. }
  13609. var cityThree = string.Empty;
  13610. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13611. cityThree = cityThree.TrimEnd(',');
  13612. if (string.IsNullOrWhiteSpace(cityThree))
  13613. {
  13614. throw new
  13615. Exception("error");
  13616. }
  13617. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13618. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13619. foreach (var item in cityArrCode)
  13620. {
  13621. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13622. if (find != null)
  13623. {
  13624. city += find.City + "/";
  13625. }
  13626. else
  13627. {
  13628. city += item + "三字码未收入/";
  13629. }
  13630. }
  13631. city = city.TrimEnd('/');
  13632. }
  13633. catch (Exception e)
  13634. {
  13635. city = "黑屏代码格式不正确!";
  13636. }
  13637. }
  13638. }
  13639. else
  13640. {
  13641. city = "未录入黑屏代码";
  13642. }
  13643. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13644. {
  13645. Date = x.Date,
  13646. Days = x.Days,
  13647. Diffgroup = x.Diffgroup,
  13648. Diid = x.Diid,
  13649. Traffic_First = x.Traffic_First,
  13650. Traffic_Second = x.Traffic_Second,
  13651. Trip = x.Trip,
  13652. WeekDay = x.WeekDay,
  13653. Id = x.Id
  13654. }).ToList();
  13655. jw.Data = new
  13656. {
  13657. groupList = groupList.Select(x => new
  13658. {
  13659. x.Id,
  13660. x.TeamName,
  13661. x.TourCode
  13662. }).ToList(),
  13663. groupInfo = new
  13664. {
  13665. group.VisitDays,
  13666. group.TourCode,
  13667. group.VisitPNumber,
  13668. group.TeamName,
  13669. city
  13670. },
  13671. OpTravelList
  13672. };
  13673. jw.Code = 200;
  13674. jw.Msg = "操作成功!";
  13675. return Ok(jw);
  13676. }
  13677. /// <summary>
  13678. /// 删除团组行程单
  13679. /// </summary>
  13680. /// <returns></returns>
  13681. [HttpPost]
  13682. public IActionResult DelTravel(DelOpTravelDto dto)
  13683. {
  13684. var jw = JsonView(false);
  13685. if (dto.UserId <= 0 || dto.Diid <= 0)
  13686. {
  13687. jw.Msg = "请输入正确的参数!";
  13688. return Ok(jw);
  13689. }
  13690. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13691. .SetColumns(x => new Grp_TravelList
  13692. {
  13693. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13694. DeleteUserId = dto.UserId,
  13695. IsDel = 1,
  13696. }).ExecuteCommand();
  13697. jw = JsonView(true);
  13698. return Ok(jw);
  13699. }
  13700. /// <summary>
  13701. /// 行程单保存
  13702. /// </summary>
  13703. /// <returns></returns>
  13704. [HttpPost]
  13705. public IActionResult TravelSave(TravelSaveDto dto)
  13706. {
  13707. var jw = JsonView(false);
  13708. if (dto.Arr.Count > 0)
  13709. {
  13710. try
  13711. {
  13712. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13713. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13714. .ToList();
  13715. _sqlSugar.BeginTran();
  13716. foreach (var item in dto.Arr)
  13717. {
  13718. if (item.Id == 0)
  13719. {
  13720. throw new Exception("请传入正确的Id");
  13721. }
  13722. //比较上一次的差异
  13723. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13724. if (findTravel != null)
  13725. {
  13726. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13727. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13728. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13729. }
  13730. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13731. .SetColumns(x => new Grp_TravelList
  13732. {
  13733. Trip = item.Trip
  13734. }).ExecuteCommand();
  13735. }
  13736. _sqlSugar.CommitTran();
  13737. jw = JsonView(true);
  13738. }
  13739. catch (Exception ex)
  13740. {
  13741. _sqlSugar.RollbackTran();
  13742. jw.Msg = "程序异常!" + ex.Message;
  13743. }
  13744. }
  13745. else
  13746. {
  13747. jw.Msg = "请传入正确的参数!";
  13748. }
  13749. return Ok(jw);
  13750. }
  13751. private static string CheckStr(string original, string changed)
  13752. {
  13753. // 创建diff_match_patch对象
  13754. var dmp = new diff_match_patch();
  13755. // 计算差异
  13756. List<Diff> diffs = dmp.diff_main(original, changed);
  13757. // 清理和合并差异
  13758. dmp.diff_cleanupSemantic(diffs);
  13759. // 使用StringBuilder构建最终的字符串
  13760. var finalString = new StringBuilder();
  13761. // 输出差异结果,并构建变动后的字符串
  13762. foreach (Diff diff in diffs)
  13763. {
  13764. switch (diff.operation)
  13765. {
  13766. case Operation.EQUAL:
  13767. // 相等的部分,直接添加到最终字符串
  13768. finalString.Append(diff.text);
  13769. break;
  13770. case Operation.INSERT:
  13771. // 插入的部分,添加标记并添加到最终字符串
  13772. finalString.Append("[++]" + diff.text + "[++]");
  13773. break;
  13774. case Operation.DELETE:
  13775. // 删除的部分,不添加到最终字符串
  13776. //finalString.Append("[++]" + diff.text + "[++]");
  13777. break;
  13778. }
  13779. }
  13780. // 输出变动后的字符串
  13781. return finalString.ToString();
  13782. }
  13783. private class tagContent
  13784. {
  13785. public DateTime Date { get; set; }
  13786. public string StartTag { get; set; }
  13787. public string EndTag { get; set; }
  13788. public string Content { get; set; }
  13789. public static int tagLength { get { return 3; } }
  13790. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13791. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13792. public bool IsFinally { get; set; }
  13793. }
  13794. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13795. {
  13796. var results = new List<string>();
  13797. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13798. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13799. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13800. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13801. string[] strValueArr = new string[1];
  13802. foreach (System.Text.RegularExpressions.Match match in matches)
  13803. {
  13804. var strValue = match.Groups[1].Value;
  13805. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13806. }
  13807. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13808. return results;
  13809. }
  13810. /// <summary>
  13811. /// 导出行程单
  13812. /// </summary>
  13813. /// <param name="dto"></param>
  13814. /// <returns></returns>
  13815. [HttpPost]
  13816. public IActionResult ExportTravel(ExportTravelDto dto)
  13817. {
  13818. var jw = JsonView(false);
  13819. jw.Data = "";
  13820. int diid = 0;
  13821. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13822. if (Find == null)
  13823. {
  13824. jw.Msg = "请选择正确的团组!";
  13825. return Ok(jw);
  13826. }
  13827. else
  13828. {
  13829. diid = Find.Id;
  13830. }
  13831. //数据源
  13832. var _travelList = new List<Grp_TravelList>();
  13833. DataTable dtBlack = null;
  13834. try
  13835. {
  13836. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13837. }
  13838. catch (Exception)
  13839. {
  13840. jw.Msg = "机票黑屏代码有误!";
  13841. return Ok(jw);
  13842. }
  13843. string CityStr = string.Empty;
  13844. if (dtBlack.Rows.Count == 0)
  13845. {
  13846. jw.Msg = "机票黑屏代码有误!";
  13847. return Ok(jw);
  13848. }
  13849. else
  13850. {
  13851. foreach (DataRow row in dtBlack.Rows)
  13852. {
  13853. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13854. {
  13855. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13856. return Ok(jw);
  13857. }
  13858. }
  13859. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13860. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13861. }
  13862. // 指定的文字
  13863. var targetTextDic = new Dictionary<string, List<string>>();
  13864. //创建数据源Table
  13865. var dtSource = new DataTable();
  13866. dtSource.Columns.Add("Days", typeof(string));
  13867. dtSource.Columns.Add("Date", typeof(string));
  13868. dtSource.Columns.Add("Week", typeof(string));
  13869. dtSource.Columns.Add("Traffic", typeof(string));
  13870. dtSource.Columns.Add("Trip", typeof(string));
  13871. //获取数据,放到datatable
  13872. foreach (var item in _travelList)
  13873. {
  13874. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13875. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13876. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13877. .Replace("[++]", string.Empty);
  13878. DataRow dr = dtSource.NewRow();
  13879. dr["Days"] = item.Days;
  13880. dr["Date"] = item.Date;
  13881. dr["Week"] = item.WeekDay;
  13882. dr["Traffic"] = item.Traffic_First
  13883. + "\r\n"
  13884. + item.Traffic_Second;
  13885. dr["Trip"] = item.Trip;
  13886. dtSource.Rows.Add(dr);
  13887. }
  13888. var dic = new Dictionary<string, string>
  13889. {
  13890. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  13891. { "City", CityStr },
  13892. { "Days", Find.VisitDays.ToString() },
  13893. { "DeleCode", Find.TourCode },
  13894. { "Pnum", Find.VisitPNumber.ToString() }
  13895. };
  13896. //模板路径
  13897. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13898. //载入模板
  13899. Document doc = null;
  13900. DocumentBuilder builder = null;
  13901. try
  13902. {
  13903. //载入模板
  13904. doc = new Document(tempPath);
  13905. builder = new DocumentBuilder(doc);
  13906. }
  13907. catch (Exception)
  13908. {
  13909. jw.Msg = "模板位置不存在!";
  13910. return Ok(jw);
  13911. }
  13912. foreach (var key in dic.Keys)
  13913. {
  13914. Bookmark bookmark = doc.Range.Bookmarks[key];
  13915. if (bookmark != null)
  13916. {
  13917. builder.MoveToBookmark(key);
  13918. builder.Write(dic[key]);
  13919. }
  13920. }
  13921. //获取word里所有表格
  13922. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13923. //获取所填表格的序数
  13924. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13925. try
  13926. {
  13927. //循环赋值
  13928. for (int i = 0; i < dtSource.Rows.Count; i++)
  13929. {
  13930. builder.MoveToCell(0, i + 1, 0, 0);
  13931. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13932. builder.MoveToCell(0, i + 1, 1, 0);
  13933. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13934. builder.MoveToCell(0, i + 1, 2, 0);
  13935. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13936. var trip = dtSource.Rows[i]["Trip"].ToString();
  13937. builder.MoveToCell(0, i + 1, 3, 0);
  13938. builder.Write(trip);
  13939. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13940. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13941. // 获取特定索引的段落
  13942. Paragraph paragraph = (Paragraph)paragraphs[0];
  13943. Run run = paragraph.Runs[0];
  13944. Aspose.Words.Font font = run.Font;
  13945. font.Name = "黑体";
  13946. //设置双休红色
  13947. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13948. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13949. paragraph = (Paragraph)paragraphs[1];
  13950. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13951. {
  13952. run = paragraph.Runs[0];
  13953. font = run.Font;
  13954. font.Color = Color.Red;
  13955. }
  13956. }
  13957. }
  13958. catch (Exception ex)
  13959. {
  13960. }
  13961. //删除多余行
  13962. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13963. {
  13964. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13965. }
  13966. var targetTextList = new List<string>();
  13967. // 遍历文档中的表格
  13968. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13969. {
  13970. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13971. {
  13972. var cellIndex = 0;
  13973. foreach (Cell cell in row.Cells)
  13974. {
  13975. if (cellIndex == 1 && row.Cells.Count == 4)
  13976. {
  13977. foreach (var target in targetTextDic.Keys)
  13978. {
  13979. if (cell.GetText().Contains(target))
  13980. {
  13981. targetTextList = targetTextDic[target];
  13982. break;
  13983. }
  13984. }
  13985. }
  13986. // 遍历单元格中的所有段落
  13987. foreach (Paragraph paragraph in cell.Paragraphs)
  13988. {
  13989. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13990. var runs = new List<Run>();
  13991. foreach (Run run in paragraph.Runs)
  13992. {
  13993. runs.Add(run);
  13994. }
  13995. foreach (Run run in runs)
  13996. {
  13997. foreach (var targetText in targetTextList)
  13998. {
  13999. // 检查文字是否包含指定文字
  14000. if (run.Text.Contains(targetText))
  14001. {
  14002. // 将包含的部分设置为红色
  14003. HighlightText(run, targetText, Color.Red);
  14004. }
  14005. }
  14006. }
  14007. }
  14008. cellIndex++;
  14009. }
  14010. }
  14011. }
  14012. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14013. if (!Directory.Exists(savePath))
  14014. {
  14015. try
  14016. {
  14017. Directory.CreateDirectory(savePath);
  14018. }
  14019. catch
  14020. {
  14021. }
  14022. }
  14023. string path = savePath + Find.TeamName + "出访日程";
  14024. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14025. try
  14026. {
  14027. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14028. string postfix = ".docx";
  14029. if (dto.IsPDF == 1)
  14030. {
  14031. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14032. postfix = ".pdf";
  14033. }
  14034. doc.Save(path + postfix, saveFormat);
  14035. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14036. }
  14037. catch (Exception)
  14038. {
  14039. jw = JsonView(false);
  14040. }
  14041. return Ok(jw);
  14042. }
  14043. /// <summary>
  14044. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14045. /// </summary>
  14046. /// <param name="num"></param>
  14047. /// <returns></returns>
  14048. static string GetNum(string num)
  14049. {
  14050. string str = "";
  14051. switch (num)
  14052. {
  14053. case "1":
  14054. str = "一";
  14055. break;
  14056. case "2":
  14057. str = "二";
  14058. break;
  14059. case "3":
  14060. str = "三";
  14061. break;
  14062. case "4":
  14063. str = "四";
  14064. break;
  14065. case "5":
  14066. str = "五";
  14067. break;
  14068. case "6":
  14069. str = "六";
  14070. break;
  14071. case "7":
  14072. str = "七";
  14073. break;
  14074. case "8":
  14075. str = "八";
  14076. break;
  14077. case "9":
  14078. str = "九";
  14079. break;
  14080. case "10":
  14081. str = "十";
  14082. break;
  14083. case "11":
  14084. str = "十一";
  14085. break;
  14086. case "12":
  14087. str = "十二";
  14088. break;
  14089. case "一":
  14090. str = "1";
  14091. break;
  14092. case "二":
  14093. str = "2";
  14094. break;
  14095. case "三":
  14096. str = "3";
  14097. break;
  14098. case "四":
  14099. str = "4";
  14100. break;
  14101. case "五":
  14102. str = "5";
  14103. break;
  14104. case "六":
  14105. str = "6";
  14106. break;
  14107. case "七":
  14108. str = "7";
  14109. break;
  14110. case "八":
  14111. str = "8";
  14112. break;
  14113. case "九":
  14114. str = "9";
  14115. break;
  14116. case "十":
  14117. str = "10";
  14118. break;
  14119. case "十一":
  14120. str = "11";
  14121. break;
  14122. case "十二":
  14123. str = "12";
  14124. break;
  14125. }
  14126. return str;
  14127. }
  14128. /// <summary>
  14129. /// 高亮包含指定文字的部分
  14130. /// </summary>
  14131. /// <param name="run"></param>
  14132. /// <param name="targetText"></param>
  14133. /// <param name="color"></param>
  14134. static void HighlightText(Run run, string targetText, Color color)
  14135. {
  14136. string text = run.Text;
  14137. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14138. if (startIndex >= 0)
  14139. {
  14140. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14141. // 前部分
  14142. if (startIndex > 0)
  14143. {
  14144. Run beforeRun = (Run)run.Clone(true);
  14145. beforeRun.Text = text.Substring(0, startIndex);
  14146. parentParagraph.InsertBefore(beforeRun, run);
  14147. }
  14148. // 匹配部分
  14149. Run matchRun = (Run)run.Clone(true);
  14150. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14151. matchRun.Font.Color = color;
  14152. parentParagraph.InsertBefore(matchRun, run);
  14153. // 后部分
  14154. if (startIndex + targetText.Length < text.Length)
  14155. {
  14156. Run afterRun = (Run)run.Clone(true);
  14157. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14158. parentParagraph.InsertBefore(afterRun, run);
  14159. }
  14160. // 删除原始Run
  14161. run.Remove();
  14162. }
  14163. }
  14164. #endregion
  14165. #endregion
  14166. #region 团组成本
  14167. /// <summary>
  14168. /// 团组成本数据初始化
  14169. /// </summary>
  14170. /// <param name="dto"></param>
  14171. /// <returns></returns>
  14172. [HttpPost]
  14173. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14174. {
  14175. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14176. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14177. WHEN COUNT(*) >= 0 THEN 'True'
  14178. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14179. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14180. ").ToList(); //团组列表
  14181. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14182. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14183. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14184. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14185. if (groupinfoValue != null)
  14186. {
  14187. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14188. var spArr = new string[1] { countryArr };
  14189. if (countryArr.Contains("|"))
  14190. {
  14191. spArr = countryArr.Split("|");
  14192. }
  14193. else if (countryArr.Contains("、"))
  14194. {
  14195. spArr = countryArr.Split("、");
  14196. }
  14197. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14198. {
  14199. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14200. if (dbQueryCountry != null)
  14201. {
  14202. visaCountryInfoArr.Add(dbQueryCountry);
  14203. }
  14204. }
  14205. }
  14206. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14207. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14208. #region 屏蔽黑屏代码生成
  14209. //var create = _GroupCostRepository.
  14210. // CreateGroupCostByBlackCode(dto.Diid);
  14211. //if (groupCost.Count == 0 && create.Code == 0)
  14212. //{
  14213. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14214. //}
  14215. #endregion
  14216. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14217. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14218. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14219. groupCostMap = groupCostMap.Select(x =>
  14220. {
  14221. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14222. {
  14223. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14224. }
  14225. return x;
  14226. }).ToList();
  14227. //GroupCostParameter.Add(new
  14228. // Grp_GroupCostParameter());
  14229. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14230. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14231. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14232. return Ok(JsonView(new
  14233. {
  14234. groupList,
  14235. groupInfo,
  14236. groupChecks,
  14237. groupCost = groupCostMap,
  14238. hotelNumber,
  14239. GroupCostParameter = GroupCostParameterMap,
  14240. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14241. {
  14242. x.VisaCountry,
  14243. x.VisaPrice,
  14244. x.Id,
  14245. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14246. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14247. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14248. x.VisaTime, // 一般签证时间
  14249. x.PettyBusinessAgencyFee, //小公务代办费
  14250. x.GrandBusinessAgencyFee //大公务代办费
  14251. }).ToList(),
  14252. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14253. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14254. hotelIsTrue,
  14255. groupModuleOperators
  14256. }));
  14257. }
  14258. /// <summary>
  14259. /// 团组成本信息保存
  14260. /// </summary>
  14261. /// <param name="dto"></param>
  14262. /// <returns></returns>
  14263. [HttpPost]
  14264. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14265. {
  14266. if (dto.Diid <= 0 || dto.Userid <= 0)
  14267. {
  14268. return Ok(JsonView(false));
  14269. }
  14270. JsonView jw = null;
  14271. bool isTrue = false;
  14272. #region 复制团组成本
  14273. //if (dto.Diid == 2581)
  14274. //{
  14275. // dto.Diid = 2599;
  14276. // dto.CheckBoxs.ForEach(x =>
  14277. // {
  14278. // x.Diid = 2599;
  14279. // });
  14280. // dto.GroupCosts.ForEach(x =>
  14281. // {
  14282. // x.Diid = 2599;
  14283. // });
  14284. // dto.CostTypeHotelNumbers.ForEach(x =>
  14285. // {
  14286. // x.Diid = 2599;
  14287. // });
  14288. // dto.GroupCostParameters.ForEach(x =>
  14289. // {
  14290. // x.DiId = 2599;
  14291. // });
  14292. //}
  14293. #endregion
  14294. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14295. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14296. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14297. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14298. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14299. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14300. try
  14301. {
  14302. _sqlSugar.BeginTran();
  14303. isTrue = await _GroupCostRepository.
  14304. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14305. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14306. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14307. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14308. _sqlSugar.CommitTran();
  14309. jw = JsonView(true, "保存成功!", isTrue);
  14310. }
  14311. catch (Exception)
  14312. {
  14313. _sqlSugar.RollbackTran();
  14314. jw = JsonView(false);
  14315. }
  14316. return Ok(jw);
  14317. }
  14318. /// <summary>
  14319. /// 复制团组成本信息
  14320. /// </summary>
  14321. /// <param name="dto"></param>
  14322. /// <returns></returns>
  14323. [HttpPost]
  14324. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14325. {
  14326. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14327. {
  14328. return Ok(JsonView(false, "参数有误!"));
  14329. }
  14330. #region 复制团组成本
  14331. dto.Diid = dto.ToGroupId;
  14332. dto.CheckBoxs.ForEach(x =>
  14333. {
  14334. x.Diid = dto.ToGroupId;
  14335. });
  14336. dto.GroupCosts.ForEach(x =>
  14337. {
  14338. x.Diid = dto.ToGroupId;
  14339. });
  14340. dto.CostTypeHotelNumbers.ForEach(x =>
  14341. {
  14342. x.Diid = dto.ToGroupId;
  14343. });
  14344. dto.GroupCostParameters.ForEach(x =>
  14345. {
  14346. x.DiId = dto.ToGroupId;
  14347. });
  14348. #endregion
  14349. JsonView jw = null;
  14350. bool isTrue = false;
  14351. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14352. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14353. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14354. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14355. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14356. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14357. try
  14358. {
  14359. _sqlSugar.BeginTran();
  14360. isTrue = await _GroupCostRepository.
  14361. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14362. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14363. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14364. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14365. _sqlSugar.CommitTran();
  14366. jw = JsonView(true, "保存成功!", isTrue);
  14367. }
  14368. catch (Exception)
  14369. {
  14370. _sqlSugar.RollbackTran();
  14371. jw = JsonView(false);
  14372. }
  14373. return Ok(jw);
  14374. }
  14375. /// <summary>
  14376. /// 司兼导数据
  14377. /// </summary>
  14378. /// <param name="dto"></param>
  14379. /// <returns></returns>
  14380. [HttpPost]
  14381. public IActionResult GetCarGuides(CarGuidesDto dto)
  14382. {
  14383. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14384. return Ok(JsonView(true, "获取成功!", Data));
  14385. }
  14386. /// <summary>
  14387. /// 导游数据
  14388. /// </summary>
  14389. /// <param name="dto"></param>
  14390. /// <returns></returns>
  14391. [HttpPost]
  14392. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14393. {
  14394. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14395. // 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
  14396. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14397. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14398. return Ok(JsonView(true, "获取成功!", Data));
  14399. }
  14400. /// <summary>
  14401. /// 成本车数据
  14402. /// </summary>
  14403. /// <param name="dto"></param>
  14404. /// <returns></returns>
  14405. [HttpPost]
  14406. public IActionResult GetCarInfo(CarGuidesDto dto)
  14407. {
  14408. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14409. return Ok(JsonView(true, "获取成功!", Data));
  14410. }
  14411. /// <summary>
  14412. /// 景点数据
  14413. /// </summary>
  14414. /// <param name="dto"></param>
  14415. /// <returns></returns>
  14416. [HttpPost]
  14417. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14418. {
  14419. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14420. return Ok(JsonView(true, "获取成功!", Data));
  14421. }
  14422. /// <summary>
  14423. /// 成本通知
  14424. /// </summary>
  14425. /// <param name="dto"></param>
  14426. /// <returns></returns>
  14427. [HttpPost]
  14428. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14429. {
  14430. if (dto.Diid < 0)
  14431. {
  14432. return Ok(JsonView(false));
  14433. }
  14434. JsonView jw;
  14435. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14436. if (GroupCostParameter != null)
  14437. {
  14438. int IsShare = 0;
  14439. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14440. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14441. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14442. string msg = string.Empty;
  14443. if (isTrue)
  14444. {
  14445. if (IsShare == 0)
  14446. {
  14447. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14448. }
  14449. else
  14450. {
  14451. #region 企微通知对应岗位用户
  14452. try
  14453. {
  14454. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14455. }
  14456. catch (Exception)
  14457. {
  14458. }
  14459. #endregion
  14460. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14461. }
  14462. jw = JsonView(isTrue, msg, new { IsShare });
  14463. }
  14464. else
  14465. {
  14466. msg = "修改失败!";
  14467. jw = JsonView(isTrue, msg);
  14468. }
  14469. }
  14470. else
  14471. {
  14472. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14473. }
  14474. return Ok(jw);
  14475. }
  14476. /// <summary>
  14477. /// 导出报价单
  14478. /// </summary>
  14479. /// <param name="dto"></param>
  14480. /// <returns></returns>
  14481. [HttpPost]
  14482. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14483. {
  14484. if (dto.Diid == 0)
  14485. {
  14486. return Ok(JsonView(false, "请传递团组id"));
  14487. }
  14488. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14489. if (deleInfo.Code != 0)
  14490. {
  14491. return Ok(JsonView(false, "团组信息查询失败!"));
  14492. }
  14493. var di = deleInfo.Data as DelegationInfoWebView;
  14494. if (di != null)
  14495. {
  14496. di.TeamName = di.TeamName.Replace("|", "、");
  14497. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14498. //文件名
  14499. string strFileName = di.TeamName + "-收款账单.doc";
  14500. //获取模板
  14501. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14502. //载入模板
  14503. Document doc = new Document(tmppath);
  14504. decimal TotalPrice = 0.00M;
  14505. string itemStr = string.Empty;
  14506. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14507. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14508. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14509. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14510. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14511. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14512. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14513. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14514. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14515. foreach (var cost in groupCostType)
  14516. {
  14517. var List = cost.ToList();
  14518. if (cost.Key == "A")
  14519. {
  14520. foreach (var ListItem in List)
  14521. {
  14522. if (ListItem.number > 0)
  14523. {
  14524. if (ListItem.code.Contains("TBR"))
  14525. {
  14526. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14527. }
  14528. else
  14529. {
  14530. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14531. }
  14532. TotalPrice += (ListItem.number * ListItem.price);
  14533. }
  14534. }
  14535. }
  14536. else
  14537. {
  14538. itemStr = itemStr.Insert(0, "A段\r\n");
  14539. itemStr += "B段\r\n";
  14540. foreach (var ListItem in List)
  14541. {
  14542. if (ListItem.number > 0)
  14543. {
  14544. if (ListItem.code.Contains("TBR"))
  14545. {
  14546. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14547. }
  14548. else
  14549. {
  14550. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14551. }
  14552. TotalPrice += (ListItem.number * ListItem.price);
  14553. }
  14554. }
  14555. }
  14556. }
  14557. #region 替换Word模板书签内容
  14558. Dictionary<string, string> marks = new Dictionary<string, string>();
  14559. marks.Add("To", di.ClientUnit);//付款方
  14560. marks.Add("ToTel", di.TellPhone);//付款方电话
  14561. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14562. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14563. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14564. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14565. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14566. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14567. marks.Add("PayItemContent", itemStr);//详细信息
  14568. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14569. #endregion
  14570. ////注
  14571. //if (doc.Range.Bookmarks["Attention"] != null)
  14572. //{
  14573. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14574. // mark.Text = frList[0].Attention;
  14575. //}
  14576. foreach (var item in marks.Keys)
  14577. {
  14578. if (doc.Range.Bookmarks[item] != null)
  14579. {
  14580. Bookmark mark = doc.Range.Bookmarks[item];
  14581. mark.Text = marks[item];
  14582. }
  14583. }
  14584. byte[] bytes = null;
  14585. using (MemoryStream stream = new MemoryStream())
  14586. {
  14587. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14588. bytes = stream.ToArray();
  14589. }
  14590. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14591. return Ok(JsonView(true, "", new
  14592. {
  14593. Data = bytes,
  14594. strFileName,
  14595. }));
  14596. }
  14597. else
  14598. {
  14599. return Ok(JsonView(false, "团组信息不存在!"));
  14600. }
  14601. }
  14602. /// <summary>
  14603. /// 导出团组成本
  14604. /// </summary>
  14605. /// <param name="dto"></param>
  14606. /// <returns></returns>
  14607. [HttpPost]
  14608. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14609. {
  14610. var jw = JsonView(false);
  14611. if (dto.Diid == 0)
  14612. {
  14613. return Ok(JsonView(false, "请传递团组id"));
  14614. }
  14615. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14616. if (deleInfo.Code != 0)
  14617. {
  14618. return Ok(JsonView(false, "团组信息查询失败!"));
  14619. }
  14620. var di = deleInfo.Data as DelegationInfoWebView;
  14621. if (di == null)
  14622. {
  14623. return Ok(JsonView(false, "团组信息查询失败!"));
  14624. }
  14625. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14626. WorkbookDesigner designer = new WorkbookDesigner();
  14627. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14628. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14629. List<int> hideColumnList = new List<int>();
  14630. var ColumnSetting = new[]
  14631. {
  14632. new { tag = "VF", Index = 4, P = "CarCost" },
  14633. new { tag = "VN", Index = 5, P = "CarNumber" },
  14634. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14635. new { tag = "T/G S", Index = 7, P = "TGS" },
  14636. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14637. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14638. new { tag = "T/G M", Index = 10, P = "TGM" },
  14639. new { tag = "T/G A", Index = 11, P = "TGA" },
  14640. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14641. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14642. new { tag = "C/F S", Index = 14, P = "CFS" },
  14643. new { tag = "C/F M", Index = 15, P = "CFM" },
  14644. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14645. new { tag = "B", Index = 17, P = "B" },
  14646. new { tag = "L", Index = 18, P = "L" },
  14647. new { tag = "D", Index = 19, P = "D" },
  14648. new { tag = "TBR", Index = 20, P = "TBR" },
  14649. new { tag = "SGR", Index = 21, P = "SGR" },
  14650. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14651. new { tag = "Suite", Index = 23, P = "Suite" },
  14652. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14653. new { tag = "T/V", Index = 25, P = "TV" },
  14654. new { tag = "1/L", Index = 26, P = "iL" },
  14655. new { tag = "I/F", Index = 27, P = "IF" },
  14656. new { tag = "EF", Index = 28, P = "EF" },
  14657. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14658. new { tag = "TE", Index = 30, P = "TE" },
  14659. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14660. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14661. new { tag = "P/C", Index = 33, P = "PC" },
  14662. new { tag = "T/L F", Index = 34, P = "TLF" },
  14663. new { tag = "E/C T", Index = 35, P = "ECT" }
  14664. };
  14665. Func<string, bool> isEmpty = (str) =>
  14666. {
  14667. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14668. {
  14669. return true;
  14670. }
  14671. if (string.IsNullOrWhiteSpace(str))
  14672. {
  14673. return true;
  14674. }
  14675. return false;
  14676. };
  14677. for (int i = 0; i < List_GC.Count; i++)
  14678. {
  14679. GroupCost_Excel gc = new GroupCost_Excel();
  14680. gc.Id = List_GC[i].Id;
  14681. gc.Diid = List_GC[i].Diid.ToString();
  14682. gc.DAY = List_GC[i].DAY;
  14683. string week = "";
  14684. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14685. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14686. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14687. gc.ITIN = List_GC[i].ITIN;
  14688. gc.CarType = List_GC[i].CarType;
  14689. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14690. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14691. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14692. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14693. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14694. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14695. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14696. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14697. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14698. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14699. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14700. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14701. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14702. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14703. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14704. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14705. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14706. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14707. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14708. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  14709. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  14710. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  14711. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  14712. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  14713. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  14714. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  14715. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  14716. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  14717. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  14718. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  14719. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  14720. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  14721. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  14722. gc.EFR = List_GC[i].EFR;
  14723. List_GC1.Add(gc);
  14724. }
  14725. if (List_GC1.Count > 0)
  14726. {
  14727. var p = List_GC1[0];
  14728. var prs = p.GetType().GetProperties();
  14729. foreach (var item in prs)
  14730. {
  14731. var tp = item.PropertyType;
  14732. if (tp == typeof(int))
  14733. {
  14734. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  14735. if (val == 0)
  14736. {
  14737. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14738. if (columnSetting != null)
  14739. {
  14740. hideColumnList.Add(columnSetting.Index);
  14741. }
  14742. }
  14743. }
  14744. if (tp == typeof(decimal))
  14745. {
  14746. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  14747. if (val == 0)
  14748. {
  14749. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14750. if (columnSetting != null)
  14751. {
  14752. hideColumnList.Add(columnSetting.Index);
  14753. }
  14754. }
  14755. }
  14756. if (tp == typeof(string))
  14757. {
  14758. var val = List_GC1.Sum(x =>
  14759. {
  14760. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  14761. if (decimal.TryParse(str, out decimal str_De))
  14762. {
  14763. return str_De;
  14764. }
  14765. else
  14766. {
  14767. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  14768. }
  14769. });
  14770. if (val == 0)
  14771. {
  14772. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14773. if (columnSetting != null)
  14774. {
  14775. hideColumnList.Add(columnSetting.Index);
  14776. }
  14777. }
  14778. }
  14779. }
  14780. }
  14781. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14782. dt.TableName = "TB";
  14783. //报表标题等不用dt的值
  14784. designer.SetDataSource("TeamName", dto.title.TeamName);
  14785. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14786. designer.SetDataSource("Tax", dto.title.Tax);
  14787. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14788. designer.SetDataSource("Currency", dto.title.Currency);
  14789. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14790. designer.SetDataSource("Rate", dto.title.Rate);
  14791. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14792. var Aparams = hotels.Find(x => x.Type == "Default");
  14793. if (Aparams == null)
  14794. {
  14795. return Ok(jw);
  14796. }
  14797. //酒店数量
  14798. var txtSGRNumber = Aparams.SGR.ToString();
  14799. var txtTBRNumber = Aparams.TBR.ToString();
  14800. var txtJSESNumber = Aparams.JSES.ToString();
  14801. var txtSUITENumbe = Aparams.SUITE.ToString();
  14802. if (dto.costType == "B")
  14803. {
  14804. Aparams = hotels.Find(x => x.Type == "A");
  14805. var Bparams = hotels.Find(x => x.Type == "B");
  14806. if (Aparams == null || Bparams == null)
  14807. {
  14808. return Ok(jw);
  14809. }
  14810. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14811. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14812. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14813. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14814. }
  14815. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14816. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14817. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14818. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14819. var ws = designer.Workbook.Worksheets[1];
  14820. int Row = List_GC.Count;
  14821. int startIndex = 0;
  14822. int HideRows = 0;
  14823. Row = 0;
  14824. List<int> hideRowsList = new List<int>();
  14825. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14826. #region A段left数据
  14827. var left = dto.leftInfo.Find(x => x.Type == "A");
  14828. if (left == null)
  14829. {
  14830. return Ok(jw);
  14831. }
  14832. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14833. if (leftBindData != null)
  14834. {
  14835. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14836. designer.SetDataSource("VisaRS", leftBindData.rs);
  14837. designer.SetDataSource("VisaXS", leftBindData.xs);
  14838. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14839. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14840. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14841. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14842. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14843. }
  14844. else
  14845. {
  14846. hideRowsList.Add(Row + startIndex + HideRows);
  14847. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14848. }
  14849. HideRows += 2;
  14850. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14851. if (leftBindData != null)
  14852. {
  14853. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14854. designer.SetDataSource("BXRS", leftBindData.rs);
  14855. designer.SetDataSource("BXXS", leftBindData.xs);
  14856. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14857. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14858. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14859. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14860. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14861. }
  14862. else
  14863. {
  14864. hideRowsList.Add(Row + startIndex + HideRows);
  14865. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14866. }
  14867. HideRows += 2;
  14868. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14869. if (leftBindData != null)
  14870. {
  14871. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14872. designer.SetDataSource("HSRS", leftBindData.rs);
  14873. designer.SetDataSource("HSXS", leftBindData.xs);
  14874. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14875. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14876. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14877. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14878. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14879. }
  14880. else
  14881. {
  14882. hideRowsList.Add(Row + startIndex + HideRows);
  14883. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14884. }
  14885. HideRows += 2;
  14886. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14887. if (leftBindData != null)
  14888. {
  14889. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14890. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14891. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14892. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14893. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14894. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14895. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14896. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14897. }
  14898. else
  14899. {
  14900. hideRowsList.Add(Row + startIndex + HideRows);
  14901. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14902. }
  14903. HideRows += 2;
  14904. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14905. if (leftBindData != null)
  14906. {
  14907. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14908. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14909. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14910. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14911. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14912. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14913. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14914. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14915. }
  14916. else
  14917. {
  14918. hideRowsList.Add(Row + startIndex + HideRows);
  14919. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14920. }
  14921. HideRows += 2;
  14922. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14923. if (leftBindData != null)
  14924. {
  14925. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14926. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14927. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14928. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14929. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14930. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14931. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14932. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14933. }
  14934. else
  14935. {
  14936. hideRowsList.Add(Row + startIndex + HideRows);
  14937. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14938. }
  14939. HideRows += 2;
  14940. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14941. if (leftBindData != null)
  14942. {
  14943. ////TBR
  14944. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14945. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14946. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14947. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14948. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14949. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14950. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14951. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14952. }
  14953. else
  14954. {
  14955. hideRowsList.Add(Row + startIndex + HideRows);
  14956. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14957. }
  14958. HideRows += 2;
  14959. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14960. if (leftBindData != null)
  14961. {
  14962. ////SGR
  14963. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14964. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14965. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14966. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14967. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14968. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14969. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14970. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14971. }
  14972. else
  14973. {
  14974. hideRowsList.Add(Row + startIndex + HideRows);
  14975. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14976. }
  14977. HideRows += 2;
  14978. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14979. if (leftBindData != null)
  14980. {
  14981. ////JS/ES
  14982. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14983. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14984. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14985. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14986. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14987. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14988. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14989. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14990. }
  14991. else
  14992. {
  14993. hideRowsList.Add(Row + startIndex + HideRows);
  14994. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14995. }
  14996. HideRows += 2;
  14997. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14998. if (leftBindData != null)
  14999. {
  15000. ////SUITE
  15001. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15002. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15003. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15004. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15005. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15006. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15007. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15008. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15009. }
  15010. else
  15011. {
  15012. hideRowsList.Add(Row + startIndex + HideRows);
  15013. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15014. }
  15015. HideRows += 2;
  15016. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15017. if (leftBindData != null)
  15018. {
  15019. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15020. designer.SetDataSource("DJRS", leftBindData.rs);
  15021. designer.SetDataSource("DJXS", leftBindData.xs);
  15022. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15023. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15024. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15025. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15026. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15027. }
  15028. else
  15029. {
  15030. hideRowsList.Add(Row + startIndex + HideRows);
  15031. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15032. }
  15033. HideRows += 2;
  15034. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15035. if (leftBindData != null)
  15036. {
  15037. designer.SetDataSource("HCPCB", leftBindData.cb);
  15038. designer.SetDataSource("HCPRS", leftBindData.rs);
  15039. designer.SetDataSource("HCPXS", leftBindData.xs);
  15040. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15041. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15042. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15043. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15044. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15045. }
  15046. else
  15047. {
  15048. hideRowsList.Add(Row + startIndex + HideRows);
  15049. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15050. }
  15051. HideRows += 2;
  15052. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15053. if (leftBindData != null)
  15054. {
  15055. designer.SetDataSource("CPCB", leftBindData.cb);
  15056. designer.SetDataSource("CPRS", leftBindData.rs);
  15057. designer.SetDataSource("CPXS", leftBindData.xs);
  15058. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15059. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15060. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15061. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15062. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15063. }
  15064. else
  15065. {
  15066. hideRowsList.Add(Row + startIndex + HideRows);
  15067. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15068. }
  15069. HideRows += 2;
  15070. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15071. if (leftBindData != null)
  15072. {
  15073. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15074. designer.SetDataSource("GWRS", leftBindData.rs);
  15075. designer.SetDataSource("GWXS", leftBindData.xs);
  15076. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15077. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15078. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15079. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15080. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15081. }
  15082. else
  15083. {
  15084. hideRowsList.Add(Row + startIndex + HideRows);
  15085. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15086. }
  15087. HideRows += 2;
  15088. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15089. if (leftBindData != null)
  15090. {
  15091. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15092. designer.SetDataSource("LYJRS", leftBindData.rs);
  15093. designer.SetDataSource("LYJXS", leftBindData.xs);
  15094. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15095. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15096. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15097. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15098. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15099. }
  15100. else
  15101. {
  15102. hideRowsList.Add(Row + startIndex + HideRows);
  15103. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15104. }
  15105. #endregion
  15106. #region A段Right信息
  15107. var right = dto.rightInfo.Find(x => x.Type == "A");
  15108. if (right == null)
  15109. {
  15110. return Ok(jw);
  15111. }
  15112. HideRows += 4;
  15113. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15114. if (rightBindData != null)
  15115. {
  15116. //经济舱 + 双人间 TBR
  15117. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15118. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15119. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15120. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15121. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15122. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15123. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15124. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15125. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15126. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15127. }
  15128. else
  15129. {
  15130. hideRowsList.Add(Row + startIndex + HideRows);
  15131. }
  15132. HideRows += 2;
  15133. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15134. if (rightBindData != null)
  15135. {
  15136. //经济舱 + 单人间 SGR
  15137. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15138. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15139. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15140. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15141. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15142. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15143. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15144. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15145. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15146. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15147. }
  15148. else
  15149. {
  15150. hideRowsList.Add(Row + startIndex + HideRows);
  15151. }
  15152. HideRows += 2;
  15153. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15154. if (rightBindData != null)
  15155. {
  15156. //公务舱 + 单人间 SGR
  15157. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15158. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15159. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15160. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15161. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15162. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15163. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15164. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15165. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15166. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15167. }
  15168. else
  15169. {
  15170. hideRowsList.Add(Row + startIndex + HideRows);
  15171. }
  15172. HideRows += 2;
  15173. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15174. if (rightBindData != null)
  15175. {
  15176. //公务舱 + 小套房 JSES
  15177. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15178. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15179. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15180. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15181. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15182. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15183. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15184. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15185. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15186. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15187. }
  15188. else
  15189. {
  15190. hideRowsList.Add(Row + startIndex + HideRows);
  15191. }
  15192. HideRows += 2;
  15193. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15194. if (rightBindData != null)
  15195. {
  15196. //公务舱 + 小套房 JSES
  15197. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15198. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15199. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15200. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15201. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15202. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15203. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15204. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15205. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15206. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15207. }
  15208. else
  15209. {
  15210. hideRowsList.Add(Row + startIndex + HideRows);
  15211. }
  15212. HideRows += 2;
  15213. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15214. if (rightBindData != null)
  15215. {
  15216. //经济舱 + 大套房
  15217. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15218. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15219. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15220. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15221. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15222. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15223. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15224. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15225. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15226. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15227. }
  15228. else
  15229. {
  15230. hideRowsList.Add(Row + startIndex + HideRows);
  15231. }
  15232. HideRows += 2;
  15233. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15234. if (rightBindData != null)
  15235. {
  15236. //头等舱 + 小套房 JSES
  15237. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15238. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15239. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15240. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15241. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15242. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15243. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15244. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15245. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15246. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15247. }
  15248. else
  15249. {
  15250. hideRowsList.Add(Row + startIndex + HideRows);
  15251. }
  15252. HideRows += 2;
  15253. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15254. if (rightBindData != null)
  15255. {
  15256. //头等舱 + 大套房
  15257. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15258. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15259. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15260. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15261. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15262. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15263. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15264. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15265. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15266. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15267. }
  15268. else
  15269. {
  15270. hideRowsList.Add(Row + startIndex + HideRows);
  15271. }
  15272. #endregion
  15273. #region B段标题清空
  15274. designer.SetDataSource("CostBDRCB", "");
  15275. designer.SetDataSource("CostBRS", "");
  15276. designer.SetDataSource("CostBXS", "");
  15277. designer.SetDataSource("CostBZCB", "");
  15278. designer.SetDataSource("CostBDRBJ", "");
  15279. designer.SetDataSource("CostBZBJ", "");
  15280. designer.SetDataSource("CostBDRLR", "");
  15281. designer.SetDataSource("CostBZLR", "");
  15282. designer.SetDataSource("CostBDRCBOM", "");
  15283. designer.SetDataSource("CostBRSOM", "");
  15284. designer.SetDataSource("CostBZCBOM", "");
  15285. designer.SetDataSource("CostBDRBJOM", "");
  15286. designer.SetDataSource("CostBZBJOM", "");
  15287. designer.SetDataSource("CostBDRLROM", "");
  15288. designer.SetDataSource("CostBZLROM", "");
  15289. #endregion
  15290. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15291. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15292. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15293. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15294. designer.SetDataSource("DJName", "地接(CNY)");
  15295. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15296. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15297. designer.SetDataSource("GWName", "公务(CNY)");
  15298. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15299. designer.SetDataSource("LYJName", "零用金(CNY)");
  15300. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15301. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15302. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15303. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15304. designer.SetDataSource("BXName", "保险(CNY)");
  15305. designer.SetDataSource("VisaName", "签证(CNY)");
  15306. #region B段基本数据
  15307. if (dto.costType == "B")
  15308. {
  15309. left = dto.leftInfo.Find(x => x.Type == "B");
  15310. if (left == null)
  15311. {
  15312. return Ok(jw);
  15313. }
  15314. #region B段left数据
  15315. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15316. if (leftBindData != null)
  15317. {
  15318. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15319. designer.SetDataSource("BHSRS", leftBindData.rs);
  15320. designer.SetDataSource("BHSXS", leftBindData.xs);
  15321. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15322. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15323. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15324. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15325. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15326. }
  15327. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15328. if (leftBindData != null)
  15329. {
  15330. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15331. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15332. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15333. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15334. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15335. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15336. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15337. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15338. }
  15339. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15340. if (leftBindData != null)
  15341. {
  15342. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15343. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15344. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15345. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15346. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15347. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15348. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15349. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15350. }
  15351. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15352. if (leftBindData != null)
  15353. {
  15354. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15355. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15356. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15357. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15358. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15359. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15360. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15361. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15362. }
  15363. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15364. if (leftBindData != null)
  15365. {
  15366. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15367. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15368. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15369. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15370. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15371. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15372. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15373. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15374. }
  15375. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15376. if (leftBindData != null)
  15377. {
  15378. designer.SetDataSource("BCPCB", leftBindData.cb);
  15379. designer.SetDataSource("BCPRS", leftBindData.rs);
  15380. designer.SetDataSource("BCPXS", leftBindData.xs);
  15381. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15382. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15383. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15384. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15385. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15386. }
  15387. //TBR
  15388. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15389. if (leftBindData != null)
  15390. {
  15391. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15392. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15393. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15394. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15395. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15396. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15397. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15398. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15399. }
  15400. //SGR
  15401. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15402. if (leftBindData != null)
  15403. {
  15404. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15405. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15406. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15407. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15408. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15409. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15410. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15411. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15412. }
  15413. //JS/ES
  15414. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15415. if (leftBindData != null)
  15416. {
  15417. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15418. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15419. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15420. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15421. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15422. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15423. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15424. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15425. }
  15426. //SUITE
  15427. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15428. if (leftBindData != null)
  15429. {
  15430. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15431. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15432. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15433. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15434. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15435. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15436. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15437. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15438. }
  15439. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15440. if (leftBindData != null)
  15441. {
  15442. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15443. designer.SetDataSource("BDJRS", leftBindData.rs);
  15444. designer.SetDataSource("BDJXS", leftBindData.xs);
  15445. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15446. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15447. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15448. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15449. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15450. }
  15451. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15452. if (leftBindData != null)
  15453. {
  15454. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15455. designer.SetDataSource("BGWRS", leftBindData.rs);
  15456. designer.SetDataSource("BGWXS", leftBindData.xs);
  15457. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15458. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15459. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15460. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15461. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15462. }
  15463. #region 优化方案
  15464. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15465. //excelBind.Add("零用金", new {
  15466. //cb="",
  15467. //rs="",
  15468. //xs ="",
  15469. //zcb = "",
  15470. //});
  15471. #endregion
  15472. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15473. if (leftBindData != null)
  15474. {
  15475. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15476. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15477. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15478. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15479. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15480. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15481. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15482. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15483. }
  15484. #endregion
  15485. #region B段Right信息
  15486. right = dto.rightInfo.Find(x => x.Type == "B");
  15487. if (right == null)
  15488. {
  15489. return Ok(jw);
  15490. }
  15491. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15492. if (rightBindData != null)
  15493. {
  15494. //经济舱 + 双人间 TBR
  15495. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15496. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15497. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15498. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15499. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15500. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15501. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15502. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15503. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15504. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15505. }
  15506. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15507. if (rightBindData != null)
  15508. {
  15509. //经济舱 + 单人间 SGR
  15510. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15511. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15512. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15513. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15514. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15515. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15516. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15517. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15518. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15519. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15520. }
  15521. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15522. if (rightBindData != null)
  15523. {
  15524. //公务舱 + 单人间 SGR
  15525. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15526. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15527. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15528. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15529. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15530. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15531. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15532. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15533. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15534. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15535. }
  15536. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15537. if (rightBindData != null)
  15538. {
  15539. //公务舱 + 小套房 JSES
  15540. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15541. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15542. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15543. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15544. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15545. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15546. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15547. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15548. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15549. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15550. }
  15551. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15552. if (rightBindData != null)
  15553. {
  15554. //公务舱 + 小套房 JSES
  15555. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15556. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15557. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15558. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15559. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15560. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15561. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15562. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15563. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15564. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15565. }
  15566. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15567. if (rightBindData != null)
  15568. {
  15569. //经济舱 + 大套房
  15570. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15571. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15572. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15573. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15574. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15575. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15576. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15577. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15578. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15579. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15580. }
  15581. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15582. if (rightBindData != null)
  15583. {
  15584. //头等舱 + 小套房 JSES
  15585. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15586. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15587. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15588. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15589. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15590. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15591. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15592. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15593. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15594. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15595. }
  15596. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15597. if (rightBindData != null)
  15598. {
  15599. //头等舱 + 大套房
  15600. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15601. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15602. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15603. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15604. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15605. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15606. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15607. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15608. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15609. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15610. }
  15611. #endregion
  15612. #region 标题
  15613. designer.SetDataSource("CostBDRCB", "单人成本");
  15614. designer.SetDataSource("CostBRS", "人数");
  15615. designer.SetDataSource("CostBXS", "系数");
  15616. designer.SetDataSource("CostBZCB", "总成本");
  15617. designer.SetDataSource("CostBDRBJ", "单人报价");
  15618. designer.SetDataSource("CostBZBJ", "总报价");
  15619. designer.SetDataSource("CostBDRLR", "单人利润");
  15620. designer.SetDataSource("CostBZLR", "总利润");
  15621. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15622. designer.SetDataSource("CostBRSOM", "人数");
  15623. designer.SetDataSource("CostBZCBOM", "总成本");
  15624. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15625. designer.SetDataSource("CostBZBJOM", "总报价");
  15626. designer.SetDataSource("CostBDRLROM", "单人利润");
  15627. designer.SetDataSource("CostBZLROM", "总利润");
  15628. #endregion
  15629. }
  15630. #endregion
  15631. designer.SetDataSource("TzZCB2", TzZCB2);
  15632. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15633. designer.SetDataSource("TzZLR2", TzZLR2);
  15634. string[] dataSourceKeys = new string[]
  15635. {
  15636. "VF",
  15637. "TGS",
  15638. "TGOF",
  15639. "TGM",
  15640. "TGA",
  15641. "TGTF",
  15642. "TGEF",
  15643. "CFM",
  15644. "CFOF",
  15645. "B",
  15646. "L",
  15647. "D",
  15648. "TBR",
  15649. "SGR",
  15650. "JSES",
  15651. "Suite",
  15652. "TV",
  15653. "1L",
  15654. "IF",
  15655. "EF",
  15656. "BRF",
  15657. "TE",
  15658. "TGT",
  15659. "DRVT",
  15660. "PC",
  15661. "TLF",
  15662. "ECT"
  15663. };
  15664. foreach (var item in dataSourceKeys)
  15665. {
  15666. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15667. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15668. var find = dto.titleModel.FirstOrDefault(expr);
  15669. if (find != null)
  15670. {
  15671. designer.SetDataSource(item, find.text);
  15672. }
  15673. else
  15674. {
  15675. designer.SetDataSource(item, 0);
  15676. }
  15677. }
  15678. designer.SetDataSource(dt);
  15679. //根据数据源处理生成报表内容
  15680. designer.Process();
  15681. designer.Workbook.Worksheets[0].Name = "费用明细";
  15682. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15683. Worksheet sheet = designer.Workbook.Worksheets[0];
  15684. foreach (var Rowindex in hideRowsList)
  15685. {
  15686. ws.Cells.HideRows(Rowindex, 2);
  15687. }
  15688. ws = designer.Workbook.Worksheets[0];
  15689. foreach (var Column in hideColumnList)
  15690. {
  15691. ws.Cells.HideColumns(Column, 1);
  15692. }
  15693. byte[] bytes = null;
  15694. string strFileName = di.TeamName + "-团组-成本.xls";
  15695. using (MemoryStream stream = new MemoryStream())
  15696. {
  15697. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15698. bytes = stream.ToArray();
  15699. }
  15700. return Ok(JsonView(true, "", new
  15701. {
  15702. Data = bytes,
  15703. strFileName,
  15704. }));
  15705. }
  15706. /// <summary>
  15707. /// 导出客户报表
  15708. /// </summary>
  15709. /// <returns></returns>
  15710. [HttpPost]
  15711. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15712. {
  15713. var jw = JsonView(false);
  15714. if (dto.Diid == 0)
  15715. {
  15716. return Ok(JsonView(false, "请传递团组id"));
  15717. }
  15718. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15719. if (deleInfo.Code != 0)
  15720. {
  15721. return Ok(JsonView(false, "团组信息查询失败!"));
  15722. }
  15723. var di = deleInfo.Data as DelegationInfoWebView;
  15724. if (di == null)
  15725. {
  15726. return Ok(JsonView(false, "团组信息查询失败!"));
  15727. }
  15728. //文件名
  15729. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15730. //获取模板
  15731. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15732. //载入模板
  15733. Document doc = new Document(tmppath);
  15734. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15735. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15736. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15737. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15738. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15739. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15740. if (AParameter == null)
  15741. {
  15742. return Ok(JsonView(false, "系数不存在!"));
  15743. }
  15744. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15745. , TzAirDesc, TzZCost;
  15746. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15747. = TzAirDesc = TzZCost = string.Empty;
  15748. TzNumber = AParameter.CostTypenumber.ToString();
  15749. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15750. CarGuides1 = dto.CarGuides1;
  15751. Meal = dto.Meal;
  15752. SubsidizedMeals = dto.SubsidizedMeals;
  15753. NightRepair = dto.NightRepair;
  15754. AttractionsTickets = dto.AttractionsTickets;
  15755. MiscellaneousFees = dto.MiscellaneousFees;
  15756. ATip = dto.ATip;
  15757. TzHotelDesc = "";
  15758. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15759. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15760. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15761. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15762. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15763. TzAirDesc = "";
  15764. TzZCost = dto.TzZCost;
  15765. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15766. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15767. var index = 1;
  15768. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15769. foreach (var item in TzHotelDescArr)
  15770. {
  15771. if (AinfoArr != null)
  15772. {
  15773. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15774. if (Ainfo != null)
  15775. {
  15776. if (int.Parse(Ainfo.rs) <= 0)
  15777. {
  15778. continue;
  15779. }
  15780. var hotelText = string.Empty;
  15781. switch (item)
  15782. {
  15783. case "SGR":
  15784. hotelText = "单人间";
  15785. break;
  15786. case "JSES":
  15787. hotelText = "小套房";
  15788. break;
  15789. case "SUITE":
  15790. hotelText = "套房";
  15791. break;
  15792. case "TBR":
  15793. hotelText = "双人间";
  15794. break;
  15795. }
  15796. if (item != "TBR")
  15797. {
  15798. 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";
  15799. }
  15800. else
  15801. {
  15802. 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";
  15803. }
  15804. index++;
  15805. }
  15806. }
  15807. }
  15808. index = 1;
  15809. foreach (var item in TzAirDescArr)
  15810. {
  15811. if (AinfoArr != null)
  15812. {
  15813. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15814. if (Ainfo != null)
  15815. {
  15816. if (int.Parse(Ainfo.rs) <= 0)
  15817. {
  15818. continue;
  15819. }
  15820. 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";
  15821. index++;
  15822. }
  15823. }
  15824. }
  15825. if (dto.costType == "B")
  15826. {
  15827. if (BParameter == null)
  15828. {
  15829. return Ok(JsonView(false, "B段系数不存在!"));
  15830. }
  15831. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15832. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15833. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15834. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15835. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15836. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15837. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15838. foreach (var item in TzHotelDescArr)
  15839. {
  15840. if (AinfoArr != null)
  15841. {
  15842. TzHotelDesc += "B段信息 \r\n";
  15843. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15844. if (Ainfo != null)
  15845. {
  15846. if (int.Parse(Ainfo.rs) <= 0)
  15847. {
  15848. continue;
  15849. }
  15850. var hotelText = string.Empty;
  15851. switch (item)
  15852. {
  15853. case "SGR":
  15854. hotelText = "单人间";
  15855. break;
  15856. case "JSES":
  15857. hotelText = "小套房";
  15858. break;
  15859. case "SUITE":
  15860. hotelText = "套房";
  15861. break;
  15862. case "TBR":
  15863. hotelText = "双人间";
  15864. break;
  15865. }
  15866. if (item != "TBR")
  15867. {
  15868. 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";
  15869. }
  15870. else
  15871. {
  15872. 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";
  15873. }
  15874. index++;
  15875. }
  15876. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15877. }
  15878. }
  15879. index = 1;
  15880. foreach (var item in TzAirDescArr)
  15881. {
  15882. if (AinfoArr != null)
  15883. {
  15884. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15885. if (Ainfo != null)
  15886. {
  15887. if (int.Parse(Ainfo.rs) <= 0)
  15888. {
  15889. continue;
  15890. }
  15891. 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";
  15892. index++;
  15893. }
  15894. }
  15895. }
  15896. }
  15897. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15898. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15899. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15900. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15901. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15902. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15903. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15904. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15905. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15906. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15907. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15908. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15909. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15910. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15911. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15912. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15913. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15914. DickeyValue.Add("TzZCost", TzZCost);
  15915. foreach (var key in DickeyValue.Keys)
  15916. {
  15917. if (doc.Range.Bookmarks[key] != null)
  15918. {
  15919. Bookmark mark = doc.Range.Bookmarks[key];
  15920. mark.Text = DickeyValue[key];
  15921. }
  15922. }
  15923. byte[] bytes = null;
  15924. string strFileName = di.TeamName + "-客户报价.doc";
  15925. using (MemoryStream stream = new MemoryStream())
  15926. {
  15927. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15928. bytes = stream.ToArray();
  15929. }
  15930. return Ok(JsonView(true, "", new
  15931. {
  15932. Data = bytes,
  15933. strFileName,
  15934. }));
  15935. }
  15936. /// <summary>
  15937. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15938. /// </summary>
  15939. /// <param name="dto"></param>
  15940. /// <returns></returns>
  15941. [HttpPost]
  15942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15943. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15944. {
  15945. try
  15946. {
  15947. #region 参数验证
  15948. if (dto.DiId < 0)
  15949. {
  15950. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15951. }
  15952. List<int> cTableIds = new List<int>() {
  15953. 76 ,//酒店预订
  15954. 77 ,//行程
  15955. 79 ,//车/导游地接
  15956. 80 ,//签证
  15957. 81 ,//邀请/公务活
  15958. 82 ,//团组客户保险
  15959. 85 ,//机票预订
  15960. 98 ,//其他款项
  15961. 285 ,//收款退还
  15962. 751 ,//酒店早餐
  15963. 1015 // 超支费用
  15964. };
  15965. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15966. {
  15967. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15968. }
  15969. #endregion
  15970. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15971. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15972. if (_GroupCostParameters.Count <= 0)
  15973. {
  15974. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15975. }
  15976. if (_GroupCostParameters[0].IsShare == 0)
  15977. {
  15978. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15979. }
  15980. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15981. //处理date为空问题
  15982. if (_GroupCosts.Count > 0)
  15983. {
  15984. for (int i = 0; i < _GroupCosts.Count; i++)
  15985. {
  15986. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15987. {
  15988. if (i > 0)
  15989. {
  15990. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15991. }
  15992. }
  15993. }
  15994. }
  15995. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15996. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15997. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15998. string currCode = "";
  15999. #region currCode 验证
  16000. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16001. if (isInt)
  16002. {
  16003. var currData = currDatas.Find(it => it.Id == intCurrency);
  16004. if (currData != null)
  16005. {
  16006. currCode = currData.Name;
  16007. }
  16008. }
  16009. else
  16010. {
  16011. currCode = _GroupCostParameters[0].Currency.Trim();
  16012. }
  16013. #endregion
  16014. //op,酒店单段模式存储
  16015. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16016. {
  16017. CurrencyCode = currCode,
  16018. Rate = _GroupCostParameters[0].Rate,
  16019. CostType = _GroupCostParameters[0].CostType,
  16020. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16021. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16022. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16023. };
  16024. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16025. if (_GroupCostParameters.Count == 2)
  16026. {
  16027. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16028. }
  16029. foreach (var item in _GroupCostParameters)
  16030. {
  16031. decimal _rate = 1;
  16032. decimal _rate1 = item.Rate;
  16033. decimal _scale = 1;
  16034. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16035. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16036. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16037. //if (userInfo != null)
  16038. //{
  16039. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16040. // {
  16041. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16042. // {
  16043. // _scale = 1.00M;
  16044. // }
  16045. // }
  16046. //}
  16047. #endregion
  16048. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16049. {
  16050. CurrencyCode = currCode,
  16051. Rate = _rate1,
  16052. CostType = item.CostType,
  16053. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16054. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16055. CostTypeNumber = item.CostTypenumber
  16056. };
  16057. if (_GroupCostParameters.Count > 1)
  16058. {
  16059. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16060. }
  16061. else
  16062. {
  16063. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16064. }
  16065. if (dto.CTable == 79)//
  16066. {
  16067. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16068. modulePromptInfo.TotalCost = item.DJCB;
  16069. }
  16070. List<string> costTypes = new List<string>() { "A", "B" };
  16071. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16072. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16073. if (_GroupCostsDuplicates.Count() == 1)
  16074. {
  16075. _GroupCostsTypeData = _GroupCosts;
  16076. }
  16077. else
  16078. {
  16079. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16080. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16081. }
  16082. /*
  16083. * 76 酒店预订
  16084. * 77 行程
  16085. * 79 车/导游地接
  16086. * 80 签证
  16087. * 81 邀请/公务活动
  16088. * 82 团组客户保险
  16089. * 85 机票预订
  16090. * 98 其他款项
  16091. * 285 收款退还
  16092. * 751 酒店早餐
  16093. * 1015 超支费用
  16094. */
  16095. switch (dto.CTable)
  16096. {
  16097. case 76: // 酒店预订
  16098. _ModuleSubPromptInfo.AddRange(
  16099. _GroupCostsTypeData.Select(it => new
  16100. {
  16101. it.DAY,
  16102. it.Date,
  16103. it.ACCON,
  16104. it.ITIN,
  16105. it.SGR,
  16106. it.TBR,
  16107. it.JS_ES,
  16108. it.Suite
  16109. })
  16110. );
  16111. break;
  16112. case 79: // 车/导游地接
  16113. _ModuleSubPromptInfo.AddRange(
  16114. _GroupCostsTypeData.Select(it => new
  16115. {
  16116. Date = it.Date, //日期
  16117. CarFee = it.CarCost * _rate * _scale, //车费用
  16118. CarType = it.CarType, //车型
  16119. DriverFee = it.CFS * _rate * _scale, //司机工资
  16120. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16121. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16122. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16123. GuideFee = it.TGS * _rate * _scale, //导游费用
  16124. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16125. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16126. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16127. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16128. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16129. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16130. Breakfast = it.B * _rate * _scale, //早餐费
  16131. Lunch = it.L * _rate * _scale, //午餐费
  16132. Dinner = it.D * _rate * _scale, //晚餐费
  16133. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16134. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16135. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16136. TicketFee = it.EF * _rate * _scale, //门票费
  16137. TicketRemark = it.EFR, //门票费描述
  16138. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16139. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16140. SpentCash = it.PC * _rate * _scale, //零用金
  16141. LeadersFee = it.TLF * _rate * _scale, //领队费
  16142. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16143. })
  16144. );
  16145. break;
  16146. case 85: // 机票
  16147. List<dynamic> datas = new List<dynamic>();
  16148. datas.Add(
  16149. new
  16150. {
  16151. AirType = "经济舱",
  16152. AirNum = item.JJCRS,
  16153. AirDRCB = item.JJCCB,
  16154. AirZCB = (item.JJCRS * item.JJCCB)
  16155. }
  16156. );
  16157. datas.Add(
  16158. new
  16159. {
  16160. AirType = "公务舱",
  16161. AirNum = item.GWCRS,
  16162. AirDRCB = item.GWCCB,
  16163. AirZCB = (item.GWCRS * item.GWCCB)
  16164. }
  16165. );
  16166. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16167. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16168. modulePromptInfo.Data = new
  16169. {
  16170. airFeeData = datas,
  16171. airInitData = initDatas
  16172. };
  16173. _ModulePromptInfos.Add(modulePromptInfo);
  16174. break;
  16175. default:
  16176. break;
  16177. }
  16178. }
  16179. if (dto.CTable != 85)
  16180. {
  16181. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16182. _ModulePromptInfos.Add(_ModulePromptInfo);
  16183. }
  16184. _view.ModulePromptInfos = _ModulePromptInfos;
  16185. return Ok(JsonView(true, "操作成功!", _view));
  16186. }
  16187. catch (Exception ex)
  16188. {
  16189. return Ok(JsonView(false, ex.Message));
  16190. }
  16191. }
  16192. /// <summary>
  16193. /// 根据黑屏代码重新生成行程
  16194. /// </summary>
  16195. /// <param name="dto"></param>
  16196. /// <returns></returns>
  16197. [HttpPost]
  16198. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16199. {
  16200. var jw = JsonView(false, "Error");
  16201. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16202. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16203. .Select(x => new
  16204. {
  16205. x.Id,
  16206. x.Title
  16207. })
  16208. .ToList();
  16209. if (Create.Any())
  16210. {
  16211. jw.Msg = "获取成功!";
  16212. jw.Code = 200;
  16213. jw.Data = new
  16214. {
  16215. BlackCodeListSelect = Create,
  16216. blackCodeIsTrue = true
  16217. };
  16218. }
  16219. else
  16220. {
  16221. jw.Code = 400;
  16222. jw.Data = new
  16223. {
  16224. BlackCodeListSelect = Create,
  16225. blackCodeIsTrue = false,
  16226. };
  16227. }
  16228. return Ok(jw);
  16229. }
  16230. /// <summary>
  16231. /// 根据黑屏代码Id重新生成行程
  16232. /// </summary>
  16233. /// <param name="dto"></param>
  16234. /// <returns></returns>
  16235. [HttpPost]
  16236. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16237. {
  16238. var jw = JsonView(false, "Error");
  16239. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16240. if (result.Code == 0)
  16241. {
  16242. jw.Msg = "获取成功!";
  16243. jw.Code = 200;
  16244. jw.Data = new
  16245. {
  16246. groupCost = result.Data,
  16247. blackCodeIsTrue = true
  16248. };
  16249. }
  16250. else
  16251. {
  16252. jw.Code = 400;
  16253. jw.Data = new
  16254. {
  16255. groupCost = result.Data,
  16256. blackCodeIsTrue = false,
  16257. };
  16258. }
  16259. return Ok(jw);
  16260. }
  16261. /// <summary>
  16262. /// 成本获取OP历史车费用
  16263. /// </summary>
  16264. /// <param name="dto"></param>
  16265. /// <returns></returns>
  16266. [HttpPost]
  16267. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16268. {
  16269. var jw = JsonView(false);
  16270. try
  16271. {
  16272. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16273. //获取现有所有车的数据
  16274. if (!dto.Param.IsNullOrWhiteSpace())
  16275. {
  16276. string sql = $@"
  16277. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16278. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16279. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16280. 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
  16281. AND gctggr.ServiceEndTime is not NULL
  16282. ORDER by gctggrc.id DESC
  16283. ";
  16284. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16285. var numeberResult = await Task.Run(() =>
  16286. {
  16287. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16288. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16289. return numberArr;
  16290. });
  16291. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16292. foreach (var item in numeberResult)
  16293. {
  16294. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16295. {
  16296. Country = "数据异常!",
  16297. City = string.Empty,
  16298. };
  16299. item.Area = find.Country + " " + find.City;
  16300. }
  16301. dbResult.AddRange(numeberResult);
  16302. if (dto.Param.Contains("、"))
  16303. {
  16304. var sp = dto.Param.Split("、");
  16305. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16306. .Where(x =>
  16307. {
  16308. return System.Array.Exists(sp, e =>
  16309. {
  16310. bool where = false;
  16311. if (x.Area != null)
  16312. {
  16313. where = x.Area.Contains(e);
  16314. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16315. {
  16316. return false;
  16317. }
  16318. }
  16319. if (x.PriceName != null && !where)
  16320. {
  16321. where = x.PriceName.Contains(e);
  16322. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16323. {
  16324. return false;
  16325. }
  16326. }
  16327. return where;
  16328. });
  16329. }).ToList();
  16330. }
  16331. else
  16332. {
  16333. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16334. .Where(x =>
  16335. {
  16336. bool where = false;
  16337. if (x.Area != null)
  16338. {
  16339. where = x.Area.Contains(dto.Param);
  16340. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16341. {
  16342. return false;
  16343. }
  16344. }
  16345. if (x.PriceName != null && !where)
  16346. {
  16347. where = x.PriceName.Contains(dto.Param);
  16348. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16349. {
  16350. return false;
  16351. }
  16352. }
  16353. return where;
  16354. }
  16355. )
  16356. .ToList();
  16357. }
  16358. }
  16359. var view = dbResult.Select(x =>
  16360. {
  16361. decimal dp = 0.00M;
  16362. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16363. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16364. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16365. {
  16366. if (startB && endB)
  16367. {
  16368. var timesp = endD.Subtract(startD);
  16369. if ((timesp.Days + 1) != 0)
  16370. {
  16371. dp = x.Price / (timesp.Days + 1);
  16372. }
  16373. }
  16374. }
  16375. else
  16376. {
  16377. dp = x.Price;
  16378. }
  16379. return new
  16380. {
  16381. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16382. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16383. x.Area,
  16384. x.id,
  16385. price = x.Price.ToString("F2"),
  16386. x.PriceName,
  16387. x.PriceContent,
  16388. x.TeamName,
  16389. x.DatePrice,
  16390. dayPrice = dp.ToString("F2"),
  16391. };
  16392. }).OrderByDescending(x => x.id).ToList();
  16393. jw = JsonView(true, "获取成功!", view);
  16394. }
  16395. catch (Exception e)
  16396. {
  16397. jw = JsonView(false, e.Message);
  16398. }
  16399. return Ok(jw);
  16400. }
  16401. [HttpPost]
  16402. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16403. {
  16404. var jw = JsonView(true);
  16405. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16406. #region SQL语句
  16407. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16408. //{
  16409. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16410. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16411. // WHEN COUNT(*) >= 0 THEN 'True'
  16412. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16413. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16414. // ")
  16415. // .ToList();
  16416. //}
  16417. //else
  16418. //{
  16419. // string likeKey = string.Empty;
  16420. // foreach (var item in dto.Keyword)
  16421. // {
  16422. // likeKey += "%" + item;
  16423. // }
  16424. // likeKey += "%";
  16425. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16426. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16427. // WHEN COUNT(*) >= 0 THEN 'True'
  16428. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16429. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16430. // ")
  16431. // .ToList();
  16432. //}
  16433. #endregion
  16434. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16435. {
  16436. @KeyWord = dto.Keyword
  16437. });
  16438. if (table != null && table.Rows.Count > 0)
  16439. {
  16440. foreach (DataRow row in table.Rows)
  16441. {
  16442. matches.Add(new DelegationInfoAndIsTrueView
  16443. {
  16444. Id = row.Field<int>("Id"),
  16445. GroupName = row.Field<string>("GroupName"),
  16446. isTrue = row.Field<string>("isTrue")
  16447. });
  16448. }
  16449. }
  16450. if (matches.Any())
  16451. {
  16452. jw.Data = matches;
  16453. }
  16454. else
  16455. {
  16456. jw.Code = 201;
  16457. jw.Msg = "empty list";
  16458. jw.Data = new List<string>(1);
  16459. }
  16460. return Ok(jw);
  16461. }
  16462. /// <summary>
  16463. /// 报价Word下载
  16464. /// </summary>
  16465. /// <param name="dto"></param>
  16466. /// <returns></returns>
  16467. [HttpPost]
  16468. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16469. {
  16470. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16471. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16472. if (di == null)
  16473. {
  16474. return Ok(JsonView(false, "团组不存在!"));
  16475. }
  16476. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16477. if (mainPrice == null || mainPrice.IsShare == 0)
  16478. {
  16479. return Ok(JsonView(false, "团组成本不存在!"));
  16480. }
  16481. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16482. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16483. if (costTypeHotelNumbers == null)
  16484. {
  16485. return Ok(JsonView(false, "团组成本不存在!"));
  16486. }
  16487. //文件名
  16488. string strFileName = di.TeamName + "-收款账单.doc";
  16489. //获取模板
  16490. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16491. //载入模板
  16492. Document doc = new Document(tmppath);
  16493. decimal allPrice = 0.00M;
  16494. string itemStr = string.Empty;
  16495. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16496. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16497. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16498. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16499. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16500. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16501. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16502. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16503. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16504. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16505. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16506. {
  16507. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16508. ("BXRS", "BXCB", "BXXS", "bx"),
  16509. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16510. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16511. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16512. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16513. ("CPRS", "CPCB", "CPXS", "cp"),
  16514. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16515. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16516. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16517. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16518. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16519. ("DJRS", "DJCB", "DJXS", "dj"),
  16520. ("GWRS", "GWCB", "GWXS", "gw"),
  16521. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16522. };
  16523. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16524. var rightSum = 0.00M;
  16525. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16526. {
  16527. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16528. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16529. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16530. if (prefix == "tbr")
  16531. {
  16532. rsValue *= 2;
  16533. cbValue /= 2;
  16534. }
  16535. if (OtherCostPropertyBJ.Contains(prefix))
  16536. {
  16537. rightSum += cbValue * xsValue;
  16538. }
  16539. }
  16540. var hotelRooms = new Dictionary<string, int>
  16541. {
  16542. { "SGR", costTypeHotelNumbers.SGR },
  16543. { "TBR", costTypeHotelNumbers.TBR },
  16544. { "JSES", costTypeHotelNumbers.JSES },
  16545. { "SUITE", costTypeHotelNumbers.SUITE }
  16546. };
  16547. var flights = new Dictionary<string, int>
  16548. {
  16549. { "经济舱", mainPrice.JJCRS },
  16550. { "公务舱", mainPrice.GWCRS },
  16551. { "头等舱", mainPrice.TDCRS }
  16552. };
  16553. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16554. {
  16555. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16556. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16557. { "头等舱", new[] { "SUITE", "JSES" } }
  16558. };
  16559. var result = new Dictionary<string, int>();
  16560. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16561. foreach (var flight in flights.Keys)
  16562. {
  16563. // 获取当前舱位的匹配规则
  16564. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16565. {
  16566. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16567. }
  16568. }
  16569. #region right计算
  16570. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16571. {
  16572. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16573. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16574. airHotelPriceList.Add(new
  16575. AirHotelPrice
  16576. {
  16577. Name = "经济舱TBR",
  16578. Price = rightSum + air + hotel,
  16579. Count = result["经济舱TBR"] * 2
  16580. });
  16581. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16582. }
  16583. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16584. {
  16585. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16586. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16587. airHotelPriceList.Add(new
  16588. AirHotelPrice
  16589. {
  16590. Name = "经济舱SGR",
  16591. Price = rightSum + air + hotel,
  16592. Count = result["经济舱SGR"]
  16593. });
  16594. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16595. }
  16596. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16597. {
  16598. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16599. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16600. airHotelPriceList.Add(new
  16601. AirHotelPrice
  16602. {
  16603. Name = "公务舱SGR",
  16604. Price = rightSum + air + hotel,
  16605. Count = result["公务舱SGR"]
  16606. });
  16607. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16608. }
  16609. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16610. {
  16611. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16612. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16613. airHotelPriceList.Add(new
  16614. AirHotelPrice
  16615. {
  16616. Name = "公务舱JSES",
  16617. Price = rightSum + air + hotel,
  16618. Count = result["公务舱JSES"]
  16619. });
  16620. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16621. }
  16622. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16623. {
  16624. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16625. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16626. airHotelPriceList.Add(new
  16627. AirHotelPrice
  16628. {
  16629. Name = "公务舱SUITE",
  16630. Price = rightSum + air + hotel,
  16631. Count = result["公务舱SUITE"]
  16632. });
  16633. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16634. }
  16635. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16636. {
  16637. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16638. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16639. airHotelPriceList.Add(new
  16640. AirHotelPrice
  16641. {
  16642. Name = "经济舱SUITE",
  16643. Price = rightSum + air + hotel,
  16644. Count = result["经济舱SUITE"]
  16645. });
  16646. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16647. }
  16648. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16649. {
  16650. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16651. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16652. airHotelPriceList.Add(new
  16653. AirHotelPrice
  16654. {
  16655. Name = "头等舱JSES",
  16656. Price = rightSum + air + hotel,
  16657. Count = result["头等舱JSES"]
  16658. });
  16659. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16660. }
  16661. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16662. {
  16663. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16664. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16665. airHotelPriceList.Add(new
  16666. AirHotelPrice
  16667. {
  16668. Name = "头等舱SUITE",
  16669. Price = rightSum + air + hotel,
  16670. Count = result["头等舱SUITE"]
  16671. });
  16672. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16673. }
  16674. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16675. {
  16676. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16677. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16678. airHotelPriceList.Add(new
  16679. AirHotelPrice
  16680. {
  16681. Name = "经济舱JSES",
  16682. Price = rightSum + air + hotel,
  16683. Count = result["经济舱JSES"]
  16684. });
  16685. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16686. }
  16687. #endregion
  16688. foreach (var item in airSouer.Keys)
  16689. {
  16690. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16691. if (find != null && find.Count > 0)
  16692. {
  16693. if (item.Contains("TBR"))
  16694. {
  16695. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16696. }
  16697. else
  16698. {
  16699. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16700. }
  16701. }
  16702. }
  16703. #region 替换Word模板书签内容
  16704. Dictionary<string, string> marks = new Dictionary<string, string>();
  16705. marks.Add("To", di.ClientUnit);//付款方
  16706. marks.Add("ToTel", di.TellPhone);//付款方电话
  16707. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16708. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16709. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16710. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16711. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16712. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16713. marks.Add("PayItemContent", itemStr);//详细信息
  16714. marks.Add("Total", allPrice.ToString("F2"));//合计
  16715. #endregion
  16716. foreach (var item in marks.Keys)
  16717. {
  16718. if (doc.Range.Bookmarks[item] != null)
  16719. {
  16720. Bookmark mark = doc.Range.Bookmarks[item];
  16721. mark.Text = marks[item];
  16722. }
  16723. }
  16724. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16725. doc.Save(savePaht);
  16726. var jw = new JsonView();
  16727. jw.Msg = "生成成功!";
  16728. jw.Code = 200;
  16729. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16730. return Ok(jw);
  16731. }
  16732. /// <summary>
  16733. /// 详细报价费用Excel下载
  16734. /// </summary>
  16735. /// <param name="dto"></param>
  16736. /// <returns></returns>
  16737. [HttpPost]
  16738. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16739. {
  16740. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16741. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16742. if (di == null)
  16743. {
  16744. return Ok(JsonView(false, "团组不存在!"));
  16745. }
  16746. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16747. if (mainPrice == null || mainPrice.IsShare == 0)
  16748. {
  16749. return Ok(JsonView(false, "团组成本不存在!"));
  16750. }
  16751. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16752. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16753. if (costTypeHotelNumbers == null)
  16754. {
  16755. return Ok(JsonView(false, "团组成本不存在!"));
  16756. }
  16757. WorkbookDesigner designer = new WorkbookDesigner();
  16758. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16759. List<int> hideRowsList = new List<int>();
  16760. int conterStartIndex = 3;
  16761. int rowIndex = conterStartIndex;
  16762. designer.SetDataSource("GroupName", di.TeamName);
  16763. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16764. {
  16765. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16766. ("BXRS", "BXCB", "BXXS", "bx"),
  16767. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16768. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16769. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16770. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16771. ("CPRS", "CPCB", "CPXS", "cp") ,
  16772. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16773. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16774. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16775. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16776. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16777. ("DJRS", "DJCB", "DJXS", "dj") ,
  16778. ("GWRS", "GWCB", "GWXS", "gw") ,
  16779. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16780. };
  16781. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16782. var rightSum = 0.00M;
  16783. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16784. {
  16785. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16786. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16787. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16788. if (prefix == "tbr")
  16789. {
  16790. rsValue *= 2;
  16791. cbValue /= 2;
  16792. }
  16793. if (OtherCostPropertyBJ.Contains(prefix))
  16794. {
  16795. rightSum += cbValue * xsValue;
  16796. }
  16797. if (rsValue == 0)
  16798. {
  16799. hideRowsList.Add(rowIndex);
  16800. }
  16801. else
  16802. {
  16803. designer.SetDataSource($"{prefix}rs", rsValue);
  16804. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16805. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16806. }
  16807. rowIndex += 2;
  16808. }
  16809. var hotelRooms = new Dictionary<string, int>
  16810. {
  16811. { "SGR", costTypeHotelNumbers.SGR },
  16812. { "TBR", costTypeHotelNumbers.TBR },
  16813. { "JSES", costTypeHotelNumbers.JSES },
  16814. { "SUITE", costTypeHotelNumbers.SUITE }
  16815. };
  16816. var flights = new Dictionary<string, int>
  16817. {
  16818. { "经济舱", mainPrice.JJCRS },
  16819. { "公务舱", mainPrice.GWCRS },
  16820. { "头等舱", mainPrice.TDCRS }
  16821. };
  16822. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16823. {
  16824. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16825. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16826. { "头等舱", new[] { "SUITE", "JSES" } }
  16827. };
  16828. var result = new Dictionary<string, int>();
  16829. foreach (var flight in flights.Keys)
  16830. {
  16831. // 获取当前舱位的匹配规则
  16832. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16833. {
  16834. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16835. }
  16836. }
  16837. var allPrice = 0.00M;
  16838. #region right计算
  16839. int airRowIndex = 35;
  16840. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16841. {
  16842. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16843. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16844. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16845. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16846. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16847. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16848. }
  16849. else
  16850. {
  16851. hideRowsList.Add(airRowIndex);
  16852. }
  16853. airRowIndex += 2;
  16854. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16855. {
  16856. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16857. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16858. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16859. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16860. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16861. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16862. }
  16863. else
  16864. {
  16865. hideRowsList.Add(airRowIndex);
  16866. }
  16867. airRowIndex += 2;
  16868. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16869. {
  16870. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16871. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16872. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16873. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16874. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16875. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16876. }
  16877. else
  16878. {
  16879. hideRowsList.Add(airRowIndex);
  16880. }
  16881. airRowIndex += 2;
  16882. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16883. {
  16884. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16885. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16886. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16887. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16888. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16889. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16890. }
  16891. else
  16892. {
  16893. hideRowsList.Add(airRowIndex);
  16894. }
  16895. airRowIndex += 2;
  16896. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16897. {
  16898. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16899. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16900. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16901. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16902. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16903. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16904. }
  16905. else
  16906. {
  16907. hideRowsList.Add(airRowIndex);
  16908. }
  16909. airRowIndex += 2;
  16910. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16911. {
  16912. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16913. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16914. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16915. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16916. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16917. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16918. }
  16919. else
  16920. {
  16921. hideRowsList.Add(airRowIndex);
  16922. }
  16923. airRowIndex += 2;
  16924. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16925. {
  16926. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16927. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16928. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16929. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16930. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16931. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16932. }
  16933. else
  16934. {
  16935. hideRowsList.Add(airRowIndex);
  16936. }
  16937. airRowIndex += 2;
  16938. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16939. {
  16940. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16941. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16942. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16943. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16944. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16945. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16946. }
  16947. else
  16948. {
  16949. hideRowsList.Add(airRowIndex);
  16950. }
  16951. airRowIndex += 2;
  16952. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16953. {
  16954. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16955. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16956. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16957. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16958. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16959. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16960. }
  16961. else
  16962. {
  16963. hideRowsList.Add(airRowIndex);
  16964. }
  16965. #endregion
  16966. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16967. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16968. var ws = designer.Workbook.Worksheets[0];
  16969. foreach (var Rowindex in hideRowsList)
  16970. {
  16971. ws.Cells.HideRows(Rowindex, 2);
  16972. }
  16973. designer.Process();
  16974. designer.Workbook.Save(savePaht);
  16975. return Ok(JsonView(true, "生成成功!", new
  16976. {
  16977. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16978. }));
  16979. }
  16980. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16981. {
  16982. foreach (var roomType in roomTypes)
  16983. {
  16984. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16985. {
  16986. hotelRooms[roomType]--;
  16987. flights[flightType]--;
  16988. if (roomType == "TBR")
  16989. {
  16990. flights[flightType]--; // 双人间在减少1
  16991. }
  16992. string key = flightType + roomType;
  16993. if (result.Keys.Contains(key))
  16994. {
  16995. result[key]++;
  16996. }
  16997. else
  16998. {
  16999. result.Add(key, 1);
  17000. }
  17001. }
  17002. }
  17003. }
  17004. private class AirHotelPrice
  17005. {
  17006. public string Name { get; set; }
  17007. public decimal Price { get; set; }
  17008. public int Count { get; set; }
  17009. }
  17010. private class HotelSum
  17011. {
  17012. internal decimal SGR { get; set; }
  17013. internal decimal TBR { get; set; }
  17014. internal decimal JSES { get; set; }
  17015. internal decimal SUITE { get; set; }
  17016. internal decimal AllPrice
  17017. {
  17018. get { return SGR + TBR + JSES + SUITE; }
  17019. }
  17020. }
  17021. [HttpPost]
  17022. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17023. {
  17024. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17025. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17026. if (di == null)
  17027. {
  17028. return Ok(JsonView(false, "团组不存在!"));
  17029. }
  17030. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>()
  17031. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  17032. .ToList();
  17033. var groupHotelNumber = _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17034. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  17035. .ToList();
  17036. var groupHotelNumberDefault = groupHotelNumber.FirstOrDefault(x => x.Type == "Default");
  17037. HotelSum hotelSumP = new();
  17038. if (groupCost.Any())
  17039. {
  17040. hotelSumP.SGR = groupHotelNumberDefault.SGR > 0 ? groupCost.Sum(x => x.SGR) * groupHotelNumberDefault.SGR : 0;
  17041. hotelSumP.TBR = groupHotelNumberDefault.TBR > 0 ? groupCost.Sum(x => x.TBR) * groupHotelNumberDefault.TBR : 0;
  17042. hotelSumP.JSES = groupHotelNumberDefault.JSES > 0 ? groupCost.Sum(x => x.JS_ES) * groupHotelNumberDefault.JSES : 0;
  17043. hotelSumP.SUITE = groupHotelNumberDefault.SUITE > 0 ? groupCost.Sum(x => x.Suite) * groupHotelNumberDefault.SUITE : 0;
  17044. }
  17045. #region 地接系数
  17046. Func<int, decimal> coefficientByDJ = (number) =>
  17047. {
  17048. if (number < 1) return 0.00M;
  17049. return number switch
  17050. {
  17051. < 6 => 2.5M,
  17052. 6 => 2.4M,
  17053. 7 => 1.8M,
  17054. 8 => 2.0M,
  17055. 9 => 3.0M,
  17056. 10 => 1.75M,
  17057. > 10 => 1.9M,
  17058. };
  17059. };
  17060. #endregion
  17061. #region 酒店系数
  17062. #endregion
  17063. return Ok(JsonView(true, "查询成功", new
  17064. {
  17065. HotelSum = hotelSumP,
  17066. CoefficientByDJ = coefficientByDJ(di.VisitPNumber) // 示例调用
  17067. }));
  17068. }
  17069. #endregion
  17070. #region 酒店预订 New 2023-12-28 17:45
  17071. /// <summary>
  17072. /// 酒店预订
  17073. /// 酒店费用列表 根据团组Id查询
  17074. /// </summary>
  17075. /// <param name="_dto"></param>
  17076. /// <returns></returns>
  17077. [HttpPost]
  17078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17079. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17080. {
  17081. #region 参数验证
  17082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17083. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17084. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17085. #region 团组操作权限验证 76 酒店预定模块
  17086. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17087. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17088. #endregion
  17089. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17090. #region 页面操作权限验证
  17091. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17092. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17093. #endregion
  17094. #endregion
  17095. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17096. }
  17097. /// <summary>
  17098. /// 酒店预订
  17099. /// 基础数据
  17100. /// </summary>
  17101. /// <param name="_dto"></param>
  17102. /// <returns></returns>
  17103. [HttpPost]
  17104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17105. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17106. {
  17107. #region 参数验证
  17108. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17109. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17110. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17111. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17112. #region 页面操作权限验证
  17113. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17114. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17115. #endregion
  17116. #region 团组操作权限验证 76 酒店预定模块
  17117. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17118. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17119. #endregion
  17120. #endregion
  17121. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17122. }
  17123. /// <summary>
  17124. /// 酒店预订
  17125. /// 创建 入住卷号码
  17126. /// </summary>
  17127. /// <param name="_dto"></param>
  17128. /// <returns></returns>
  17129. [HttpPost]
  17130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17131. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17132. {
  17133. #region 参数验证
  17134. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17135. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17136. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17137. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17138. #region 页面操作权限验证
  17139. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17140. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17141. #endregion
  17142. #region 团组操作权限验证 76 酒店预定模块
  17143. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17144. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17145. #endregion
  17146. #endregion
  17147. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17148. if (data.Code != 0)
  17149. {
  17150. return Ok(JsonView(false, data.Msg));
  17151. }
  17152. return Ok(JsonView(true, data.Msg, data.Data));
  17153. }
  17154. /// <summary>
  17155. /// 酒店预订
  17156. /// 详情
  17157. /// </summary>
  17158. /// <param name="_dto"></param>
  17159. /// <returns></returns>
  17160. [HttpPost]
  17161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17162. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17163. {
  17164. #region 参数验证
  17165. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17166. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17167. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17168. #region 团组操作权限验证 76 酒店预定模块
  17169. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17170. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17171. #endregion
  17172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17173. #region 页面操作权限验证
  17174. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17175. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17176. #endregion
  17177. #endregion
  17178. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17179. }
  17180. /// <summary>
  17181. /// 酒店预订
  17182. /// Add Or Edit
  17183. /// </summary>
  17184. /// <param name="_dto"></param>
  17185. /// <returns></returns>
  17186. [HttpPost]
  17187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17188. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17189. {
  17190. #region 参数验证
  17191. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17192. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17193. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17194. #region 团组操作权限验证 76 酒店预定模块
  17195. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17196. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17197. #endregion
  17198. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17199. #region 页面操作权限验证
  17200. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17201. if (_dto.Id == 0) // Add
  17202. {
  17203. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17204. }
  17205. else if (_dto.Id > 1) // Edit
  17206. {
  17207. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17208. }
  17209. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17210. #endregion
  17211. #endregion
  17212. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17213. if (_view.Code != 200)
  17214. {
  17215. return Ok(_view);
  17216. }
  17217. #region 成本无酒店价格数据进入超支
  17218. _sqlSugar.BeginTran();
  17219. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17220. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17221. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17222. for (int i = 0; i < groupCost.Count; i++)
  17223. {
  17224. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17225. {
  17226. groupCost[i].Date = groupCost[i - 1].Date;
  17227. }
  17228. }
  17229. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17230. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17231. List<Fin_GroupExtraCostDto_OP>();
  17232. if (start_Bool && end_Bool)
  17233. {
  17234. while (start_Time < end_Time)
  17235. {
  17236. foreach (var item in groupCost_Grp)
  17237. {
  17238. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17239. {
  17240. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17241. {
  17242. extraCostList.Add(new
  17243. Fin_GroupExtraCostDto_OP
  17244. {
  17245. Area = _dto.AreaId,
  17246. coefficient = 1.5M,
  17247. createUser = _dto.UserId,
  17248. currency = _dto.CardPriceCurrency,
  17249. diId = _dto.DiId,
  17250. ManagerConfirm = 0,
  17251. SupervisorConfirm = 0,
  17252. SYsupervisorConfirm = 0,
  17253. editType = 1,
  17254. PortType = 1,
  17255. price = _dto.CardPrice,
  17256. PriceCount = 1,
  17257. priceType = 1027,
  17258. priceDetailType = 1044,
  17259. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17260. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17261. });
  17262. }
  17263. }
  17264. }
  17265. start_Time = start_Time.AddDays(1);
  17266. }
  17267. }
  17268. if (extraCostList.Any())
  17269. {
  17270. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17271. }
  17272. _sqlSugar.CommitTran();
  17273. #endregion
  17274. #region 应用推送
  17275. try
  17276. {
  17277. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17278. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17279. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17280. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17281. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17282. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17283. var diId = _dto.DiId;
  17284. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17285. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17286. #region 操作记录
  17287. var opInfo = new Crm_TableOperationRecord()
  17288. {
  17289. TableName = "Grp_HotelReservations",
  17290. PortType = _dto.PortType,
  17291. DataId = hotelId,
  17292. CreateUserId = _dto.UserId
  17293. };
  17294. //var opStatus = OperationEnum.NoOperation;
  17295. if (_dto.Id < 1) //添加操作
  17296. {
  17297. opInfo.OperationItem = OperationEnum.Add;
  17298. }
  17299. else if (_dto.Id > 0)
  17300. {
  17301. opInfo.OperationItem = OperationEnum.Edit;
  17302. }
  17303. string opRemark = string.Empty;
  17304. if (ccpInfo != null)
  17305. {
  17306. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17307. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17308. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17309. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17310. }
  17311. opInfo.Remark = opRemark;
  17312. await _tableorRep.AddAsync(opInfo);
  17313. #endregion
  17314. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17315. //2024-10-21 新增LZ UID
  17316. var userIds = new List<int>() { 21 };
  17317. string title = $"费用审核";
  17318. string content = "";
  17319. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17320. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17321. try
  17322. {
  17323. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17324. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17325. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17326. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17327. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17328. }
  17329. catch (Exception ex)
  17330. {
  17331. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17332. }
  17333. }
  17334. catch (Exception ex)
  17335. {
  17336. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17337. }
  17338. try
  17339. {
  17340. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17341. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17342. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17343. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17344. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17345. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17346. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17347. //自动审核
  17348. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17349. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17350. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17351. //2024-10-21 新增LZ UID
  17352. var userIds = new List<int>() { 21 };
  17353. string title = $"系统通知";
  17354. var diId = _dto.DiId;
  17355. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17356. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17357. string content = "";
  17358. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17359. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17360. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17361. }
  17362. catch (Exception ex)
  17363. {
  17364. }
  17365. #endregion
  17366. return Ok(_view);
  17367. }
  17368. /// <summary>
  17369. /// 酒店自动审核测试
  17370. /// Add Or Edit
  17371. /// </summary>
  17372. /// <param name="diid"></param>
  17373. /// <param name="dataId"></param>
  17374. /// <returns></returns>
  17375. [HttpPost]
  17376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17377. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17378. {
  17379. #region 应用推送
  17380. try
  17381. {
  17382. //自动审核
  17383. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17384. }
  17385. catch (Exception ex)
  17386. {
  17387. return Ok(JsonView(false, ex.Message));
  17388. }
  17389. #endregion
  17390. return Ok(JsonView(false, "操作成功"));
  17391. }
  17392. /// <summary>
  17393. /// 酒店预订
  17394. /// Del
  17395. /// </summary>
  17396. /// <param name="_dto"></param>
  17397. /// <returns></returns>
  17398. [HttpPost]
  17399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17400. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17401. {
  17402. #region 参数验证
  17403. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17404. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17405. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17406. #region 团组操作权限验证 76 酒店预定模块
  17407. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17408. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17409. #endregion
  17410. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17411. #region 页面操作权限验证
  17412. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17413. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17414. #endregion
  17415. #endregion
  17416. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17417. #region 操作记录
  17418. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17419. {
  17420. TableName = "Grp_HotelReservations",
  17421. PortType = _dto.PortType,
  17422. OperationItem = OperationEnum.Del,
  17423. DataId = _dto.Id,
  17424. CreateUserId = _dto.UserId
  17425. });
  17426. #endregion
  17427. return Ok(data);
  17428. }
  17429. /// <summary>
  17430. /// 酒店预订
  17431. /// 生成VOUCHER
  17432. /// 2024.05.06 之前版本
  17433. /// </summary>
  17434. /// <param name="_dto"></param>
  17435. /// <returns></returns>
  17436. [HttpPost]
  17437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17438. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17439. {
  17440. try
  17441. {
  17442. #region 参数验证
  17443. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17444. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17445. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17446. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17447. #region 团组操作权限验证 76 酒店预定模块
  17448. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17449. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17450. #endregion
  17451. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17452. #region 页面操作权限验证
  17453. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17454. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17455. #endregion
  17456. #endregion
  17457. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17458. //判断数据是否完整
  17459. if (hr != null)
  17460. {
  17461. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17462. {
  17463. string strFileName = "HotelStatement/";
  17464. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17465. if (dele != null)
  17466. strFileName += dele.TourCode;
  17467. //载入模板
  17468. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17469. Document doc = new Document(sss);
  17470. DocumentBuilder builder = new DocumentBuilder(doc);
  17471. #region 替换Word模板书签内容
  17472. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17473. //入住卷预定号码
  17474. if (doc.Range.Bookmarks["VNO"] != null)
  17475. {
  17476. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17477. mark.Text = hr.CheckNumber;
  17478. }
  17479. //酒店时间
  17480. if (doc.Range.Bookmarks["Date"] != null)
  17481. {
  17482. Bookmark mark = doc.Range.Bookmarks["Date"];
  17483. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17484. }
  17485. //团号
  17486. if (doc.Range.Bookmarks["TNo"] != null)
  17487. {
  17488. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17489. mark.Text = dele.TourCode;
  17490. }
  17491. //预定号码
  17492. if (doc.Range.Bookmarks["BookingId"] != null)
  17493. {
  17494. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17495. mark.Text = hr.ReservationsNo;
  17496. }
  17497. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17498. {
  17499. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17500. mark.Text = hr.DetermineNo;
  17501. }
  17502. //酒店城市
  17503. if (doc.Range.Bookmarks["City"] != null)
  17504. {
  17505. Bookmark mark = doc.Range.Bookmarks["City"];
  17506. mark.Text = hr.City;
  17507. }
  17508. //酒店名称
  17509. if (doc.Range.Bookmarks["HName"] != null)
  17510. {
  17511. Bookmark mark = doc.Range.Bookmarks["HName"];
  17512. mark.Text = hr.HotelName;
  17513. }
  17514. //酒店地址
  17515. if (doc.Range.Bookmarks["Address"] != null)
  17516. {
  17517. Bookmark mark = doc.Range.Bookmarks["Address"];
  17518. mark.Text = hr.HotelAddress;
  17519. }
  17520. //酒店电话
  17521. if (doc.Range.Bookmarks["Tel"] != null)
  17522. {
  17523. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17524. mark.Text = hr.HotelTel;
  17525. }
  17526. //酒店传真
  17527. if (doc.Range.Bookmarks["Fax"] != null)
  17528. {
  17529. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17530. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17531. {
  17532. mark.Text = hr.HotelFax;
  17533. }
  17534. }
  17535. //入住时间
  17536. if (doc.Range.Bookmarks["CIn"] != null)
  17537. {
  17538. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17539. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17540. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17541. }
  17542. //退房时间
  17543. if (doc.Range.Bookmarks["COut"] != null)
  17544. {
  17545. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17546. Bookmark mark = doc.Range.Bookmarks["COut"];
  17547. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17548. }
  17549. //客户名称
  17550. if (doc.Range.Bookmarks["GName"] != null)
  17551. {
  17552. string guestName = "";
  17553. string[] clients = Array.Empty<string>();
  17554. if (hr.GuestName.Contains(","))
  17555. {
  17556. clients = hr.GuestName.Split(",");
  17557. }
  17558. else
  17559. {
  17560. clients = new string[] { hr.GuestName };
  17561. }
  17562. List<int> clientIds_int = new List<int>();
  17563. if (clients.Length > 0)
  17564. {
  17565. foreach (var item in clients)
  17566. {
  17567. if (item.IsNumeric())
  17568. {
  17569. clientIds_int.Add(int.Parse(item));
  17570. }
  17571. }
  17572. }
  17573. if (clientIds_int.Count > 0)
  17574. {
  17575. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17576. foreach (var client in _clientDatas)
  17577. {
  17578. //男
  17579. if (client.Sex == 0) guestName += $"Mr.";
  17580. //女
  17581. else if (client.Sex == 1) guestName += $"Ms.";
  17582. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17583. {
  17584. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17585. }
  17586. //guestName += $"{client.Pinyin},";
  17587. }
  17588. if (guestName.Length > 0)
  17589. {
  17590. guestName = guestName.Substring(0, guestName.Length - 1);
  17591. }
  17592. }
  17593. else
  17594. {
  17595. guestName = hr.GuestName;
  17596. }
  17597. Bookmark mark = doc.Range.Bookmarks["GName"];
  17598. mark.Text = guestName;
  17599. }
  17600. //房间介绍
  17601. if (doc.Range.Bookmarks["ROOM"] != null)
  17602. {
  17603. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17604. mark.Text = hr.RoomExplanation;
  17605. }
  17606. //报价描述
  17607. if (doc.Range.Bookmarks["NOTE"] != null)
  17608. {
  17609. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17610. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17611. if (ss != null)
  17612. mark.Text = ss.Name;
  17613. }
  17614. //入住时间
  17615. if (doc.Range.Bookmarks["CheckIn"] != null)
  17616. {
  17617. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17618. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17619. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17620. }
  17621. //退房时间
  17622. if (doc.Range.Bookmarks["CheckOut"] != null)
  17623. {
  17624. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17625. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17626. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17627. }
  17628. //日期
  17629. if (doc.Range.Bookmarks["DT"] != null)
  17630. {
  17631. Bookmark mark = doc.Range.Bookmarks["DT"];
  17632. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17633. }
  17634. //名称
  17635. if (doc.Range.Bookmarks["VName"] != null)
  17636. {
  17637. Bookmark mark = doc.Range.Bookmarks["VName"];
  17638. mark.Text = hr.HotelName;
  17639. }
  17640. //号码
  17641. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17642. {
  17643. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17644. mark.Text = hr.CheckNumber;
  17645. }
  17646. #endregion
  17647. strFileName += "VOUCHER.doc";
  17648. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17649. doc.Save(fileDir);
  17650. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17651. return Ok(JsonView(true, "操作成功!", Url));
  17652. }
  17653. else
  17654. {
  17655. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17656. }
  17657. }
  17658. else
  17659. {
  17660. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17661. }
  17662. }
  17663. catch (Exception ex)
  17664. {
  17665. return Ok(JsonView(false, ex.Message));
  17666. }
  17667. }
  17668. /// <summary>
  17669. /// 酒店预订
  17670. /// 生成VOUCHER
  17671. /// 2024.05.06 之后版本
  17672. /// </summary>
  17673. /// <param name="_dto"></param>
  17674. /// <returns></returns>
  17675. [HttpPost]
  17676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17677. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17678. {
  17679. #region 参数验证
  17680. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17681. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17682. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17683. #region 团组操作权限验证 76 酒店预定模块
  17684. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17685. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17686. #endregion
  17687. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17688. #region 页面操作权限验证
  17689. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17690. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17691. #endregion
  17692. #endregion
  17693. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17694. //判断数据是否完整
  17695. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17696. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17697. string strFileName = "HotelStatement/";
  17698. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17699. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17700. #region 数据处理
  17701. List<int> guestIds = new List<int>();
  17702. //int index = 0;
  17703. foreach (var item in hrDtas)
  17704. {
  17705. if (item.GuestName.Contains(","))
  17706. {
  17707. string[] guestIdArr = item.GuestName.Split(',');
  17708. foreach (var guestIdStr in guestIdArr)
  17709. {
  17710. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17711. if (guestBool)
  17712. {
  17713. guestIds.Add(guestId);
  17714. }
  17715. }
  17716. }
  17717. else guestNames += item.GuestName;
  17718. var voucherInfo = new HotelVoucherInfoView()
  17719. {
  17720. HotelName = item.HotelName,
  17721. CheckInDate = item.CheckInDate,
  17722. CheckOutDate = item.CheckOutDate,
  17723. ConfirmationNumber = item.DetermineNo.Trim(),
  17724. RoomType = item.RoomExplanation
  17725. };
  17726. vouchers.Add(voucherInfo);
  17727. }
  17728. if (guestIds.Count > 0)
  17729. {
  17730. guestIds = guestIds.Distinct().ToList();
  17731. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17732. if (guestDatas.Count > 0)
  17733. {
  17734. guestNames = "";
  17735. foreach (var guest in guestDatas)
  17736. {
  17737. string guestName = "";
  17738. if (guest.Sex == 0) guestName += @"MR.";
  17739. else if (guest.Sex == 1) guestName += @"MS.";
  17740. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17741. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17742. guestNames += @$"{guestName.Trim()}、";
  17743. }
  17744. if (guestNames.Length > 0)
  17745. {
  17746. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17747. }
  17748. }
  17749. }
  17750. #endregion
  17751. //载入模板
  17752. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17753. Document doc = new Document(sss);
  17754. DocumentBuilder builder = new DocumentBuilder(doc);
  17755. if (doc.Range.Bookmarks["GuestName"] != null)
  17756. {
  17757. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17758. mark.Text = guestNames;
  17759. }
  17760. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17761. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17762. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17763. for (int i = 1; i <= vouchers.Count; i++)
  17764. {
  17765. HotelVoucherInfoView hviv = vouchers[i - 1];
  17766. builder.MoveToCell(0, i, 0, 0);
  17767. builder.Write(hviv.HotelName);
  17768. builder.MoveToCell(0, i, 1, 0);
  17769. builder.Write(hviv.CheckInDate);
  17770. builder.MoveToCell(0, i, 2, 0);
  17771. builder.Write(hviv.CheckOutDate);
  17772. builder.MoveToCell(0, i, 3, 0);
  17773. builder.Write(hviv.RoomType);
  17774. builder.MoveToCell(0, i, 4, 0);
  17775. builder.Write(hviv.ConfirmationNumber);
  17776. }
  17777. //删除多余行
  17778. int currRowIndex = vouchers.Count + 1;
  17779. int delRows = 21 - currRowIndex;
  17780. if (delRows > 0)
  17781. {
  17782. for (int i = 0; i < delRows; i++)
  17783. {
  17784. table.Rows.RemoveAt(currRowIndex);
  17785. //cultivateRowIndex++;
  17786. }
  17787. }
  17788. strFileName += "VOUCHER.docx";
  17789. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17790. doc.Save(fileDir);
  17791. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17792. return Ok(JsonView(true, "操作成功!", Url));
  17793. }
  17794. /// <summary>
  17795. /// 酒店预订
  17796. /// 生成VOUCHER 批量生成
  17797. /// New
  17798. /// </summary>
  17799. /// <param name="_dto"></param>
  17800. /// <returns></returns>
  17801. [HttpPost]
  17802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17803. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17804. {
  17805. #region 参数验证
  17806. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17807. if (_dto.PageId < 1) _dto.PageId = 28;
  17808. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17809. #region 团组操作权限验证 76 酒店预定模块
  17810. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17811. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17812. #endregion
  17813. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17814. #region 页面操作权限验证
  17815. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17816. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17817. #endregion
  17818. #endregion
  17819. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17820. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17821. .OrderBy(x => x.CheckInDate)
  17822. .ToListAsync();
  17823. //判断数据是否完整
  17824. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17825. string strFileName = "HotelStatement/";
  17826. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17827. if (dele != null)
  17828. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17829. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17830. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17831. .Where(it => it.IsDel == 0)
  17832. .ToListAsync();
  17833. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17834. for (int i = 0; i < hrDtas.Count; i++)
  17835. {
  17836. string guestNames = string.Empty;
  17837. List<int> guestIds = new List<int>();
  17838. var item = hrDtas[i];
  17839. //处理客户姓名
  17840. if (item.GuestName.Contains(","))
  17841. {
  17842. string[] guestIdArr = item.GuestName.Split(',');
  17843. foreach (var guestIdStr in guestIdArr)
  17844. if (int.TryParse(guestIdStr, out int guestId))
  17845. guestIds.Add(guestId);
  17846. }
  17847. else
  17848. {
  17849. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17850. if (guestIdBool)
  17851. {
  17852. guestIds.Add(guestId);
  17853. }
  17854. //NaN
  17855. if (item.GuestName.Contains("NaN"))
  17856. {
  17857. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17858. }
  17859. }
  17860. if (guestIds.Count > 0)
  17861. {
  17862. guestIds = guestIds.Distinct().ToList();
  17863. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17864. if (guestDatas1.Count > 0)
  17865. {
  17866. guestNames = "";
  17867. foreach (var guest in guestDatas1)
  17868. {
  17869. string guestName = "";
  17870. if (guest.Sex == 0) guestName += @"MR.";
  17871. else if (guest.Sex == 1) guestName += @"MS.";
  17872. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17873. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17874. guestNames += @$"{guestName.Trim()}、";
  17875. }
  17876. if (guestNames.Length > 0)
  17877. {
  17878. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17879. }
  17880. }
  17881. }
  17882. //if (!string.IsNullOrEmpty(guestNames))
  17883. //{
  17884. hrDtas[i].GuestName = guestNames;
  17885. //}
  17886. }
  17887. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17888. Document doc = new Document();
  17889. DocumentBuilder builder = new DocumentBuilder(doc);
  17890. try
  17891. {
  17892. builder.MoveToDocumentStart();
  17893. foreach (var item in hrDtas)
  17894. {
  17895. //标题
  17896. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17897. builder.ParagraphFormat.LineSpacing = 1;
  17898. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17899. builder.ParagraphFormat.Style.Font.Size = 9;
  17900. builder.ParagraphFormat.Style.Font.Bold = true;
  17901. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17902. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17903. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17905. builder.ParagraphFormat.LineSpacing = 1;
  17906. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17907. builder.ParagraphFormat.Style.Font.Size = 9;
  17908. builder.ParagraphFormat.Style.Font.Bold = true;
  17909. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17910. builder.StartTable();
  17911. // 设置边框颜色
  17912. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17913. //设置边框样式
  17914. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17915. //表格
  17916. #region 第一行
  17917. builder.InsertCell();
  17918. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17919. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17920. //builder.CellFormat.AllowAutoFit = false;
  17921. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17922. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17923. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17924. builder.CellFormat.WrapText = true; //自动换行
  17925. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17926. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17927. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17928. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17929. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17930. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17931. builder.Write("TOUR NO:");
  17932. builder.InsertCell();
  17933. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17934. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17935. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17936. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17937. builder.ParagraphFormat.Style.Font.Bold = false;
  17938. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17939. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17940. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17941. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17942. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17943. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17944. builder.Write($"{dele?.TourCode ?? "-"}");
  17945. builder.InsertCell();
  17946. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17947. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17948. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17949. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17950. builder.ParagraphFormat.Style.Font.Bold = false;
  17951. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17952. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17953. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17954. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17955. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17956. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17957. builder.Write($"CITY:");
  17958. builder.InsertCell();
  17959. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17960. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17961. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17962. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17963. builder.ParagraphFormat.Style.Font.Bold = false;
  17964. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17965. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17966. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17967. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17968. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17969. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17970. builder.Write($"{item.City}");
  17971. builder.EndRow();
  17972. #endregion
  17973. #region 第二行
  17974. builder.InsertCell();
  17975. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17976. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17977. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17978. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17979. builder.ParagraphFormat.Style.Font.Bold = false;
  17980. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17981. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17982. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17983. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17984. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17985. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17986. builder.Write("CONFIRMATION NO:");
  17987. builder.InsertCell();
  17988. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17989. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17990. builder.ParagraphFormat.Style.Font.Size = 8;
  17991. builder.ParagraphFormat.Style.Font.Bold = false;
  17992. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17993. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17994. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17995. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17996. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17997. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17998. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17999. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18000. builder.Write($"{item.DetermineNo}");
  18001. builder.InsertCell();
  18002. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18003. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18004. builder.InsertCell();
  18005. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18006. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18007. builder.EndRow();
  18008. #endregion
  18009. #region 第三行
  18010. builder.InsertCell();
  18011. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18012. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18013. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18014. builder.ParagraphFormat.Style.Font.Bold = false;
  18015. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18016. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18017. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18018. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18019. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18020. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18021. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18022. builder.Write($"HOTEL NAME:");
  18023. builder.InsertCell();
  18024. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18025. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18026. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18027. builder.ParagraphFormat.Style.Font.Bold = false;
  18028. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18029. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18030. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18031. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18032. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18033. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18034. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18035. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18036. builder.Write($"{item.HotelName}");
  18037. builder.InsertCell();
  18038. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18039. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18040. builder.InsertCell();
  18041. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18042. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18043. builder.EndRow();
  18044. #endregion
  18045. #region 第四行
  18046. builder.InsertCell();
  18047. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18048. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18049. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18050. builder.ParagraphFormat.Style.Font.Bold = false;
  18051. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18052. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18053. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18054. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18055. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18056. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18057. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18058. builder.Write($"HOTEL ADDRESS:");
  18059. builder.InsertCell();
  18060. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18061. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18062. builder.ParagraphFormat.Style.Font.Size = 8;
  18063. builder.ParagraphFormat.Style.Font.Bold = false;
  18064. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18065. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18066. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18067. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18068. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18069. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18070. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18071. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18072. builder.Write($"{item.HotelAddress}");
  18073. builder.InsertCell();
  18074. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18075. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18076. builder.InsertCell();
  18077. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18078. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18079. builder.EndRow();
  18080. #endregion
  18081. #region 第五行
  18082. builder.InsertCell();
  18083. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18084. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18085. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18086. builder.ParagraphFormat.Style.Font.Bold = false;
  18087. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18088. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18089. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18090. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18091. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18092. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18093. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18094. builder.Write("TEL:");
  18095. builder.InsertCell();
  18096. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18097. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18098. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18099. builder.ParagraphFormat.Style.Font.Bold = false;
  18100. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18101. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18102. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18103. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18104. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18105. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18106. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18107. builder.Write($"{item.HotelTel}");
  18108. builder.InsertCell();
  18109. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18110. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18111. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18112. builder.ParagraphFormat.Style.Font.Bold = false;
  18113. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18114. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18115. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18116. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18117. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18118. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18119. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18120. builder.Write($"FAX:");
  18121. builder.InsertCell();
  18122. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18123. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18124. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18125. builder.ParagraphFormat.Style.Font.Bold = false;
  18126. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18127. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18128. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18129. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18130. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18131. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18132. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18133. builder.Write($"{item.HotelFax}");
  18134. builder.EndRow();
  18135. #endregion
  18136. #region 第六行
  18137. builder.InsertCell();
  18138. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18139. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18140. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18141. builder.ParagraphFormat.Style.Font.Bold = false;
  18142. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18143. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18144. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18145. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18146. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18147. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18148. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18149. builder.Write("CHECK IN:");
  18150. builder.InsertCell();
  18151. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18152. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18153. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18154. builder.ParagraphFormat.Style.Font.Bold = false;
  18155. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18156. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18157. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18158. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18159. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18160. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18161. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18162. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18163. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18164. builder.Write($"{checkInStr}");
  18165. builder.InsertCell();
  18166. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18167. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18168. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18169. builder.ParagraphFormat.Style.Font.Bold = false;
  18170. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18171. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18172. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18173. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18174. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18175. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18176. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18177. builder.Write($"CHECK OUT:");
  18178. builder.InsertCell();
  18179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18180. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18181. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18182. builder.ParagraphFormat.Style.Font.Bold = false;
  18183. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18184. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18185. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18186. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18187. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18188. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18189. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18190. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18191. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18192. builder.Write($"{checkOutStr}");
  18193. builder.EndRow();
  18194. #endregion
  18195. #region 第七行
  18196. builder.InsertCell();
  18197. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18198. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18199. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18200. builder.ParagraphFormat.Style.Font.Bold = false;
  18201. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18202. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18203. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18204. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18205. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18206. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18207. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18208. builder.Write($"GUEST NAME:");
  18209. builder.InsertCell();
  18210. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18211. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18212. builder.ParagraphFormat.Style.Font.Size = 8;
  18213. builder.ParagraphFormat.Style.Font.Bold = false;
  18214. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18215. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18216. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18217. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18218. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18219. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18220. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18221. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18222. builder.Write($"{item.GuestName.Trim()}");
  18223. builder.InsertCell();
  18224. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18225. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18226. builder.InsertCell();
  18227. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18228. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18229. builder.EndRow();
  18230. #endregion
  18231. #region 第八行
  18232. builder.InsertCell();
  18233. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18234. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18235. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18236. builder.ParagraphFormat.Style.Font.Bold = false;
  18237. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18238. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18239. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18240. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18241. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18242. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18243. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18244. builder.Write($"ROOM TYPE:");
  18245. builder.InsertCell();
  18246. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18247. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18248. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18249. builder.ParagraphFormat.Style.Font.Bold = false;
  18250. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18251. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18252. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18253. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18254. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18255. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18256. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18257. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18258. builder.Write($"{item.RoomExplanation}");
  18259. builder.InsertCell();
  18260. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18261. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18262. builder.InsertCell();
  18263. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18264. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18265. builder.EndRow();
  18266. #endregion
  18267. #region 第九行
  18268. builder.InsertCell();
  18269. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18270. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18271. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18272. builder.ParagraphFormat.Style.Font.Bold = false;
  18273. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18274. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18275. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18276. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18277. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18278. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18279. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18280. builder.Write($"NOTE:");
  18281. builder.InsertCell();
  18282. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18283. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18284. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18285. builder.ParagraphFormat.Style.Font.Bold = false;
  18286. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18287. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18288. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18289. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18290. 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.");
  18291. builder.InsertCell();
  18292. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18293. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18294. builder.InsertCell();
  18295. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18296. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18297. builder.EndRow();
  18298. #endregion
  18299. builder.EndTable();
  18300. //换行
  18301. builder.Writeln("");
  18302. builder.Writeln("");
  18303. }
  18304. #region 获取文档中的所有表格 设置文字自适应
  18305. // 获取文档中的所有表格。
  18306. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18307. {
  18308. // 遍历表格中的所有行。
  18309. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18310. {
  18311. foreach (Cell cell in row.Cells)
  18312. {
  18313. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18314. cellFormat.Width = 0;
  18315. }
  18316. }
  18317. }
  18318. #endregion
  18319. #region 设置页眉
  18320. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18321. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18322. if (System.IO.File.Exists(voucherHeaderPath))
  18323. {
  18324. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18325. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18326. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18327. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18328. // 调整图片位置
  18329. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18330. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18331. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18332. shape.Left = 0; // 将图片距离页面左边缘的距离
  18333. shape.Width = 81; // 设置图片宽度
  18334. shape.Height = 36; // 设置图片高度
  18335. }
  18336. //靠右
  18337. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18338. //// 设置页脚上下边距
  18339. //builder.PageSetup.HeaderDistance = 42;
  18340. // 添加页眉线
  18341. Aspose.Words.Border borderHeader = null;
  18342. try
  18343. {
  18344. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18345. }
  18346. catch (Exception e)
  18347. {
  18348. // TODO Auto-generated catch block
  18349. //e.printStackTrace();
  18350. }
  18351. borderHeader.Shadow = true;
  18352. borderHeader.DistanceFromText = 2;
  18353. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18354. #endregion
  18355. }
  18356. catch (Exception ex)
  18357. {
  18358. }
  18359. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18360. doc.Save(fileDir);
  18361. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18362. return Ok(JsonView(true, "操作成功!", Url));
  18363. }
  18364. /// <summary>
  18365. /// 酒店预订
  18366. /// 生成 预定成本 Excel
  18367. /// </summary>
  18368. /// <param name="_dto"></param>
  18369. /// <returns></returns>
  18370. [HttpPost]
  18371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18372. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18373. {
  18374. #region 参数验证
  18375. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18376. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18377. if (!vadalitorRes.IsValid)
  18378. {
  18379. var errors = new StringBuilder();
  18380. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18381. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18382. }
  18383. #region 团组操作权限验证 76 酒店预定模块
  18384. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18385. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18386. #endregion
  18387. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18388. #region 页面操作权限验证
  18389. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18390. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18391. #endregion
  18392. #endregion
  18393. decimal _rate = 1.00M;
  18394. string _currency = string.Empty;
  18395. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18396. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18397. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18398. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18399. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18400. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18401. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18402. if (_GroupCostParameter == null)
  18403. {
  18404. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18405. bool isIntType = int.TryParse(_currency, out int currId);
  18406. if (isIntType)
  18407. {
  18408. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18409. }
  18410. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18411. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18412. if (currInfo == null)
  18413. {
  18414. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18415. }
  18416. else _rate = currInfo.Rate;
  18417. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18418. {
  18419. _rate = _GroupCostParameter.Rate;
  18420. }
  18421. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18422. //string strFileName = "HotelStatement/";
  18423. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18424. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18425. var rateDatas = new List<dynamic>();
  18426. #region 数据处理
  18427. foreach (var item in hrDtas)
  18428. {
  18429. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18430. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18431. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18432. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18433. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18434. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18435. {
  18436. continue;
  18437. }
  18438. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18439. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18440. string singleRoomFeeStr = string.Empty,
  18441. doubleRoomFeeStr = string.Empty,
  18442. suiteRoomFeeStr = string.Empty,
  18443. otherRoomFeeStr = string.Empty,
  18444. payMoneyStr = string.Empty,
  18445. cardPriceStr = string.Empty;
  18446. if (roomCurr.Equals("CNY"))
  18447. {
  18448. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18449. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18450. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18451. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18452. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18453. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18454. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18455. }
  18456. else
  18457. {
  18458. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18459. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18460. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18461. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18462. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18463. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18464. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18465. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18466. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18467. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18468. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18469. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18470. if (ccpPaymentCurrency.Equals("CNY"))
  18471. {
  18472. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18473. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18474. }
  18475. else
  18476. {
  18477. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18478. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18479. }
  18480. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18481. if (hotelcardPriceCurrency.Equals("CNY"))
  18482. {
  18483. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18484. }
  18485. else
  18486. {
  18487. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18488. }
  18489. }
  18490. string breakfastPriceStr = string.Empty,
  18491. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18492. governmentRentStr = string.Empty,
  18493. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18494. cityTaxStr = string.Empty,
  18495. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18496. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18497. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18498. {
  18499. if (breakfastCurrency1.Equals("CNY"))
  18500. {
  18501. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18502. }
  18503. else
  18504. {
  18505. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18506. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18507. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18508. }
  18509. }
  18510. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18511. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18512. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18513. {
  18514. if (governmentRentCurrency.Equals("CNY"))
  18515. {
  18516. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18517. }
  18518. else
  18519. {
  18520. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18521. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18522. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18523. }
  18524. }
  18525. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18526. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18527. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18528. {
  18529. if (cityTaxStrCurrency1.Equals("CNY"))
  18530. {
  18531. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18532. }
  18533. else
  18534. {
  18535. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18536. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18537. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18538. }
  18539. }
  18540. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18541. int payDId = roomInfo?.PayDId ?? 0;
  18542. pcfds.Add(new HotelReservations_PCFD_View()
  18543. {
  18544. City = item.City,
  18545. HotelName = item.HotelName,
  18546. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18547. // SingleRoomCount = item.SingleRoomCount,
  18548. SingleRoomPrice = singleRoomFeeStr,
  18549. // DoubleRoomCount = item.DoubleRoomCount,
  18550. DoubleRoomPrice = doubleRoomFeeStr,
  18551. //SuiteRoomCount = item.SuiteRoomCount,
  18552. SuiteRoomPrice = suiteRoomFeeStr,
  18553. OtherRoomPrice = otherRoomFeeStr,
  18554. //OtherRoomCount = item.OtherRoomCount,
  18555. BreakfastPrice = breakfastPriceStr,
  18556. GovernmentRent = governmentRentStr,
  18557. CityTax = cityTaxStr,
  18558. RoomExplanation = item.RoomExplanation,
  18559. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18560. PayTime = roomInfo?.ConsumptionDate,
  18561. BankNo = roomInfo?.BankNo,
  18562. PayMoney = payMoneyStr,
  18563. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18564. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18565. CardPrice = cardPriceStr,
  18566. Remark = ccpInfo.Remark
  18567. });
  18568. }
  18569. #endregion
  18570. //载入模板
  18571. WorkbookDesigner designer = new WorkbookDesigner();
  18572. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18573. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18574. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18575. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18576. var rateDatas1 = rateDatas.Distinct();
  18577. var rateStr = string.Empty;
  18578. foreach (var item in rateDatas1)
  18579. {
  18580. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18581. }
  18582. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18583. designer.SetDataSource("Opertor", userInfo.CnName);
  18584. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18585. dt.TableName = "ViewMyHotelReservations";
  18586. designer.SetDataSource(dt);
  18587. designer.Process();
  18588. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18589. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18590. designer.Workbook.Save(serverPath);
  18591. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18592. #region 删除指定行
  18593. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18594. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18595. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18596. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18597. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18598. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18599. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18600. cssIndex = dt.Columns["CityTax"].Ordinal,
  18601. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18602. remarkIndex = dt.Columns["Remark"].Ordinal;
  18603. //删除指定列
  18604. foreach (DataRow item in dt.Rows)
  18605. {
  18606. string singleStr = item["SingleRoomPrice"].ToString();
  18607. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18608. if (containsDigitButNotZero1) singleDel = false;
  18609. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18610. string doubleStr = item["DoubleRoomPrice"].ToString();
  18611. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18612. if (containsDigitButNotZero2) doubleDel = false;
  18613. string suiteStr = item["SuiteRoomPrice"].ToString();
  18614. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18615. if (containsDigitButNotZero3) suiteDel = false;
  18616. string otherStr = item["OtherRoomPrice"].ToString();
  18617. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18618. if (containsDigitButNotZero4) otherDel = false;
  18619. string zcStr = item["BreakfastPrice"].ToString();
  18620. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18621. if (containsDigitButNotZero5) zcDel = false;
  18622. string dsStr = item["GovernmentRent"].ToString();
  18623. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18624. if (containsDigitButNotZero6) dsDel = false;
  18625. string cssStr = item["CityTax"].ToString();
  18626. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18627. if (containsDigitButNotZero7) cssDel = false;
  18628. string cpStr = item["ConsumptionPatterns"].ToString();
  18629. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18630. string remarkStr = item["Remark"].ToString();
  18631. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18632. }
  18633. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18634. DeleteColumn(serverPath, cpIndex, cpDel);
  18635. DeleteColumn(serverPath, dsIndex, dsDel);
  18636. DeleteColumn(serverPath, cssIndex, cssDel);
  18637. DeleteColumn(serverPath, zcIndex, zcDel);
  18638. DeleteColumn(serverPath, otherIndex, otherDel);
  18639. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18640. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18641. DeleteColumn(serverPath, singleIndex, singleDel);
  18642. #endregion
  18643. //只保留第一个表格
  18644. DeleteSheet(serverPath);
  18645. return Ok(JsonView(true, "操作成功", url = rst));
  18646. }
  18647. else
  18648. {
  18649. _currency = _GroupCostParameter.Currency;
  18650. bool isIntType = int.TryParse(_currency, out int currId);
  18651. if (isIntType)
  18652. {
  18653. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18654. }
  18655. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18656. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18657. if (currInfo == null)
  18658. {
  18659. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18660. }
  18661. if (!_currency.ToUpper().Equals("CNY"))
  18662. {
  18663. _rate = _GroupCostParameter.Rate;
  18664. }
  18665. _rate = currInfo.Rate;
  18666. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18667. //string strFileName = "HotelStatement/";
  18668. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18669. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18670. #region 数据处理
  18671. foreach (var item in hrDtas)
  18672. {
  18673. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18674. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18675. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18676. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18677. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18678. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18679. string singleRoomFeeStr = string.Empty,
  18680. doubleRoomFeeStr = string.Empty,
  18681. suiteRoomFeeStr = string.Empty,
  18682. otherRoomFeeStr = string.Empty,
  18683. payMoneyStr = string.Empty,
  18684. cardPriceStr = string.Empty;
  18685. if (roomCurr.Equals(_currency))
  18686. {
  18687. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18688. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18689. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18690. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18691. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18692. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18693. }
  18694. else
  18695. {
  18696. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18697. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18698. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18699. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18700. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18701. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18702. }
  18703. string breakfastPriceStr = string.Empty,
  18704. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18705. governmentRentStr = string.Empty,
  18706. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18707. cityTaxStrStr = string.Empty,
  18708. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18709. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18710. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18711. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18712. int payDId = roomInfo?.PayDId ?? 0;
  18713. pcfds.Add(new HotelReservations_PCFD_View()
  18714. {
  18715. City = item.City,
  18716. HotelName = item.HotelName,
  18717. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18718. // SingleRoomCount = item.SingleRoomCount,
  18719. SingleRoomPrice = singleRoomFeeStr,
  18720. // DoubleRoomCount = item.DoubleRoomCount,
  18721. DoubleRoomPrice = doubleRoomFeeStr,
  18722. //SuiteRoomCount = item.SuiteRoomCount,
  18723. SuiteRoomPrice = suiteRoomFeeStr,
  18724. OtherRoomPrice = otherRoomFeeStr,
  18725. //OtherRoomCount = item.OtherRoomCount,
  18726. BreakfastPrice = breakfastPriceStr,
  18727. GovernmentRent = governmentRentStr,
  18728. CityTax = cityTaxStrStr,
  18729. RoomExplanation = item.RoomExplanation,
  18730. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18731. PayTime = roomInfo?.ConsumptionDate,
  18732. BankNo = roomInfo?.BankNo,
  18733. PayMoney = payMoneyStr,
  18734. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18735. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18736. CardPrice = cardPriceStr,
  18737. Remark = ccpInfo.Remark
  18738. });
  18739. }
  18740. #endregion
  18741. //载入模板
  18742. WorkbookDesigner designer = new WorkbookDesigner();
  18743. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18744. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18745. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18746. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18747. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18748. designer.SetDataSource("Opertor", userInfo.CnName);
  18749. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18750. dt.TableName = "ViewMyHotelReservations";
  18751. designer.SetDataSource(dt);
  18752. designer.Process();
  18753. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18754. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18755. designer.Workbook.Save(serverPath);
  18756. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18757. #region 删除指定行
  18758. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18759. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18760. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18761. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18762. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18763. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18764. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18765. cssIndex = dt.Columns["CityTax"].Ordinal,
  18766. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18767. remarkIndex = dt.Columns["Remark"].Ordinal;
  18768. //删除指定列
  18769. foreach (DataRow item in dt.Rows)
  18770. {
  18771. string singleStr = item["SingleRoomPrice"].ToString();
  18772. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18773. if (containsDigitButNotZero1) singleDel = false;
  18774. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18775. string doubleStr = item["DoubleRoomPrice"].ToString();
  18776. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18777. if (containsDigitButNotZero2) doubleDel = false;
  18778. string suiteStr = item["SuiteRoomPrice"].ToString();
  18779. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18780. if (containsDigitButNotZero3) suiteDel = false;
  18781. string otherStr = item["OtherRoomPrice"].ToString();
  18782. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18783. if (containsDigitButNotZero4) otherDel = false;
  18784. string zcStr = item["BreakfastPrice"].ToString();
  18785. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18786. if (containsDigitButNotZero5) zcDel = false;
  18787. string dsStr = item["GovernmentRent"].ToString();
  18788. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18789. if (containsDigitButNotZero6) dsDel = false;
  18790. string cssStr = item["CityTax"].ToString();
  18791. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18792. if (containsDigitButNotZero7) cssDel = false;
  18793. string cpStr = item["ConsumptionPatterns"].ToString();
  18794. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18795. string remarkStr = item["Remark"].ToString();
  18796. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18797. }
  18798. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18799. DeleteColumn(serverPath, cpIndex, cpDel);
  18800. DeleteColumn(serverPath, dsIndex, dsDel);
  18801. DeleteColumn(serverPath, cssIndex, cssDel);
  18802. DeleteColumn(serverPath, zcIndex, zcDel);
  18803. DeleteColumn(serverPath, otherIndex, otherDel);
  18804. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18805. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18806. DeleteColumn(serverPath, singleIndex, singleDel);
  18807. #endregion
  18808. //只保留第一个表格
  18809. DeleteSheet(serverPath);
  18810. return Ok(JsonView(true, "操作成功", url = rst));
  18811. }
  18812. //return Ok(JsonView(false));
  18813. }
  18814. /// <summary>
  18815. /// 删除指定列
  18816. /// </summary>
  18817. /// <param name="file"></param>
  18818. /// <param name="columnIndex"></param>
  18819. /// <param name="isDel"></param>
  18820. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18821. {
  18822. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18823. //wb.Save(file);
  18824. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18825. if (sheet1 != null)
  18826. {
  18827. if (isDel)
  18828. {
  18829. Cells cells = sheet1.Cells;
  18830. cells.DeleteColumn(columnIndex);
  18831. }
  18832. }
  18833. wb.Save(file);
  18834. }
  18835. /// <summary>
  18836. /// 删除sheet
  18837. /// </summary>
  18838. /// <param name="file"></param>
  18839. private void DeleteSheet(string file)
  18840. {
  18841. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18842. //wb.Save(file);
  18843. List<string> sheets = new List<string>();
  18844. foreach (var item in wb.Worksheets)
  18845. {
  18846. sheets.Add(item.Name);
  18847. }
  18848. if (sheets.Count > 0)
  18849. {
  18850. sheets.RemoveAt(0);//不删除第一个sheet
  18851. foreach (var item in sheets)
  18852. {
  18853. wb.Worksheets.RemoveAt(item);
  18854. }
  18855. }
  18856. wb.Save(file);
  18857. }
  18858. /// <summary>
  18859. /// 酒店预订
  18860. /// 确认单
  18861. /// </summary>
  18862. /// <param name="_dto"></param>
  18863. /// <returns></returns>
  18864. [HttpPost]
  18865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18866. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18867. {
  18868. try
  18869. {
  18870. #region 参数验证
  18871. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18872. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18873. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18874. #region 团组操作权限验证 76 酒店预定模块
  18875. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18876. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18877. #endregion
  18878. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18879. #region 页面操作权限验证
  18880. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18881. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18882. #endregion
  18883. #endregion
  18884. //团组信息
  18885. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18886. //酒店数据
  18887. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18888. if (listhoteldata.Count < 0)
  18889. {
  18890. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18891. }
  18892. //利datatable存储
  18893. DataTable dt = new DataTable();
  18894. dt.Columns.Add("CheckInDate", typeof(string));
  18895. dt.Columns.Add("City", typeof(string));
  18896. dt.Columns.Add("Hotel", typeof(string));
  18897. dt.Columns.Add("Room", typeof(string));
  18898. for (int i = 0; i < listhoteldata.Count; i++)
  18899. {
  18900. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18901. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18902. while (dayStart < dayEnd)
  18903. {
  18904. string temp = "";
  18905. DataRow row = dt.NewRow();
  18906. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18907. row["City"] = listhoteldata[i].City;
  18908. row["Hotel"] = listhoteldata[i].HotelName;
  18909. if (listhoteldata[i].SingleRoomCount > 0)
  18910. {
  18911. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18912. }
  18913. if (listhoteldata[i].DoubleRoomCount > 0)
  18914. {
  18915. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18916. }
  18917. if (listhoteldata[i].SuiteRoomCount > 0)
  18918. {
  18919. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18920. }
  18921. if (listhoteldata[i].OtherRoomCount > 0)
  18922. {
  18923. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18924. }
  18925. row["Room"] = temp;
  18926. dt.Rows.Add(row);
  18927. dayStart = dayStart.AddDays(1);
  18928. }
  18929. }
  18930. Dictionary<string, string> dic = new Dictionary<string, string>();
  18931. dic.Add("Dele", di.TeamName);
  18932. dic.Add("City", di.VisitCountry);
  18933. //模板路径
  18934. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18935. //载入模板
  18936. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18937. DocumentBuilder builder = new DocumentBuilder(doc);
  18938. foreach (var key in dic.Keys)
  18939. {
  18940. builder.MoveToBookmark(key);
  18941. builder.Write(dic[key]);
  18942. }
  18943. //获取word里所有表格
  18944. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18945. //获取所填表格的序数
  18946. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18947. var rowStart = tableOne.Rows[0]; //获取第1行
  18948. //循环赋值
  18949. for (int i = 0; i < dt.Rows.Count; i++)
  18950. {
  18951. builder.MoveToCell(0, i + 1, 0, 0);
  18952. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18953. builder.MoveToCell(0, i + 1, 1, 0);
  18954. builder.Write(dt.Rows[i]["City"].ToString());
  18955. builder.MoveToCell(0, i + 1, 2, 0);
  18956. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18957. builder.MoveToCell(0, i + 1, 3, 0);
  18958. builder.Write(dt.Rows[i]["Room"].ToString());
  18959. }
  18960. //删除多余行
  18961. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18962. {
  18963. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18964. }
  18965. string strFileName = di.TeamName + "酒店确认单.doc";
  18966. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18967. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18968. return Ok(JsonView(true, "成功", url));
  18969. }
  18970. catch (Exception ex)
  18971. {
  18972. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18973. }
  18974. }
  18975. #endregion
  18976. #region 团组状态
  18977. /// <summary>
  18978. /// 团组状态列表 Page
  18979. /// </summary>
  18980. /// <param name="dto">团组列表请求dto</param>
  18981. /// <returns></returns>
  18982. [HttpPost]
  18983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18984. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18985. {
  18986. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18987. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18988. {
  18989. string sqlWhere = string.Empty;
  18990. if (dto.IsSure == 0) //未完成
  18991. {
  18992. sqlWhere += string.Format(@" And IsSure = 0");
  18993. }
  18994. else if (dto.IsSure == 1) //已完成
  18995. {
  18996. sqlWhere += string.Format(@" And IsSure = 1");
  18997. }
  18998. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18999. {
  19000. string tj = dto.SearchCriteria;
  19001. 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}%')",
  19002. tj, tj, tj, tj, tj);
  19003. }
  19004. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19005. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19006. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19007. From (
  19008. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19009. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19010. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19011. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19012. From Grp_DelegationInfo gdi
  19013. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19014. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19015. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19016. Where gdi.IsDel = 0 {0}
  19017. ) temp ", sqlWhere);
  19018. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19019. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19020. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19021. }
  19022. else
  19023. {
  19024. return Ok(JsonView(false, "查询失败"));
  19025. }
  19026. }
  19027. /// <summary>
  19028. /// 团组状态
  19029. /// 设置操作完成
  19030. /// </summary>
  19031. /// <param name="dto">团组列表请求dto</param>
  19032. /// <returns></returns>
  19033. [HttpPost]
  19034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19035. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19036. {
  19037. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19038. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19039. {
  19040. Id = dto.Id,
  19041. IsSure = 1
  19042. };
  19043. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19044. .UpdateColumns(it => new { it.IsSure })
  19045. .WhereColumns(it => new { it.Id })
  19046. .ExecuteCommandAsync();
  19047. if (result > 0)
  19048. {
  19049. return Ok(JsonView(true, "操作完成!"));
  19050. }
  19051. return Ok(JsonView(false, "操作失败!"));
  19052. }
  19053. #endregion
  19054. #region 保险费用录入
  19055. /// <summary>
  19056. /// 根据团组Id查询保险费用列表
  19057. /// </summary>
  19058. /// <param name="dto"></param>
  19059. /// <returns></returns>
  19060. [HttpPost]
  19061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19062. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19063. {
  19064. Result groupData = await _customersRep.CustomersByDiId(dto);
  19065. if (groupData.Code != 0)
  19066. {
  19067. return Ok(JsonView(false, groupData.Msg));
  19068. }
  19069. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19070. }
  19071. /// <summary>
  19072. /// 根据保险费用Id查询保险费用详细
  19073. /// </summary>
  19074. /// <param name="dto"></param>
  19075. /// <returns></returns>
  19076. [HttpPost]
  19077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19078. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19079. {
  19080. try
  19081. {
  19082. Result groupData = await _customersRep.CustomersById(dto);
  19083. if (groupData.Code != 0)
  19084. {
  19085. return Ok(JsonView(false, groupData.Msg));
  19086. }
  19087. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19088. }
  19089. catch (Exception ex)
  19090. {
  19091. return Ok(JsonView(false, ex.Message));
  19092. }
  19093. }
  19094. /// <summary>
  19095. /// 保险费用录入页面初始化绑定
  19096. /// </summary>
  19097. /// <param name="dto"></param>
  19098. /// <returns></returns>
  19099. [HttpPost]
  19100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19101. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19102. {
  19103. try
  19104. {
  19105. Result groupData = await _customersRep.CustomersInitialize(dto);
  19106. if (groupData.Code != 0)
  19107. {
  19108. return Ok(JsonView(false, groupData.Msg));
  19109. }
  19110. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19111. }
  19112. catch (Exception ex)
  19113. {
  19114. return Ok(JsonView(false, ex.Message));
  19115. }
  19116. }
  19117. /// <summary>
  19118. /// 保险费用操作(Status:1.新增,2.修改)
  19119. /// </summary>
  19120. /// <param name="dto"></param>
  19121. /// <returns></returns>
  19122. [HttpPost]
  19123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19124. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19125. {
  19126. Result groupData = await _customersRep.OpCustomers(dto);
  19127. if (groupData.Code != 0)
  19128. {
  19129. return Ok(JsonView(false, groupData.Msg));
  19130. }
  19131. #region 应用推送
  19132. try
  19133. {
  19134. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19135. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19136. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19137. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19138. //自动审核
  19139. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19140. //2024-10-21 新增LZ UID
  19141. var userIds = new List<int>() { 21 };
  19142. string title = $"系统通知";
  19143. var diId = dto.DiId;
  19144. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19145. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19146. string content = "";
  19147. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19148. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19149. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19150. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19151. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19152. }
  19153. catch (Exception ex)
  19154. {
  19155. }
  19156. #endregion
  19157. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19158. }
  19159. /// <summary>
  19160. /// 保险文件上传
  19161. /// </summary>
  19162. /// <param name="file"></param>
  19163. /// <returns></returns>
  19164. [HttpPost]
  19165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19166. public async Task<IActionResult> UploadCus(IFormFile file)
  19167. {
  19168. try
  19169. {
  19170. if (file != null)
  19171. {
  19172. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19173. //文件名称
  19174. string projectFileName = file.FileName;
  19175. //上传的文件的路径
  19176. string filePath = "";
  19177. if (!Directory.Exists(fileDir))
  19178. {
  19179. Directory.CreateDirectory(fileDir);
  19180. }
  19181. //上传的文件的路径
  19182. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19183. using (FileStream fs = System.IO.File.Create(filePath))
  19184. {
  19185. file.CopyTo(fs);
  19186. fs.Flush();
  19187. }
  19188. return Ok(JsonView(true, "上传成功!", projectFileName));
  19189. }
  19190. else
  19191. {
  19192. return Ok(JsonView(false, "上传失败!"));
  19193. }
  19194. }
  19195. catch (Exception ex)
  19196. {
  19197. return Ok(JsonView(false, ex.Message));
  19198. }
  19199. }
  19200. /// <summary>
  19201. /// 保险删除指定文件
  19202. /// </summary>
  19203. /// <param name="dto"></param>
  19204. /// <returns></returns>
  19205. [HttpPost]
  19206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19207. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19208. {
  19209. try
  19210. {
  19211. string filePath = "";
  19212. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19213. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19214. //int id = 0;
  19215. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19216. // 删除该文件
  19217. try
  19218. {
  19219. System.IO.File.Delete(filePath);
  19220. 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()
  19221. {
  19222. Attachment = "",
  19223. }).ExecuteCommandAsync();
  19224. if (result != 0)
  19225. {
  19226. return Ok(JsonView(true, "成功!"));
  19227. }
  19228. else
  19229. {
  19230. return Ok(JsonView(false, "失败!"));
  19231. }
  19232. }
  19233. catch (Exception)
  19234. {
  19235. 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()
  19236. {
  19237. Attachment = "",
  19238. }).ExecuteCommandAsync();
  19239. if (result != 0)
  19240. {
  19241. return Ok(JsonView(true, "成功!"));
  19242. }
  19243. else
  19244. {
  19245. return Ok(JsonView(false, "失败!"));
  19246. }
  19247. }
  19248. }
  19249. catch (Exception ex)
  19250. {
  19251. return Ok(JsonView(false, "程序错误!"));
  19252. throw;
  19253. }
  19254. }
  19255. /// <summary>
  19256. /// 保险费用操作(删除)
  19257. /// </summary>
  19258. /// <param name="dto"></param>
  19259. /// <returns></returns>
  19260. [HttpPost]
  19261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19262. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19263. {
  19264. try
  19265. {
  19266. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19267. if (!res)
  19268. {
  19269. return Ok(JsonView(false, "删除失败"));
  19270. }
  19271. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19272. {
  19273. IsDel = 1,
  19274. DeleteUserId = dto.DeleteUserId,
  19275. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19276. }).ExecuteCommandAsync();
  19277. return Ok(JsonView(true, "删除成功!"));
  19278. }
  19279. catch (Exception ex)
  19280. {
  19281. return Ok(JsonView(false, "程序错误!"));
  19282. throw;
  19283. }
  19284. }
  19285. #endregion
  19286. #region 接团客户名单 PageId 104
  19287. /// <summary>
  19288. /// 接团客户名单
  19289. /// 迁移数据(慎用!)
  19290. /// </summary>
  19291. /// <returns></returns>
  19292. [HttpPost]
  19293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19294. public async Task<IActionResult> PostTourClientListChange()
  19295. {
  19296. try
  19297. {
  19298. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19299. //var groupClinetData1
  19300. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19301. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19302. int updateCount = 0;
  19303. if (oldOAClientList.Count > 0)
  19304. {
  19305. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19306. _sqlSugar.BeginTran();
  19307. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19308. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19309. foreach (var item in oldOAClientList)
  19310. {
  19311. int comId = 0;
  19312. string format = "yyyy-MM-dd HH:mm:ss";
  19313. string data11 = "1990-01-01 00:00";
  19314. var data1 = IsValidDate(item.OPdate, format);
  19315. if (data1) data11 = item.OPdate;
  19316. //客户公司验证
  19317. if (!string.IsNullOrEmpty(item.Company))
  19318. {
  19319. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19320. if (clientComInfo == null) // add
  19321. {
  19322. var addInfo = new Crm_CustomerCompany()
  19323. {
  19324. CompanyAbbreviation = "",
  19325. CompanyFullName = item.Company,
  19326. Address = "",
  19327. PostCodes = "",
  19328. LastedOpUserId = item.OPer,
  19329. LastedOpDt = Convert.ToDateTime(data11),
  19330. CreateUserId = item.OPer,
  19331. CreateTime = Convert.ToDateTime(data11),
  19332. IsDel = 0
  19333. };
  19334. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19335. if (comId1 > 0) comId = comId1;
  19336. }
  19337. else comId = clientComInfo.Id;
  19338. }
  19339. //客户人员验证
  19340. int clientId = 0;
  19341. string name = item.LastName + item.Name;
  19342. if (!string.IsNullOrEmpty(name))
  19343. {
  19344. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19345. if (clientInfo == null)
  19346. {
  19347. DateTime? dateTime = null;
  19348. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19349. if (isDt) dateTime = birthDayDt;
  19350. var addInfo1 = new Crm_DeleClient()
  19351. {
  19352. CrmCompanyId = comId,
  19353. DiId = -1,
  19354. LastName = item.LastName,
  19355. FirstName = item.Name,
  19356. OldName = "",
  19357. Pinyin = item.Pinyin,
  19358. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19359. Marriage = 0,
  19360. Phone = item.Phone,
  19361. Job = item.Job,
  19362. BirthDay = dateTime
  19363. };
  19364. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19365. if (clientId1 > 0) clientId = clientId1;
  19366. }
  19367. else clientId = clientInfo.Id;
  19368. }
  19369. if (clientId < 1)
  19370. {
  19371. continue;
  19372. }
  19373. int airType = 0;
  19374. if (item.AirType == "超经舱") airType = 459;
  19375. else if (item.AirType == "公务舱") airType = 458;
  19376. else if (item.AirType == "经济舱") airType = 460;
  19377. else if (item.AirType == "其他") airType = 565;
  19378. else if (item.AirType == "头等舱") airType = 457;
  19379. var _TourClientListEntity = new Grp_TourClientList()
  19380. {
  19381. DiId = item.Diid,
  19382. ClientId = clientId,
  19383. CreateUserId = item.OPer,
  19384. CreateTime = Convert.ToDateTime(data11),
  19385. Remark = item.Remark,
  19386. IsDel = item.Isdel,
  19387. ShippingSpaceTypeId = airType,
  19388. ShippingSpaceSpecialNeeds = item.AirRemark,
  19389. HotelSpecialNeeds = item.RoomType
  19390. };
  19391. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19392. if (_TourClientList > 0)
  19393. {
  19394. updateCount++;
  19395. }
  19396. }
  19397. _sqlSugar.CommitTran();
  19398. }
  19399. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19400. }
  19401. catch (Exception ex)
  19402. {
  19403. _sqlSugar.RollbackTran();
  19404. return Ok(JsonView(false, ex.Message));
  19405. }
  19406. //return Ok(JsonView(true));
  19407. }
  19408. private bool IsValidDate(string dateString, string format)
  19409. {
  19410. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19411. }
  19412. /// <summary>
  19413. /// 接团客户名单
  19414. /// 根据团组Id查询List
  19415. /// </summary>
  19416. /// <param name="_dto"></param>
  19417. /// <returns></returns>
  19418. [HttpPost]
  19419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19420. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19421. {
  19422. #region 参数验证
  19423. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19424. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19425. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19426. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19427. #region 页面操作权限验证
  19428. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19429. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19430. #endregion
  19431. #endregion
  19432. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19433. if (viewData.Code != 0)
  19434. {
  19435. return Ok(JsonView(false, viewData.Msg));
  19436. }
  19437. return Ok(JsonView(viewData.Data));
  19438. }
  19439. /// <summary>
  19440. /// 接团客户名单
  19441. /// 基础数据 Init
  19442. /// </summary>
  19443. /// <param name="_dto"></param>
  19444. /// <returns></returns>
  19445. [HttpPost]
  19446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19447. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19448. {
  19449. #region 参数验证
  19450. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19451. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19452. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19453. #region 页面操作权限验证
  19454. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19455. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19456. #endregion
  19457. #endregion
  19458. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19459. }
  19460. /// <summary>
  19461. /// 接团客户名单
  19462. /// 根据 Id查询 Details
  19463. /// </summary>
  19464. /// <param name="_dto"></param>
  19465. /// <returns></returns>
  19466. [HttpPost]
  19467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19468. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19469. {
  19470. #region 参数验证
  19471. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19472. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19473. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19474. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19475. #region 页面操作权限验证
  19476. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19477. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19478. #endregion
  19479. #endregion
  19480. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19481. if (viewData.Code != 0)
  19482. {
  19483. return Ok(JsonView(false, viewData.Msg));
  19484. }
  19485. return Ok(JsonView(viewData.Data));
  19486. }
  19487. /// <summary>
  19488. /// 接团客户名单
  19489. /// Add Or Edit
  19490. /// </summary>
  19491. /// <param name="_dto"></param>
  19492. /// <returns></returns>
  19493. [HttpPost]
  19494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19495. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19496. {
  19497. #region 参数验证
  19498. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19499. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19500. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19501. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19502. #region 页面操作权限验证
  19503. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19504. if (_dto.Id == 0) //添加
  19505. {
  19506. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19507. }
  19508. else if (_dto.Id >= 0) //修改
  19509. {
  19510. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19511. }
  19512. #endregion
  19513. #endregion
  19514. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19515. if (viewData.Code != 0)
  19516. {
  19517. return Ok(JsonView(false, viewData.Msg));
  19518. }
  19519. return Ok(JsonView(true));
  19520. }
  19521. /// <summary>
  19522. /// 接团客户名单
  19523. /// json字符串 AddMultiple(添加多个)
  19524. /// </summary>
  19525. /// <param name="_dto"></param>
  19526. /// <returns></returns>
  19527. [HttpPost]
  19528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19529. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19530. {
  19531. #region 参数验证
  19532. string jsonLabel = _dto.JsonLabel;
  19533. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19534. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19535. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19536. #region 页面操作权限验证
  19537. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19538. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19539. #endregion
  19540. #endregion
  19541. var request = new TourClientListAddMultipleDto();
  19542. request.DiId = _dto.DiId;
  19543. request.UserId = _dto.UserId;
  19544. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19545. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19546. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19547. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19548. var infos = new List<TourClientListInfo>();
  19549. foreach (var data in datas)
  19550. {
  19551. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19552. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19553. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19554. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19555. {
  19556. continue;
  19557. }
  19558. infos.Add(new TourClientListInfo()
  19559. {
  19560. IsAccompany = 1,
  19561. LastName = lastName,
  19562. FirstName = firstName,
  19563. Pinyin = lastNameEn + @"/" + firstNameEn,
  19564. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19565. CompanyFullName = data.CompanyFullName,
  19566. Job = data.Job
  19567. });
  19568. }
  19569. if (infos.Any())
  19570. {
  19571. var viewData = await _tourClientListRep._AddMultiple(request);
  19572. if (viewData.Code != 0)
  19573. {
  19574. return Ok(JsonView(false, viewData.Msg));
  19575. }
  19576. return Ok(JsonView(true));
  19577. }
  19578. return Ok(JsonView(false));
  19579. }
  19580. /// <summary>
  19581. /// 接团客户名单
  19582. /// AddMultiple(添加多个)
  19583. /// </summary>
  19584. /// <param name="_dto"></param>
  19585. /// <returns></returns>
  19586. [HttpPost]
  19587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19588. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19589. {
  19590. #region 参数验证
  19591. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19592. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19593. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19594. #region 页面操作权限验证
  19595. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19596. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19597. #endregion
  19598. #endregion
  19599. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19600. if (viewData.Code != 0)
  19601. {
  19602. return Ok(JsonView(false, viewData.Msg));
  19603. }
  19604. return Ok(JsonView(true));
  19605. }
  19606. /// <summary>
  19607. /// 接团客户名单
  19608. /// Del
  19609. /// </summary>
  19610. /// <param name="_dto"></param>
  19611. /// <returns></returns>
  19612. [HttpPost]
  19613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19614. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19615. {
  19616. #region 参数验证
  19617. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19618. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19619. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19620. #region 页面操作权限验证
  19621. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19622. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19623. #endregion
  19624. #endregion
  19625. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19626. if (viewData.Code != 0)
  19627. {
  19628. return Ok(JsonView(false, viewData.Msg));
  19629. }
  19630. return Ok(JsonView(true));
  19631. }
  19632. /// <summary>
  19633. /// 接团客户名单
  19634. /// 文件下载 客户名单
  19635. /// </summary>
  19636. /// <param name="_dto"></param>
  19637. /// <returns></returns>
  19638. [HttpPost]
  19639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19640. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19641. {
  19642. #region 参数验证
  19643. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19644. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19645. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19646. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19647. #region 页面操作权限验证
  19648. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19649. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19650. #endregion
  19651. #endregion
  19652. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19653. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19654. From Grp_TourClientList tcl
  19655. Left Join
  19656. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19657. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19658. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19659. From Crm_DeleClient dc
  19660. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19661. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19662. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19663. Where dc.IsDel = 0) temp
  19664. On temp.DcId =tcl.ClientId
  19665. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19666. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19667. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19668. //载入模板
  19669. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19670. if (_dto.Language == 1)
  19671. {
  19672. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19673. }
  19674. //载入模板
  19675. var doc = new Document(tempPath);
  19676. DocumentBuilder builder = new DocumentBuilder(doc);
  19677. //获取word里所有表格
  19678. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19679. //获取所填表格的序数
  19680. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19681. var rowStart = tableOne.Rows[0]; //获取第1行
  19682. if (_dto.Language == 0)
  19683. {
  19684. //循环赋值
  19685. for (int i = 0; i < DcList.Count; i++)
  19686. {
  19687. EncryptionProcessor.DecryptProperties(DcList[i]);
  19688. builder.MoveToCell(0, i + 1, 0, 0);
  19689. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19690. builder.MoveToCell(0, i + 1, 1, 0);
  19691. int sex = DcList[i].Sex;
  19692. string sexStr = string.Empty;
  19693. if (sex == 0) sexStr = "男";
  19694. else if (sex == 1) sexStr = "女";
  19695. else sexStr = "未设置";
  19696. builder.Write(sexStr);
  19697. builder.MoveToCell(0, i + 1, 2, 0);
  19698. string birthDay = DcList[i].BirthDay;
  19699. string birthDayStr = string.Empty;
  19700. if (!string.IsNullOrEmpty(birthDay))
  19701. {
  19702. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19703. }
  19704. builder.Write(birthDayStr);
  19705. builder.MoveToCell(0, i + 1, 3, 0);
  19706. string company = "";
  19707. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19708. {
  19709. company = DcList[i].CompanyFullName.ToString();
  19710. }
  19711. builder.Write(company);
  19712. builder.MoveToCell(0, i + 1, 4, 0);
  19713. builder.Write(DcList[i].Job);
  19714. }
  19715. }
  19716. else if (_dto.Language == 1)
  19717. {
  19718. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19719. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19720. List<string> transArrayStr = new List<string>();
  19721. string transStrRes1 = "";
  19722. for (int i = 0; i < DcList.Count; i++)
  19723. {
  19724. var dc = DcList[i];
  19725. EncryptionProcessor.DecryptProperties(dc);
  19726. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19727. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19728. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19729. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19730. else transStrRes1 += $"{str1}|";
  19731. }
  19732. #region AI转英文
  19733. string jsonValue = JsonConvert.SerializeObject(DcList);
  19734. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19735. List<SeedMessages> messages = new List<SeedMessages>()
  19736. {
  19737. new SeedMessages
  19738. {
  19739. Role = KimiRole.user,
  19740. Content = jsonValue + text
  19741. }
  19742. };
  19743. KiMiApiClient client = new KiMiApiClient();
  19744. var kimiApiResult = await client.SeedMessage(messages);
  19745. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19746. string clients = kimiApiResult_JObject["content"].ToString();
  19747. string startStr = "```json", endStr = "```";
  19748. // 判断并清除开头部分
  19749. if (clients.StartsWith(startStr))
  19750. {
  19751. clients = clients.Remove(0, startStr.Length);
  19752. }
  19753. // 判断并清除结尾部分
  19754. if (clients.EndsWith(endStr))
  19755. {
  19756. clients = clients.Remove(clients.Length - endStr.Length);
  19757. }
  19758. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19759. //循环赋值
  19760. for (int i = 0; i < en_Json.Count; i++)
  19761. {
  19762. var dc = en_Json[i];
  19763. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19764. string PYName = dc.FirstName + " " + dc.LastName;
  19765. builder.MoveToCell(0, i + 1, 0, 0);
  19766. builder.Write(PYName);
  19767. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19768. builder.MoveToCell(0, i + 1, 1, 0);
  19769. builder.Write(sex);
  19770. DateTime birthDt;
  19771. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19772. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19773. builder.MoveToCell(0, i + 1, 2, 0);
  19774. builder.Write(birthday);
  19775. string company = string.Empty, job = string.Empty;
  19776. company = dc.CompanyFullName;
  19777. job = dc.Job;
  19778. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19779. {
  19780. //查询对照表
  19781. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19782. if (tempCec != null)
  19783. {
  19784. company = tempCec.enName;
  19785. }
  19786. }
  19787. builder.MoveToCell(0, i + 1, 3, 0);
  19788. builder.Write(company);
  19789. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19790. {
  19791. //查询对照表
  19792. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19793. if (tempPec != null)
  19794. {
  19795. job = tempPec.enName;
  19796. }
  19797. }
  19798. builder.MoveToCell(0, i + 1, 4, 0);
  19799. builder.Write(job);
  19800. }
  19801. #endregion
  19802. #region 旧翻译英文处理
  19803. ////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";
  19804. //string transStrRes = "";
  19805. //if (transStrRes1.Length > 0)
  19806. //{
  19807. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19808. //}
  19809. ////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
  19810. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19811. ////List<string> transArray = new List<string> { };
  19812. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19813. //if (transStrRes.Contains("|"))
  19814. //{
  19815. // string[] transArray1 = transStrRes.Split('|');
  19816. // if (transArray1.Length > 0)
  19817. // {
  19818. // foreach (var item in transArray1)
  19819. // {
  19820. // if (item.Contains("&"))
  19821. // {
  19822. // string[] transArray2 = item.Split('&');
  19823. // int index = 0;
  19824. // string companyName = "", job = "";
  19825. // if (transArray2.Length > 0)
  19826. // {
  19827. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19828. // if (1 < transArray2.Length) companyName = transArray2[1];
  19829. // if (2 < transArray2.Length) job = transArray2[2];
  19830. // }
  19831. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19832. // }
  19833. // }
  19834. // }
  19835. //}
  19836. ////循环赋值
  19837. //for (int i = 0; i < DcList.Count; i++)
  19838. //{
  19839. // string PYName = "";
  19840. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19841. // {
  19842. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19843. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19844. // PYName = PY_First + " " + PY_Last;
  19845. // }
  19846. // else
  19847. // {
  19848. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19849. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19850. // PYName = PY_First + " " + PY_Last;
  19851. // }
  19852. // builder.MoveToCell(0, i + 1, 0, 0);
  19853. // builder.Write(PYName);
  19854. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19855. // builder.MoveToCell(0, i + 1, 1, 0);
  19856. // builder.Write(sex);
  19857. // DateTime birthDt;
  19858. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19859. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19860. // builder.MoveToCell(0, i + 1, 2, 0);
  19861. // builder.Write(birthday);
  19862. // string company = string.Empty, job = string.Empty;
  19863. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19864. // if (dcTransInfo != null)
  19865. // {
  19866. // company = dcTransInfo.CompanyName;
  19867. // job = dcTransInfo.Job;
  19868. // }
  19869. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19870. // {
  19871. // //查询对照表
  19872. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19873. // if (tempCec != null)
  19874. // {
  19875. // company = tempCec.enName;
  19876. // }
  19877. // //翻译
  19878. // else
  19879. // {
  19880. // }
  19881. // }
  19882. // builder.MoveToCell(0, i + 1, 3, 0);
  19883. // builder.Write(company);
  19884. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19885. // {
  19886. // //查询对照表
  19887. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19888. // if (tempPec != null)
  19889. // {
  19890. // job = tempPec.enName;
  19891. // }
  19892. // //翻译
  19893. // else
  19894. // {
  19895. // }
  19896. // }
  19897. // builder.MoveToCell(0, i + 1, 4, 0);
  19898. // builder.Write(job);
  19899. //}
  19900. #endregion
  19901. }
  19902. //删除多余行
  19903. while (tableOne.Rows.Count > DcList.Count + 1)
  19904. {
  19905. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19906. }
  19907. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19908. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19909. doc.Save(fileDir);
  19910. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19911. return Ok(JsonView(true, "操作成功!", Url));
  19912. }
  19913. private class TranslateInfo
  19914. {
  19915. public int Index { get; set; }
  19916. public string CompanyName { get; set; }
  19917. public string Job { get; set; }
  19918. }
  19919. [HttpPost]
  19920. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19921. {
  19922. if (files.Count == 0)
  19923. {
  19924. return Ok(JsonView(false, "文件为空"));
  19925. }
  19926. KiMiApiClient KiMiApi = new KiMiApiClient();
  19927. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19928. if (seedConter.Count == 0)
  19929. {
  19930. return Ok(JsonView(false, "上传结果为空!"));
  19931. }
  19932. var messages = new List<SeedMessages>
  19933. {
  19934. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19935. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19936. };
  19937. messages.InsertRange(1, seedConter);
  19938. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19939. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19940. string clients = kimiApiResult_JObject["content"].ToString();
  19941. string startStr = "```json", endStr = "```";
  19942. // 判断并清除开头部分
  19943. if (clients.StartsWith(startStr))
  19944. {
  19945. clients = clients.Remove(0, startStr.Length);
  19946. }
  19947. // 判断并清除结尾部分
  19948. if (clients.EndsWith(endStr))
  19949. {
  19950. clients = clients.Remove(clients.Length - endStr.Length);
  19951. }
  19952. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19953. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19954. {
  19955. {"姓", "LastName" },
  19956. {"名", "FirstName" },
  19957. {"姓名拼音", "Pinyin" },
  19958. {"性别", "Sex" },
  19959. {"单位", "CompanyFullName" },
  19960. {"职务", "Job" },
  19961. {"出生日期", "Birthday" },
  19962. };
  19963. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19964. foreach (var item in clients_JObject)
  19965. {
  19966. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19967. foreach (var field in clientFieldMap.Keys)
  19968. {
  19969. if (item.TryGetValue(field, out JToken value))
  19970. {
  19971. var getValue = value.ToString();
  19972. System.Type type = cdc.GetType();
  19973. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19974. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19975. propertyInfo.SetValue(cdc, propertyValue);
  19976. }
  19977. }
  19978. crmClients.Add(cdc);
  19979. }
  19980. return Ok(JsonView(new
  19981. {
  19982. fileCount = files.Count,
  19983. UploadCount = seedConter.Count,
  19984. ApiResult = clients,
  19985. CrmClients = crmClients
  19986. }));
  19987. }
  19988. #endregion
  19989. #region 团组倒推表
  19990. /// <summary>
  19991. /// 倒推表基础数据
  19992. /// Init
  19993. /// </summary>
  19994. /// <returns></returns>
  19995. [HttpPost]
  19996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19997. public async Task<IActionResult> PostInvertedListInit()
  19998. {
  19999. var viewData = await _invertedListRep._Init();
  20000. if (viewData.Code != 0)
  20001. {
  20002. return Ok(JsonView(false, viewData.Msg));
  20003. }
  20004. return Ok(JsonView(viewData.Data));
  20005. }
  20006. /// <summary>
  20007. /// 倒推表
  20008. /// Info
  20009. /// </summary>
  20010. /// <param name="dto"></param>
  20011. /// <returns></returns>
  20012. [HttpPost]
  20013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20014. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20015. {
  20016. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20017. if (viewData.Code != 0)
  20018. {
  20019. return Ok(JsonView(false, viewData.Msg));
  20020. }
  20021. return Ok(JsonView(viewData.Data));
  20022. }
  20023. /// <summary>
  20024. /// 倒推表
  20025. /// Create
  20026. /// </summary>
  20027. /// <param name="dto"></param>
  20028. /// <returns></returns>
  20029. [HttpPost]
  20030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20031. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20032. {
  20033. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20034. if (viewData.Code != 0)
  20035. {
  20036. return Ok(JsonView(false, viewData.Msg));
  20037. }
  20038. return Ok(JsonView(viewData.Data));
  20039. }
  20040. /// <summary>
  20041. /// 倒推表
  20042. /// Update
  20043. /// </summary>
  20044. /// <param name="dto"></param>
  20045. /// <returns></returns>
  20046. [HttpPost]
  20047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20048. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20049. {
  20050. var viewData = await _invertedListRep._Update(dto);
  20051. if (viewData.Code != 0)
  20052. {
  20053. return Ok(JsonView(false, viewData.Msg));
  20054. }
  20055. return Ok(JsonView(viewData.Data));
  20056. }
  20057. /// <summary>
  20058. /// 倒推表
  20059. /// File Download
  20060. /// </summary>
  20061. /// <param name="dto"></param>
  20062. /// <returns></returns>
  20063. [HttpPost]
  20064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20065. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20066. {
  20067. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20068. if (info2.Code != 0)
  20069. {
  20070. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20071. }
  20072. var info1 = info2.Data as InvertedListInfoView;
  20073. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20074. string teamName = "";
  20075. if (info != null) teamName = info.TeamName;
  20076. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20077. var doc = new Document();
  20078. var builder = new DocumentBuilder(doc);
  20079. #region old insert
  20080. ////载入模板
  20081. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20082. //Document doc = new Document(tempPath);
  20083. //DocumentBuilder builder = new DocumentBuilder(doc);
  20084. //利用键值对存放数据
  20085. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20086. //dic.Add("TeamName", teamName);
  20087. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20088. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20089. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20090. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20091. //dic.Add("SQRemark", info1.ApprovalRemark);
  20092. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20093. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20094. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20095. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20096. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20097. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20098. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20099. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20100. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20101. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20102. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20103. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20104. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20105. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20106. //#region 填充word模板书签内容
  20107. //foreach (var key in dic.Keys)
  20108. //{
  20109. // builder.MoveToBookmark(key);
  20110. // builder.Write(dic[key]);
  20111. //}
  20112. //#endregion
  20113. #endregion
  20114. #region New Insert
  20115. string titleFont = $"仿宋",
  20116. contentFont = $"仿宋";
  20117. var fontColor = Color.FromArgb(64, 64, 64);
  20118. //设置标题 团组名称
  20119. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20120. builder.Font.Name = titleFont;
  20121. builder.Font.Color = fontColor;
  20122. builder.Font.Size = 12;
  20123. builder.Font.Bold = true;
  20124. builder.Writeln(teamName);
  20125. //设置副标题 团组出访时间
  20126. builder.Font.Size = 12;
  20127. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20128. builder.Writeln();
  20129. var backgroundColor = Color.FromArgb(199, 199, 199);
  20130. var table = builder.StartTable();
  20131. builder.InsertCell();
  20132. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20133. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20134. builder.CellFormat.Borders.LineWidth = 1;
  20135. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20136. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20137. builder.RowFormat.Height = 40;
  20138. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20139. builder.Font.Name = contentFont;
  20140. builder.Font.Size = 12;
  20141. builder.Font.Bold = true;
  20142. builder.Font.Color = fontColor;
  20143. builder.Write("时间");
  20144. builder.InsertCell();
  20145. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20146. builder.Write("流程");
  20147. builder.InsertCell();
  20148. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20149. builder.Write("说明");
  20150. builder.EndRow();
  20151. //报批资料准备
  20152. if (info1.IsSelectedAirportd)
  20153. {
  20154. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20155. }
  20156. //报批/提供送签资料
  20157. if (info1.IsSelectedApprovalData)
  20158. {
  20159. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20160. }
  20161. //出批件护照办理
  20162. if (info1.IsSelectedIssueApproval)
  20163. {
  20164. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20165. }
  20166. //签证资料准备
  20167. if (info1.IsSelectedVisaInfo)
  20168. {
  20169. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20170. }
  20171. //送签
  20172. if (info1.IsSelectedSendVisa)
  20173. {
  20174. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20175. }
  20176. //出签
  20177. if (info1.IsSelectedIssueVisa)
  20178. {
  20179. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20180. }
  20181. //机票
  20182. if (info1.IsSelectedAirTicket)
  20183. {
  20184. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20185. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20186. }
  20187. //酒店
  20188. if (info1.IsSelectedHotel)
  20189. {
  20190. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20191. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20192. }
  20193. //开行前会
  20194. if (info1.IsSelectedPreTripMeeting)
  20195. {
  20196. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20197. }
  20198. //送机
  20199. if (info1.IsSelectedAirportdDropOff)
  20200. {
  20201. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20202. }
  20203. builder.EndTable();
  20204. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20205. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20206. for (int i = 0; i < table.Rows.Count; i++)
  20207. {
  20208. var row = table.Rows[i];
  20209. //设置宽度
  20210. row.Cells[0].CellFormat.Width = 20.00;
  20211. row.Cells[1].CellFormat.Width = 30.00;
  20212. row.Cells[2].CellFormat.Width = 50.00;
  20213. if (i != 0)
  20214. {
  20215. //边框设置
  20216. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20217. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20218. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20219. }
  20220. }
  20221. #region 页脚插入图片
  20222. // 创建页脚
  20223. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20224. doc.FirstSection.HeadersFooters.Add(footer);
  20225. Paragraph para = new Paragraph(doc);
  20226. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20227. footer.AppendChild(para);
  20228. builder.MoveTo(para);
  20229. string imagePath = "./Images/FMGJ_Log.png";
  20230. builder.InsertImage(imagePath);
  20231. #endregion
  20232. #endregion
  20233. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20234. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20235. string filePath = fileDir + $@"InvertedList/{fileName}";
  20236. doc.Save(filePath);
  20237. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20238. return Ok(JsonView(true, "操作成功!", Url));
  20239. }
  20240. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20241. {
  20242. var fontColor = Color.FromArgb(64, 64, 64);
  20243. builder.InsertCell();
  20244. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20245. builder.RowFormat.Height = 40;
  20246. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20247. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20248. builder.Font.Name = fontName;
  20249. builder.Font.Size = 8;
  20250. builder.Font.Bold = true;
  20251. builder.Font.Color = fontColor;
  20252. builder.Write(dateTime);
  20253. builder.InsertCell();
  20254. builder.Font.Size = 9;
  20255. builder.Font.Bold = true;
  20256. builder.Font.Color = fontColor;
  20257. builder.Write(content);
  20258. builder.InsertCell();
  20259. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20260. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20261. builder.Font.Size = 9;
  20262. builder.Font.Bold = false;
  20263. builder.Font.Color = fontColor;
  20264. builder.Write(reamrk);
  20265. builder.EndRow();
  20266. }
  20267. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20268. {
  20269. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20270. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20271. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20272. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20273. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20274. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20275. }
  20276. #endregion
  20277. #region 会务倒推表
  20278. /// <summary>
  20279. /// 会务倒推表
  20280. /// Init
  20281. /// </summary>
  20282. /// <returns></returns>
  20283. [HttpPost]
  20284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20285. public async Task<IActionResult> InforRetrogressTableInit()
  20286. {
  20287. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20288. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20289. return Ok(JsonView(false, groupData.Msg));
  20290. }
  20291. /// <summary>
  20292. /// 会务倒推表
  20293. /// ExcelDownload
  20294. /// </summary>
  20295. /// <param name="dto"></param>
  20296. /// <returns></returns>
  20297. [HttpPost]
  20298. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20300. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20301. {
  20302. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20303. var validatorRes = await validator.ValidateAsync(dto);
  20304. if (!validatorRes.IsValid)
  20305. {
  20306. StringBuilder sb = new StringBuilder();
  20307. foreach (var item in validatorRes.Errors)
  20308. {
  20309. sb.AppendLine(item.ErrorMessage);
  20310. }
  20311. return Ok(JsonView(false, sb.ToString()));
  20312. }
  20313. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20314. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20315. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20316. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20317. #region Excel
  20318. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20319. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20320. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20321. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20322. var fileNamePrefix = string.Empty;
  20323. if (days >= 30)
  20324. {
  20325. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20326. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20327. }
  20328. else if (days < 30 && days > 7)
  20329. {
  20330. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20331. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20332. }
  20333. else if (days <= 7)
  20334. {
  20335. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20336. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20337. }
  20338. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20339. fileName = CommonFun.ValidFileName(fileName);
  20340. //载入模板
  20341. WorkbookDesigner designer = new WorkbookDesigner();
  20342. designer.Workbook = new Workbook(tempPath);
  20343. designer.Process();
  20344. if (!Directory.Exists(savePath))
  20345. {
  20346. Directory.CreateDirectory(savePath);
  20347. }
  20348. string serverPath = $"{savePath}{fileName}";
  20349. designer.Workbook.Save(serverPath);
  20350. string rst = $"{servicePath}{ftpPath}{fileName}";
  20351. #endregion
  20352. return Ok(JsonView(new { url = rst }));
  20353. }
  20354. #endregion
  20355. #region 三公签证费用(签证费、代办费)
  20356. /// <summary>
  20357. /// 三公签证费用(签证费、代办费)
  20358. /// List
  20359. /// </summary>
  20360. /// <returns></returns>
  20361. [HttpPost]
  20362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20363. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20364. {
  20365. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20366. }
  20367. /// <summary>
  20368. /// 三公签证费用(签证费、代办费)
  20369. /// Add Or Update
  20370. /// </summary>
  20371. /// <returns></returns>
  20372. [HttpPost]
  20373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20374. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20375. {
  20376. var _view = await _visaFeeInfoRep.Update(_dto);
  20377. if (_view.Code != 0)
  20378. {
  20379. return Ok(JsonView(false, _view.Msg));
  20380. }
  20381. return Ok(JsonView(true, _view.Msg));
  20382. }
  20383. #endregion
  20384. #region 酒店询价
  20385. /// <summary>
  20386. /// 酒店询价
  20387. /// Init
  20388. /// </summary>
  20389. /// <returns></returns>
  20390. [HttpPost]
  20391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20392. public async Task<IActionResult> PostHotelInquiryInit()
  20393. {
  20394. var res = await _hotelInquiryRep._Init();
  20395. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20396. return Ok(JsonView(true, res.Msg, res.Data));
  20397. }
  20398. /// <summary>
  20399. /// 酒店询价
  20400. /// page Item
  20401. /// </summary>
  20402. /// <param name="_dto"></param>
  20403. /// <returns></returns>
  20404. [HttpPost]
  20405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20406. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20407. {
  20408. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20409. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20410. var view = res.Data as PageDataViewBase;
  20411. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20412. }
  20413. /// <summary>
  20414. /// 酒店询价
  20415. /// info
  20416. /// </summary>
  20417. /// <param name="_dto"></param>
  20418. /// <returns></returns>
  20419. [HttpPost]
  20420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20421. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20422. {
  20423. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20424. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20425. return Ok(JsonView(true, res.Msg, res.Data));
  20426. }
  20427. /// <summary>
  20428. /// 酒店询价
  20429. /// Add Or Edit
  20430. /// </summary>
  20431. /// <param name="_dto"></param>
  20432. /// <returns></returns>
  20433. [HttpPost]
  20434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20435. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20436. {
  20437. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20438. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20439. return Ok(JsonView(true, res.Msg, res.Data));
  20440. }
  20441. /// <summary>
  20442. /// 酒店询价
  20443. /// Del
  20444. /// </summary>
  20445. /// <param name="_dto"></param>
  20446. /// <returns></returns>
  20447. [HttpPost]
  20448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20449. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20450. {
  20451. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20452. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20453. return Ok(JsonView(true, res.Msg, res.Data));
  20454. }
  20455. #endregion
  20456. #region 下载匹配op行程单
  20457. /// <summary>
  20458. /// 匹配op行程单
  20459. /// Init
  20460. /// </summary>
  20461. /// <param name="dto">团组列表请求dto</param>
  20462. /// <returns></returns>
  20463. [HttpPost]
  20464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20465. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20466. {
  20467. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20468. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20469. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20470. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20471. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20472. .Where(it => it.IsDel == 0)
  20473. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20474. .OrderByDescending(it => it.VisitStartDate)
  20475. .ToList();
  20476. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20477. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20478. var diids = groupInfos.Select(it => it.Id).ToList();
  20479. List<string> countrys = new List<string>();
  20480. foreach (var item in country)
  20481. {
  20482. var data = _groupRepository.FormartTeamName(item);
  20483. var dataArray = _groupRepository.GroupSplitCountry(data);
  20484. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20485. }
  20486. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20487. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20488. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20489. foreach (var item in areaItem)
  20490. {
  20491. string areaStr = item.Value;
  20492. if (!string.IsNullOrEmpty(areaStr))
  20493. {
  20494. string[] str1 = areaStr.Split("-");
  20495. if (str1.Length > 0)
  20496. {
  20497. areaArray.AddRange(str1);
  20498. }
  20499. }
  20500. }
  20501. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20502. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20503. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20504. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20505. .ToList();
  20506. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20507. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20508. .Where(it => countriesIds.Contains(it.Id))
  20509. .Select(it => new { it.Id, Name = it.Name_CN })
  20510. .ToList();
  20511. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20512. .Select(it => it.TeamName).ToList();
  20513. stopwatch.Stop();
  20514. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20515. }
  20516. ///// <summary>
  20517. ///// 匹配op行程单
  20518. ///// Init 查询区域数据
  20519. ///// </summary>
  20520. ///// <param name="dto">团组列表请求dto</param>
  20521. ///// <returns></returns>
  20522. //[HttpPost]
  20523. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20524. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20525. //{
  20526. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20527. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20528. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20529. // if (string.IsNullOrEmpty(countriesDataStr))
  20530. // {
  20531. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20532. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20533. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20534. // }
  20535. // else
  20536. // {
  20537. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20538. // }
  20539. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20540. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20541. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20542. // List<dynamic> childList = new List<dynamic>();
  20543. // int parentId = dto.CountriesId;
  20544. // if (provinceData.Count > 1)
  20545. // {
  20546. // foreach (var item1 in provinceData)
  20547. // {
  20548. // List<dynamic> childList1 = new List<dynamic>();
  20549. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20550. // foreach (var item2 in citiesData1)
  20551. // {
  20552. // List<dynamic> childList2 = new List<dynamic>();
  20553. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20554. // foreach (var item3 in countiesData1)
  20555. // {
  20556. // childList2.Add(new
  20557. // {
  20558. // id = item3.Id,
  20559. // parentId = item2.Id,
  20560. // level = "district",
  20561. // name = item3.Name_CN,
  20562. // });
  20563. // }
  20564. // childList1.Add(new
  20565. // {
  20566. // id = item2.Id,
  20567. // parentId = item1.Id,
  20568. // level = "city",
  20569. // name = item2.Name_CN,
  20570. // childList = childList2
  20571. // });
  20572. // }
  20573. // childList.Add(new
  20574. // {
  20575. // id = item1.Id,
  20576. // parentId = parentId,
  20577. // level = "province",
  20578. // name = item1.Name_CN,
  20579. // childList = childList1
  20580. // });
  20581. // }
  20582. // //城市
  20583. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20584. // foreach (var item2 in citiesData2)
  20585. // {
  20586. // List<dynamic> childList22 = new List<dynamic>();
  20587. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20588. // foreach (var item3 in countiesData1)
  20589. // {
  20590. // childList22.Add(new
  20591. // {
  20592. // id = item3.Id,
  20593. // parentId = item2.Id,
  20594. // level = "district",
  20595. // name = item3.Name_CN,
  20596. // });
  20597. // }
  20598. // childList.Add(new
  20599. // {
  20600. // id = item2.Id,
  20601. // parentId = parentId,
  20602. // level = "city",
  20603. // name = item2.Name_CN,
  20604. // childList = childList22
  20605. // });
  20606. // }
  20607. // }
  20608. // else
  20609. // {
  20610. // foreach (var item2 in citiesData)
  20611. // {
  20612. // string cname = item2.Name_CN;
  20613. // List<dynamic> childList1 = new List<dynamic>();
  20614. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20615. // foreach (var item3 in countiesData1)
  20616. // {
  20617. // childList1.Add(new
  20618. // {
  20619. // Id = item3.Id,
  20620. // parentId = item2.Id,
  20621. // level = "district",
  20622. // name = item3.Name_CN
  20623. // });
  20624. // }
  20625. // childList.Add(new
  20626. // {
  20627. // id = item2.Id,
  20628. // parentId = parentId,
  20629. // level = "city",
  20630. // name = item2.Name_CN,
  20631. // childList = childList1
  20632. // });
  20633. // }
  20634. // }
  20635. // stopwatch.Stop();
  20636. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20637. //}
  20638. /// <summary>
  20639. /// 匹配op行程单
  20640. /// 接团信息列表 Page
  20641. /// </summary>
  20642. /// <param name="dto">团组列表请求dto</param>
  20643. /// <returns></returns>
  20644. [HttpPost]
  20645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20646. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20647. {
  20648. var swatch = new Stopwatch();
  20649. swatch.Start();
  20650. #region 参数验证
  20651. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20652. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20653. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20654. #region 页面操作权限验证
  20655. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20656. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20657. #endregion
  20658. #endregion
  20659. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20660. {
  20661. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20662. //string sqlWhere = "";
  20663. if (!string.IsNullOrEmpty(dto.Country))
  20664. {
  20665. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20666. }
  20667. if (!string.IsNullOrEmpty(dto.Area))
  20668. {
  20669. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20670. }
  20671. if (!string.IsNullOrEmpty(dto.TeamName))
  20672. {
  20673. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20674. }
  20675. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20676. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20677. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20678. swatch.Stop();
  20679. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20680. }
  20681. else
  20682. {
  20683. return Ok(JsonView(false, "查询失败"));
  20684. }
  20685. }
  20686. /// <summary>
  20687. /// 匹配op行程单
  20688. /// 行程单下载
  20689. /// </summary>
  20690. /// <param name="dto">团组列表请求dto</param>
  20691. /// <returns></returns>
  20692. [HttpPost]
  20693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20694. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20695. {
  20696. #region 参数验证
  20697. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20698. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20699. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20700. #region 页面操作权限验证
  20701. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20702. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20703. #endregion
  20704. #endregion
  20705. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20706. {
  20707. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20708. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20709. }
  20710. else
  20711. {
  20712. return Ok(JsonView(false, "下载失败!"));
  20713. }
  20714. }
  20715. #endregion
  20716. #region 国家信息 数据 注释
  20717. //[HttpPost]
  20718. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20719. //{
  20720. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20721. // foreach (var item in dto)
  20722. // {
  20723. // infos.Add(new Grp_GroupsTaskAssignment()
  20724. // {
  20725. // DIId = item,
  20726. // CTId = 82,
  20727. // UId = 248,
  20728. // IsEnable = 1,
  20729. // CreateUserId = 233,
  20730. // CreateTime = DateTime.Now,
  20731. // IsDel = 0
  20732. // });
  20733. // infos.Add(new Grp_GroupsTaskAssignment()
  20734. // {
  20735. // DIId = item,
  20736. // CTId = 82,
  20737. // UId = 286,
  20738. // IsEnable = 1,
  20739. // CreateUserId = 233,
  20740. // CreateTime = DateTime.Now,
  20741. // IsDel = 0
  20742. // });
  20743. // }
  20744. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20745. // return Ok("操作成功");
  20746. //}
  20747. //public class paramJsonDto
  20748. //{
  20749. // public List<CountriesInfo> str { get; set; }
  20750. //}
  20751. //[HttpPost]
  20752. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20753. //{
  20754. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20755. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20756. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20757. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20758. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20759. // _sqlSugar.BeginTran();
  20760. // int countitiesIndex = 0;
  20761. // foreach (var item in dto.str)
  20762. // {
  20763. // dynamic data = item.c;
  20764. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20765. // if (data != null)
  20766. // {
  20767. // countitiesIndex++;
  20768. // foreach (var item1 in data)
  20769. // {
  20770. // string cnname = item1.cn;
  20771. // string enname = item1.en;
  20772. // Sys_Cities provinceInfo = new Sys_Cities()
  20773. // {
  20774. // CountriesId = countriesId,
  20775. // Name_CN = cnname,
  20776. // Name_EN = enname,
  20777. // ParentId = 0,
  20778. // IsCapital = 1,
  20779. // CreateUserId = 208,
  20780. // CreateTime = DateTime.Now,
  20781. // IsDel = 0
  20782. // };
  20783. // if (item1.lv == "province") //省份
  20784. // {
  20785. // provinceInfo.Level = 1;
  20786. // int provinceId = 0;
  20787. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20788. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20789. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20790. // var data1 = item1.c;
  20791. // foreach (var item2 in data1)
  20792. // {
  20793. // if (item2.lv == "city")
  20794. // {
  20795. // string citycnname = item2.cn;
  20796. // string cityenname = item2.en;
  20797. // Sys_Cities cityInfo = new Sys_Cities()
  20798. // {
  20799. // CountriesId = countriesId,
  20800. // ParentId = provinceId,
  20801. // Level = 2,
  20802. // Name_CN = citycnname,
  20803. // Name_EN = cityenname,
  20804. // IsCapital = 1,
  20805. // CreateUserId = 208,
  20806. // CreateTime = DateTime.Now,
  20807. // IsDel = 0
  20808. // };
  20809. // if (item2.c != null)
  20810. // {
  20811. // int cityId = 0;
  20812. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20813. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20814. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20815. // foreach (var item3 in item2.c)
  20816. // {
  20817. // if (item3.lv == "district")
  20818. // {
  20819. // var districtInfo = new Sys_Cities()
  20820. // {
  20821. // CountriesId = countriesId,
  20822. // Name_CN = item3.cn,
  20823. // Name_EN = item3.en,
  20824. // Level = 3,
  20825. // ParentId = cityId,
  20826. // IsCapital = 1,
  20827. // CreateUserId = 208,
  20828. // CreateTime = DateTime.Now,
  20829. // IsDel = 0
  20830. // };
  20831. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20832. // //{
  20833. // districts.Add(districtInfo);
  20834. // //}
  20835. // }
  20836. // }
  20837. // }
  20838. // else
  20839. // {
  20840. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20841. // //{
  20842. // cities.Add(cityInfo);
  20843. // //}
  20844. // }
  20845. // }
  20846. // }
  20847. // }
  20848. // else if (item1.lv == "city")//城市
  20849. // {
  20850. // provinceInfo.Level = 2;
  20851. // if (item1.c != null)
  20852. // {
  20853. // int cityId = 0;
  20854. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20855. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20856. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20857. // foreach (var item3 in item1.c)
  20858. // {
  20859. // if (item3.lv == "district")
  20860. // {
  20861. // var districtInfo = new Sys_Cities()
  20862. // {
  20863. // CountriesId = countriesId,
  20864. // Name_CN = item3.cn,
  20865. // Name_EN = item3.en,
  20866. // Level = 3,
  20867. // ParentId = cityId,
  20868. // IsCapital = 1,
  20869. // CreateUserId = 208,
  20870. // CreateTime = DateTime.Now,
  20871. // IsDel = 0
  20872. // };
  20873. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20874. // //{
  20875. // districts.Add(districtInfo);
  20876. // //}
  20877. // }
  20878. // }
  20879. // }
  20880. // else
  20881. // {
  20882. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20883. // //{
  20884. // cities.Add(provinceInfo);
  20885. // //}
  20886. // }
  20887. // }
  20888. // }
  20889. // }
  20890. // }
  20891. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20892. // cities = cities.Distinct().ToList();
  20893. // districts = districts.Distinct().ToList();
  20894. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20895. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20896. // cities.AddRange(districts);
  20897. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20898. // //_sqlSugar.RollbackTran();
  20899. // _sqlSugar.CommitTran();
  20900. // return Ok(JsonView(false, "操作成功!"));
  20901. //}
  20902. //[HttpPost]
  20903. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20904. //{
  20905. // List<CountitiesInfo> infos = dto.MyProperty;
  20906. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20907. // _sqlSugar.BeginTran();
  20908. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20909. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20910. // foreach (var item in infos)
  20911. // {
  20912. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20913. // if (countryInfo != null)
  20914. // {
  20915. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20916. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20917. // if (cityInfo1 != null)
  20918. // {
  20919. // cityInfo1.IsCapital = 0;
  20920. // cityInfos.Add(cityInfo1);
  20921. // }
  20922. // }
  20923. // }
  20924. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20925. // .UpdateColumns(it => it.IsCapital)
  20926. // .WhereColumns(it => it.Id)
  20927. // .ExecuteCommand();
  20928. // //_sqlSugar.RollbackTran();
  20929. // _sqlSugar.CommitTran();
  20930. // return Ok(JsonView(false, "操作成功!"));
  20931. //}
  20932. //public class CounrtiesDto
  20933. //{
  20934. // public List<CountitiesInfo> MyProperty { get; set; }
  20935. //}
  20936. //public class CountitiesInfo
  20937. //{
  20938. // /// <summary>
  20939. // /// 圣约翰
  20940. // /// </summary>
  20941. // public string capital_name_chinese { get; set; }
  20942. // /// <summary>
  20943. // ///
  20944. // /// </summary>
  20945. // public string capital_name { get; set; }
  20946. // /// <summary>
  20947. // ///
  20948. // /// </summary>
  20949. // public string country_type { get; set; }
  20950. // /// <summary>
  20951. // /// 安提瓜和巴布达
  20952. // /// </summary>
  20953. // public string country_name_chinese { get; set; }
  20954. // /// <summary>
  20955. // /// 安提瓜和巴布达
  20956. // /// </summary>
  20957. // public string country_name_chinese_short { get; set; }
  20958. // /// <summary>
  20959. // /// 安提瓜和巴布达
  20960. // /// </summary>
  20961. // public string country_name_chinese_UN { get; set; }
  20962. // /// <summary>
  20963. // ///
  20964. // /// </summary>
  20965. // public string country_name_english_abbreviation { get; set; }
  20966. // /// <summary>
  20967. // ///
  20968. // /// </summary>
  20969. // public string country_name_english_formal { get; set; }
  20970. // /// <summary>
  20971. // ///
  20972. // /// </summary>
  20973. // public string country_name_english_UN { get; set; }
  20974. // /// <summary>
  20975. // ///
  20976. // /// </summary>
  20977. // public string continent_name { get; set; }
  20978. // /// <summary>
  20979. // ///
  20980. // /// </summary>
  20981. // public string subregion_name { get; set; }
  20982. // /// <summary>
  20983. // ///
  20984. // /// </summary>
  20985. // public string country_code2 { get; set; }
  20986. // /// <summary>
  20987. // ///
  20988. // /// </summary>
  20989. // public string country_code3 { get; set; }
  20990. // /// <summary>
  20991. // ///
  20992. // /// </summary>
  20993. // public string phone_code { get; set; }
  20994. //}
  20995. //public class CountriesInfo : BasicInfo
  20996. //{
  20997. // public List<CitiesInfo> c { get; set; }
  20998. //}
  20999. //public class CitiesInfo : BasicInfo
  21000. //{
  21001. // public List<AreaInfo> c { get; set; }
  21002. //}
  21003. //public class AreaInfo : BasicInfo
  21004. //{
  21005. // public List<AreaInfo> c { get; set; }
  21006. //}
  21007. //public class BasicInfo
  21008. //{
  21009. // public string code { get; set; }
  21010. // public string cn { get; set; }
  21011. // public string lv { get; set; }
  21012. // public string en { get; set; }
  21013. //}
  21014. #endregion
  21015. #region 查看邀请方
  21016. /// <summary>
  21017. /// 查看邀请方
  21018. /// 邀请方信息 Init
  21019. /// </summary>
  21020. /// <param name="dto"></param>
  21021. /// <returns></returns>
  21022. [HttpPost]
  21023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21024. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21025. {
  21026. string sqlWhere = string.Empty;
  21027. if (!string.IsNullOrEmpty(dto.Search))
  21028. {
  21029. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21030. }
  21031. string sql = string.Format($@"Select
  21032. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21033. Id,
  21034. UnitName
  21035. From Res_InvitationOfficialActivityData
  21036. Where IsDel = 0
  21037. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21038. RefAsync<int> total = 0;
  21039. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21040. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21041. }
  21042. /// <summary>
  21043. /// 查看邀请方
  21044. /// 国家信息 Init
  21045. /// </summary>
  21046. /// <param name="dto"></param>
  21047. /// <returns></returns>
  21048. [HttpPost]
  21049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21050. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21051. {
  21052. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21053. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21054. var diids = groupInfos.Select(it => it.Id).ToList();
  21055. List<string> countrys = new List<string>();
  21056. foreach (var item in country)
  21057. {
  21058. var data = _groupRepository.FormartTeamName(item);
  21059. var dataArray = _groupRepository.GroupSplitCountry(data);
  21060. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21061. }
  21062. countrys = countrys.Distinct().ToList();
  21063. for (int i = 0; i < countrys.Count; i++)
  21064. {
  21065. string item = countrys[i];
  21066. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21067. {
  21068. countrys.Remove(item);
  21069. i--;
  21070. }
  21071. }
  21072. RefAsync<int> total = 0;
  21073. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21074. .Where(it => countrys.Contains(it.Name_CN))
  21075. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21076. .Select(it => new { id = it.Id, name = it.Name_CN })
  21077. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21078. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21079. }
  21080. /// <summary>
  21081. /// 查看邀请方
  21082. /// 城市信息 Init
  21083. /// </summary>
  21084. /// <param name="dto"></param>
  21085. /// <returns></returns>
  21086. [HttpPost]
  21087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21088. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21089. {
  21090. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21091. RefAsync<int> total = 0;
  21092. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21093. .Where(it => it.CountriesId == dto.CountiesId)
  21094. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21095. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21096. .Select(it => new { id = it.Id, name = it.Name_CN })
  21097. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21098. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21099. }
  21100. /// <summary>
  21101. /// 查看邀请方
  21102. /// 团组名称 Init
  21103. /// </summary>
  21104. /// <param name="dto"></param>
  21105. /// <returns></returns>
  21106. [HttpPost]
  21107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21108. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21109. {
  21110. var watch = new Stopwatch();
  21111. watch.Start();
  21112. RefAsync<int> total = 0;
  21113. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21114. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21115. .Where((oa, di) => oa.IsDel == 0)
  21116. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21117. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21118. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21119. .Distinct()
  21120. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21121. watch.Stop();
  21122. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21123. }
  21124. /// <summary>
  21125. /// 查看邀请方
  21126. /// 团组 & 邀请方信息
  21127. /// </summary>
  21128. /// <param name="dto"></param>
  21129. /// <returns></returns>
  21130. [HttpPost]
  21131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21132. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21133. {
  21134. var watch = new Stopwatch();
  21135. watch.Start();
  21136. RefAsync<int> total = 0;
  21137. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21138. .AS("Grp_DelegationInfo")
  21139. .Includes(x => x.InvitingInfos)
  21140. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21141. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21142. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21143. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21144. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21145. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21146. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21147. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21148. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21149. infos.ForEach(x =>
  21150. {
  21151. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21152. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21153. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21154. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21155. });
  21156. watch.Stop();
  21157. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21158. }
  21159. #endregion
  21160. #region 报批行程
  21161. /// <summary>
  21162. /// 报批行程初始化
  21163. /// </summary>
  21164. /// <param name="dto"></param>
  21165. /// <returns></returns>
  21166. [HttpPost]
  21167. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21168. {
  21169. const int chiNumber = 5;
  21170. var jw = JsonView(false);
  21171. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21172. var group = groupList.First();
  21173. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21174. group = groupList.First(x => x.Id == diid);
  21175. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21176. .Where(x => x.DiId == diid && x.IsDel == 0)
  21177. .ToArray();
  21178. var count = 1;
  21179. foreach (var item in blackCodeList)
  21180. {
  21181. if (string.IsNullOrWhiteSpace(item.Title))
  21182. {
  21183. item.Title = "未设置名称数据" + count;
  21184. }
  21185. count++;
  21186. }
  21187. ;
  21188. if (group == null)
  21189. {
  21190. jw.Msg = "暂无团组!";
  21191. return Ok(jw);
  21192. }
  21193. var data = new
  21194. {
  21195. groupList = groupList.Select(x => new
  21196. {
  21197. x.TeamName,
  21198. x.Id
  21199. }),
  21200. content = new ArrayList(),
  21201. groupInfo = new
  21202. {
  21203. group.VisitDays,
  21204. group.TourCode,
  21205. group.VisitPNumber,
  21206. group.TeamName,
  21207. group.Id,
  21208. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21209. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21210. group.ClientUnit
  21211. },
  21212. blackCodeList = blackCodeList.Select(x => new
  21213. {
  21214. x.Title,
  21215. x.Id
  21216. }),
  21217. FileTempList = new ArrayList()
  21218. {
  21219. new { Index = 1,FileName = "旧模板" },
  21220. new { Index = 2,FileName = "省外办" },
  21221. new { Index = 3,FileName = "市外办" },
  21222. }
  21223. };
  21224. var resultArr = new ArrayList();
  21225. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21226. #region 默认不生成行程
  21227. //if (content.Count == 0)
  21228. //{
  21229. // var stay = "-";
  21230. // var cityPath = "-";
  21231. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21232. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21233. // .ToList();
  21234. // //添加城市路径以及住宿地
  21235. // //黑屏代码数据
  21236. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21237. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21238. // {
  21239. // jw = JsonView(true, "黑屏代码有误!", data);
  21240. // return Ok(jw);
  21241. // }
  21242. // data = data with
  21243. // {
  21244. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21245. // {
  21246. // x.Title,
  21247. // x.Id,
  21248. // }).ToArray())
  21249. // };
  21250. // foreach (DataRow row in dtBlack.Rows)
  21251. // {
  21252. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21253. // {
  21254. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21255. // return Ok(jw);
  21256. // }
  21257. // }
  21258. // //黑屏代码获取时间区间
  21259. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21260. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21261. // _sqlSugar.BeginTran();
  21262. // for (int i = 0; i < timeArr.Count; i++)
  21263. // {
  21264. // stay = "-";
  21265. // cityPath = "-";
  21266. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21267. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21268. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21269. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21270. // if (tbSelect.Length > 0)
  21271. // {
  21272. // List<string> threeCodeStr = new List<string>();
  21273. // foreach (var item in tbSelect)
  21274. // {
  21275. // var threeCode = item["Three"].ToString() ?? "";
  21276. // if (threeCode.Length == 6)
  21277. // {
  21278. // var start = threeCode.Substring(0, 3);
  21279. // var end = threeCode.Substring(3, 3);
  21280. // if (threeCodeStr.Count == 0)
  21281. // {
  21282. // threeCodeStr.Add(start);
  21283. // threeCodeStr.Add(end);
  21284. // }
  21285. // else
  21286. // {
  21287. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21288. // {
  21289. // threeCodeStr.Add(end);
  21290. // }
  21291. // else
  21292. // {
  21293. // threeCodeStr.Add(start);
  21294. // threeCodeStr.Add(end);
  21295. // }
  21296. // }
  21297. // }
  21298. // }
  21299. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21300. // var last = threeCodeStr.Last();
  21301. // foreach (var item in threeCodeStr)
  21302. // {
  21303. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21304. // if (item.Equals(last))
  21305. // {
  21306. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21307. // }
  21308. // }
  21309. // cityPath = cityPath.Trim('-');
  21310. // }
  21311. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21312. // appro.Diid = diid ?? -1;
  21313. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21314. // appro.Id = thisId;
  21315. // appro.CreateUserId = dto.UserId;
  21316. // appro.CreateTime = DateTime.Now;
  21317. // content.Add(appro);
  21318. // }
  21319. // _sqlSugar.CommitTran();
  21320. //}
  21321. #endregion
  21322. foreach (var x in content)
  21323. {
  21324. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21325. if (chiList.Count < chiNumber)
  21326. {
  21327. for (int i = chiList.Count; i < chiNumber; i++)
  21328. {
  21329. chiList.Add(new Grp_ApprovalTravelDetails());
  21330. }
  21331. }
  21332. resultArr.Add(new
  21333. {
  21334. x.Id,
  21335. x.Date,
  21336. x.Diid,
  21337. chiList = chiList.Select(x1 => new
  21338. {
  21339. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21340. x1.Details,
  21341. x1.ParentId,
  21342. x1.Id
  21343. })
  21344. });
  21345. }
  21346. data = data with
  21347. {
  21348. content = resultArr,
  21349. };
  21350. jw = JsonView(true, "获取成功!", data);
  21351. return Ok(jw);
  21352. }
  21353. /// <summary>
  21354. /// 报批行程删除
  21355. /// </summary>
  21356. /// <param name="dto"></param>
  21357. /// <returns></returns>
  21358. [HttpPost]
  21359. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21360. {
  21361. var jw = JsonView(false);
  21362. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21363. if (group == null)
  21364. {
  21365. jw.Msg = "团组参数有误!";
  21366. return Ok(jw);
  21367. }
  21368. try
  21369. {
  21370. _sqlSugar.BeginTran();
  21371. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21372. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21373. {
  21374. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21375. DeleteUserId = dto.uesrId,
  21376. IsDel = 1
  21377. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21378. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21379. {
  21380. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21381. DeleteUserId = dto.uesrId,
  21382. IsDel = 1
  21383. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21384. _sqlSugar.CommitTran();
  21385. jw = JsonView(true, "删除成功");
  21386. }
  21387. catch (Exception ex)
  21388. {
  21389. jw = JsonView(false, ex.Message);
  21390. }
  21391. return Ok(jw);
  21392. }
  21393. /// <summary>
  21394. /// 报批行程保存
  21395. /// </summary>
  21396. /// <param name="dto"></param>
  21397. /// <returns></returns>
  21398. [HttpPost]
  21399. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21400. {
  21401. var jw = JsonView(false);
  21402. var Find = dto.Arr.Find(x => x.id == 0);
  21403. if (Find != null)
  21404. {
  21405. jw.Msg = "生成的ID为0!";
  21406. return Ok(jw);
  21407. }
  21408. foreach (var item in dto.Arr)
  21409. {
  21410. foreach (var chi in item.chiList)
  21411. {
  21412. if (chi.parentId == 0)
  21413. {
  21414. chi.parentId = item.id;
  21415. }
  21416. }
  21417. }
  21418. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21419. _sqlSugar.BeginTran();
  21420. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21421. {
  21422. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21423. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21424. {
  21425. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21426. DeleteUserId = dto.UserId,
  21427. IsDel = 1
  21428. }).ExecuteCommand();
  21429. }
  21430. try
  21431. {
  21432. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21433. {
  21434. CreateTime = DateTime.Now,
  21435. CreateUserId = dto.UserId,
  21436. Details = x.details,
  21437. ParentId = x.parentId,
  21438. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21439. Remark = "",
  21440. IsDel = 0
  21441. }).ToList()).ExecuteCommand();
  21442. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21443. {
  21444. Id = x.id,
  21445. Details = x.details,
  21446. ParentId = x.parentId,
  21447. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21448. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21449. {
  21450. Details = x.Details,
  21451. ParentId = x.ParentId,
  21452. Time = x.Time
  21453. }).ExecuteCommand();
  21454. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21455. {
  21456. Id = x.id,
  21457. Date = x.date,
  21458. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21459. {
  21460. Date = x.Date
  21461. }).ExecuteCommand();
  21462. _sqlSugar.CommitTran();
  21463. jw = JsonView(true, "保存成功!");
  21464. }
  21465. catch (Exception ex)
  21466. {
  21467. _sqlSugar.RollbackTran();
  21468. jw = JsonView(false, "保存失败!" + ex.Message);
  21469. }
  21470. return Ok(jw);
  21471. }
  21472. /// <summary>
  21473. /// 报批行程生成
  21474. /// </summary>
  21475. /// <param name="dto"></param>
  21476. /// <returns></returns>
  21477. [HttpPost]
  21478. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21479. {
  21480. var jw = JsonView(false);
  21481. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21482. if (group == null)
  21483. {
  21484. jw.Msg = "暂无该团组!";
  21485. return Ok(jw);
  21486. }
  21487. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21488. //黑屏代码数据
  21489. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21490. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21491. {
  21492. jw.Msg = "黑屏代码有误!";
  21493. return Ok(jw);
  21494. }
  21495. foreach (DataRow row in dtBlack.Rows)
  21496. {
  21497. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21498. {
  21499. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21500. return Ok(jw);
  21501. }
  21502. }
  21503. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21504. var resultArr = new ArrayList();
  21505. //if (officialActivitiesArr.Count == 0)
  21506. //{
  21507. // jw.Msg = "暂无公务出访信息!";
  21508. // return Ok(jw);
  21509. //}
  21510. try
  21511. {
  21512. _sqlSugar.BeginTran();
  21513. DeleteApprovalJourney(new
  21514. Domain.Dtos.Groups.DeleteApprovalJourney
  21515. {
  21516. Diid = dto.Diid,
  21517. uesrId = dto.Userid
  21518. });
  21519. var stay = "-";
  21520. var cityPath = "-";
  21521. var arriveCountry = string.Empty;
  21522. //添加城市路径以及住宿地
  21523. //黑屏代码获取时间区间
  21524. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21525. var empty = "【未收入该三字码!请机票同事录入】";
  21526. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21527. #region 配置公务活动时间
  21528. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21529. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21530. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21531. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21532. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21533. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21534. {
  21535. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21536. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21537. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21538. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21539. };
  21540. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21541. {
  21542. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21543. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21544. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21545. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21546. };
  21547. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21548. {
  21549. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  21550. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  21551. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21552. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21553. };
  21554. #endregion
  21555. var nextDayNum = 0;
  21556. for (int i = 0; i < timeArr.Count; i++)
  21557. {
  21558. stay = "-";
  21559. cityPath = "-";
  21560. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21561. DateTime NewData = DateTime.Parse(timeArr[i]);
  21562. //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();
  21563. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21564. if (nextDayNum > 0)
  21565. {
  21566. nextDayNum--;
  21567. }
  21568. if (tbSelect.Length > 0)
  21569. {
  21570. List<string> threeCodeStr = new List<string>();
  21571. bool isTrade = false;
  21572. string trip = string.Empty;
  21573. foreach (var item in tbSelect)
  21574. {
  21575. if (nextDayNum == 0)
  21576. {
  21577. nextDayNum = Convert.ToInt32(item["Sign"]);
  21578. }
  21579. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21580. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21581. var takeOffTime = DateTime.Parse(timeArr[i]);
  21582. var fallToTime = DateTime.Parse(timeArr[i]);
  21583. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21584. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21585. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21586. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21587. if (nextDayNum > 0)
  21588. {
  21589. fallToTime = fallToTime.AddDays(nextDayNum);
  21590. }
  21591. trip = string.Empty;
  21592. var start = string.Empty;
  21593. var end = string.Empty;
  21594. var threeCode = item["Three"].ToString() ?? "";
  21595. if (threeCode.Length == 6)
  21596. {
  21597. start = threeCode.Substring(0, 3);
  21598. end = threeCode.Substring(3, 3);
  21599. if (threeCodeStr.Count == 0)
  21600. {
  21601. threeCodeStr.Add(start);
  21602. threeCodeStr.Add(end);
  21603. }
  21604. else
  21605. {
  21606. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21607. {
  21608. threeCodeStr.Add(end);
  21609. }
  21610. else
  21611. {
  21612. threeCodeStr.Add(start);
  21613. threeCodeStr.Add(end);
  21614. }
  21615. }
  21616. }
  21617. //处理机票信息
  21618. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21619. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21620. if (start_Object == null)
  21621. {
  21622. start_Object = new Res_ThreeCode()
  21623. {
  21624. AirPort = empty,
  21625. AirPort_En = empty,
  21626. City = empty,
  21627. Country = empty,
  21628. Four = empty,
  21629. Three = empty,
  21630. };
  21631. }
  21632. if (end_Object == null)
  21633. {
  21634. end_Object = new Res_ThreeCode()
  21635. {
  21636. AirPort = empty,
  21637. AirPort_En = empty,
  21638. City = empty,
  21639. Country = empty,
  21640. Four = empty,
  21641. Three = empty,
  21642. };
  21643. }
  21644. //机型判断
  21645. string airModel = item["AirModel"].ToString();
  21646. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21647. string flightTime = item["FlightTime"].ToString();
  21648. flightTime = ParseBlackTime(flightTime);
  21649. //航班号
  21650. string flightcode = item["Fliagtcode"].ToString();
  21651. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21652. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21653. if (aircompany == null)
  21654. {
  21655. aircompany = new Res_AirCompany
  21656. {
  21657. CnName = hsEmpty,
  21658. EnName = hsEmpty,
  21659. ShortCode = hsEmpty,
  21660. };
  21661. }
  21662. //航班前公务安排
  21663. if (tbSelect.First().Equals(item) && i != 0)
  21664. {
  21665. foreach (var takeoff in takeoffTimes)
  21666. {
  21667. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21668. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21669. {
  21670. foreach (var addTime in takeoff.Item2)
  21671. {
  21672. chiarr.Add(new Grp_ApprovalTravelDetails
  21673. {
  21674. Time = addTime,
  21675. CreateTime = DateTime.Now,
  21676. CreateUserId = dto.Userid,
  21677. ParentId = 0,
  21678. Details = "公务活动"
  21679. });
  21680. }
  21681. break;
  21682. }
  21683. }
  21684. }
  21685. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21686. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21687. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21688. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21689. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21690. if (isTrade)
  21691. {
  21692. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21693. trip += "(转机不出机场)。";
  21694. }
  21695. //else
  21696. //{
  21697. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21698. //}
  21699. chiarr.Add(new Grp_ApprovalTravelDetails
  21700. {
  21701. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21702. CreateTime = DateTime.Now,
  21703. CreateUserId = dto.Userid,
  21704. ParentId = 0,
  21705. Details = trip
  21706. });
  21707. //最后一条到达的时间安排公务
  21708. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21709. {
  21710. bool isCheckCountry = false;
  21711. if (end_Object.Country != arriveCountry)
  21712. {
  21713. arriveCountry = end_Object.Country;
  21714. isCheckCountry = true;
  21715. }
  21716. if (nextDayNum == 0)
  21717. {
  21718. //需要入境的情况
  21719. if (isCheckCountry)
  21720. {
  21721. foreach (var fallTime in fallTimesCheckCountry)
  21722. {
  21723. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21724. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21725. {
  21726. foreach (var addTime in fallTime.Item2)
  21727. {
  21728. chiarr.Add(new Grp_ApprovalTravelDetails
  21729. {
  21730. Time = addTime,
  21731. CreateTime = DateTime.Now,
  21732. CreateUserId = dto.Userid,
  21733. ParentId = 0,
  21734. Details = "公务活动"
  21735. });
  21736. }
  21737. break;
  21738. }
  21739. }
  21740. }
  21741. else
  21742. {
  21743. foreach (var fallTime in fallTimesNotCheckCountry)
  21744. {
  21745. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21746. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21747. {
  21748. foreach (var addTime in fallTime.Item2)
  21749. {
  21750. chiarr.Add(new Grp_ApprovalTravelDetails
  21751. {
  21752. Time = addTime,
  21753. CreateTime = DateTime.Now,
  21754. CreateUserId = dto.Userid,
  21755. ParentId = 0,
  21756. Details = "公务活动"
  21757. });
  21758. }
  21759. break;
  21760. }
  21761. }
  21762. }
  21763. }
  21764. }
  21765. }
  21766. //添加乘车语句
  21767. //chiarr.Add(new Grp_ApprovalTravelDetails
  21768. //{
  21769. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21770. // CreateTime = DateTime.Now,
  21771. // CreateUserId = dto.Userid,
  21772. // ParentId = 0,
  21773. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21774. //});
  21775. //if (i != timeArr.Count - 1)
  21776. //{
  21777. // fallToTime = fallToTime.AddHours(2.5);
  21778. // foreach (var item in Times)
  21779. // {
  21780. // //排列公务时间
  21781. // if (fallToTime.Hour < item.Item1)
  21782. // {
  21783. // chiarr.Add(new Grp_ApprovalTravelDetails
  21784. // {
  21785. // Time = $"{item.Item2} - {item.Item3}",
  21786. // CreateTime = DateTime.Now,
  21787. // CreateUserId = dto.Userid,
  21788. // ParentId = 0,
  21789. // Details = "公务活动"
  21790. // });
  21791. // }
  21792. // }
  21793. //}
  21794. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21795. var last = threeCodeStr.Last();
  21796. foreach (var item in threeCodeStr)
  21797. {
  21798. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21799. if (item.Equals(last))
  21800. {
  21801. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21802. }
  21803. }
  21804. cityPath = cityPath.Trim('-');
  21805. }
  21806. else
  21807. {
  21808. foreach (var item in Times)
  21809. {
  21810. chiarr.Add(new Grp_ApprovalTravelDetails
  21811. {
  21812. Time = $"{item.Item2} - {item.Item3}",
  21813. CreateTime = DateTime.Now,
  21814. CreateUserId = dto.Userid,
  21815. ParentId = 0,
  21816. Details = "公务活动"
  21817. });
  21818. }
  21819. }
  21820. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21821. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21822. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21823. appro.Diid = dto.Diid;
  21824. appro.CreateUserId = dto.Userid;
  21825. appro.CreateTime = DateTime.Now;
  21826. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21827. appro.Id = thisId;
  21828. //foreach (var item in gwinfo)
  21829. //{
  21830. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21831. // chi.Details = "拜访" + item.Client;
  21832. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21833. // {
  21834. // chi.Details += "," + item.ReqSample;
  21835. // }
  21836. // chi.ParentId = thisId;
  21837. // chi.Time = item.Time;
  21838. // chiarr.Add(chi);
  21839. //}
  21840. if (chiarr.Count < 6)
  21841. {
  21842. for (int j = chiarr.Count; j < 6; j++)
  21843. {
  21844. chiarr.Add(new
  21845. Grp_ApprovalTravelDetails());
  21846. }
  21847. }
  21848. resultArr.Add(new
  21849. {
  21850. appro.Id,
  21851. appro.Date,
  21852. appro.Diid,
  21853. chiList = chiarr.Select(x1 => new
  21854. {
  21855. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21856. x1.Details,
  21857. x1.ParentId,
  21858. x1.Id
  21859. })
  21860. });
  21861. }
  21862. _sqlSugar.CommitTran();
  21863. jw = JsonView(true, "生成成功!", resultArr);
  21864. }
  21865. catch (Exception ex)
  21866. {
  21867. jw.Code = 400;
  21868. jw.Msg = "生成失败!" + ex.Message;
  21869. }
  21870. return Ok(jw);
  21871. }
  21872. /// <summary>
  21873. /// 报批行程word导出
  21874. /// </summary>
  21875. /// <param name="dto"></param>
  21876. /// <returns></returns>
  21877. [HttpPost]
  21878. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21879. {
  21880. var jw = JsonView(false);
  21881. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21882. if (group == null)
  21883. {
  21884. jw.Msg = "暂无该团组!";
  21885. return Ok(jw);
  21886. }
  21887. //模板路径
  21888. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21889. var fileName = string.Empty;
  21890. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21891. bool bold = false;
  21892. if (dto.FileIndex == 1)
  21893. {
  21894. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21895. }
  21896. else if (dto.FileIndex == 2)
  21897. {
  21898. fileName = "省外办-报批.docx";
  21899. bold = false;
  21900. titleFont = "方正黑体简体";
  21901. timeFont = "Times New Roman";
  21902. contentFont = "方正仿宋_GBK";
  21903. }
  21904. else if (dto.FileIndex == 3)
  21905. {
  21906. fileName = "市外办-报批.docx";
  21907. titleFont = "方正黑体简体";
  21908. timeFont = "Times New Roman";
  21909. contentFont = "方正仿宋简体";
  21910. }
  21911. tempPath = tempPath + fileName;
  21912. //载入模板
  21913. Document doc = new Document(tempPath);
  21914. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21915. //获取所填表格的序数
  21916. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21917. Aspose.Words.Tables.Row titleRowClone = null;
  21918. Aspose.Words.Tables.Row CenterRowClone = null;
  21919. int index = 0;
  21920. int indexChi = 0;
  21921. int SetIndex = 0;
  21922. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21923. //获取数据,放到datatable
  21924. foreach (var item in ApprovalTravelArr)
  21925. {
  21926. if (index > 0)
  21927. {
  21928. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21929. tableOne.AppendChild(titleRowClone);
  21930. }
  21931. var textTime = item.Date;
  21932. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21933. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21934. SetIndex++;
  21935. if (ChiRep.Count > 0)
  21936. {
  21937. foreach (var itemChi in ChiRep)
  21938. {
  21939. var txtTime = itemChi.Time;
  21940. var txtDetail = itemChi.Details;
  21941. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21942. {
  21943. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21944. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21945. //indexChi++;
  21946. //SetIndex++;
  21947. break;
  21948. }
  21949. if (indexChi > 0)
  21950. {
  21951. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21952. tableOne.AppendChild(CenterRowClone);
  21953. }
  21954. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21955. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21956. indexChi++;
  21957. SetIndex++;
  21958. }
  21959. }
  21960. //else
  21961. //{
  21962. // if (indexChi > 0)
  21963. // {
  21964. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21965. // tableOne.AppendChild(CenterRowClone);
  21966. // }
  21967. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21968. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21969. // indexChi++;
  21970. // SetIndex++;
  21971. //}
  21972. index++;
  21973. }
  21974. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21975. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21976. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21977. jw.Code = 200;
  21978. jw.Msg = "";
  21979. return Ok(jw);
  21980. }
  21981. private string ParseBlackTime(string time)
  21982. {
  21983. // 匹配可能只有分钟的情况
  21984. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21985. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21986. if (match.Success)
  21987. {
  21988. string hours = match.Groups[1].Value;
  21989. string minutes = match.Groups[2].Value;
  21990. // 如果小时部分为空,则只显示分钟
  21991. if (string.IsNullOrEmpty(hours))
  21992. {
  21993. return $"{minutes}分钟";
  21994. }
  21995. // 如果分钟部分为空,则只显示小时
  21996. else if (string.IsNullOrEmpty(minutes))
  21997. {
  21998. return $"{hours}小时";
  21999. }
  22000. // 否则显示完整格式
  22001. else
  22002. {
  22003. return $"{hours}小时{minutes}分钟";
  22004. }
  22005. }
  22006. else
  22007. {
  22008. return "未知时长";
  22009. }
  22010. }
  22011. private string intToString(int numberVal)
  22012. {
  22013. string numberval = numberVal.ToString();
  22014. Dictionary<char, string> Number = new Dictionary<char, string>();
  22015. Number.Add('1', "一");
  22016. Number.Add('2', "二");
  22017. Number.Add('3', "三");
  22018. Number.Add('4', "四");
  22019. Number.Add('5', "五");
  22020. Number.Add('6', "六");
  22021. Number.Add('7', "七");
  22022. Number.Add('8', "八");
  22023. Number.Add('9', "九");
  22024. string stringNumberVal = string.Empty;
  22025. for (int i = 0; i < numberval.Length; i++)
  22026. {
  22027. if (i == 0)
  22028. {
  22029. stringNumberVal += Number[numberval[i]];
  22030. }
  22031. else if (i >= 1)
  22032. {
  22033. if (numberval[i] == '0')
  22034. {
  22035. stringNumberVal = "十";
  22036. }
  22037. else
  22038. {
  22039. stringNumberVal += "十" + Number[numberval[i]];
  22040. }
  22041. }
  22042. }
  22043. return stringNumberVal;
  22044. }
  22045. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22046. {
  22047. //获取table中的某个单元格,从0开始
  22048. Cell lshCell = table.Rows[rows].Cells[cells];
  22049. //将单元格中段落移除
  22050. foreach (Paragraph item in lshCell.Paragraphs)
  22051. {
  22052. lshCell.Paragraphs.Remove(item);
  22053. }
  22054. if (val.Contains("\r\n"))
  22055. {
  22056. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22057. foreach (var item in spArr)
  22058. {
  22059. //新建一个段落
  22060. Paragraph p = new Paragraph(doc);
  22061. var r = new Run(doc, item);
  22062. //设置字体
  22063. if (!string.IsNullOrEmpty(font))
  22064. {
  22065. r.Font.Name = font;
  22066. }
  22067. r.Font.Bold = bold;
  22068. //把设置的值赋给之前新建的段落
  22069. p.AppendChild(r);
  22070. //将此段落加到单元格内
  22071. lshCell.AppendChild(p);
  22072. }
  22073. }
  22074. else
  22075. {
  22076. //新建一个段落
  22077. Paragraph p = new Paragraph(doc);
  22078. var r = new Run(doc, val);
  22079. //设置字体
  22080. if (!string.IsNullOrEmpty(font))
  22081. {
  22082. r.Font.Name = font;
  22083. }
  22084. r.Font.Bold = bold;
  22085. //把设置的值赋给之前新建的段落
  22086. p.AppendChild(r);
  22087. //将此段落加到单元格内
  22088. lshCell.AppendChild(p);
  22089. }
  22090. }
  22091. /// <summary>
  22092. /// 报批行程AI续写
  22093. /// </summary>
  22094. /// <returns></returns>
  22095. [HttpPost]
  22096. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22097. {
  22098. var jw = JsonView(false);
  22099. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22100. {
  22101. jw.Msg = "参数有误!";
  22102. return Ok(jw);
  22103. }
  22104. KiMiApiClient kiMi = new KiMiApiClient();
  22105. List<SeedMessages> messages = new List<SeedMessages>() {
  22106. new SeedMessages
  22107. {
  22108. Role = KimiRole.system,
  22109. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22110. },
  22111. new SeedMessages
  22112. {
  22113. Role = KimiRole.user,
  22114. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22115. }
  22116. };
  22117. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22118. string data = kimi_result.Choices[0]?.Message.Content;
  22119. if (string.IsNullOrWhiteSpace(data))
  22120. {
  22121. jw.Data = "Ai续写失败!";
  22122. }
  22123. else
  22124. {
  22125. jw = JsonView(true, "success!", data);
  22126. }
  22127. return Ok(jw);
  22128. }
  22129. #endregion
  22130. #region 团组接待意见调查
  22131. /// <summary>
  22132. /// 团组接待意见调查 - 信息管理
  22133. /// 基础数据(团组)
  22134. /// </summary>
  22135. /// <returns></returns>
  22136. [HttpGet]
  22137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22138. public async Task<IActionResult> OpinionaireInit()
  22139. {
  22140. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22141. .Select(x => new
  22142. {
  22143. x.Id,
  22144. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22145. })
  22146. .OrderByDescending(x => x.Id)
  22147. .ToListAsync();
  22148. return Ok(JsonView(groupData, groupData.Count));
  22149. }
  22150. /// <summary>
  22151. /// 团组接待意见调查 - 信息管理
  22152. /// 列表
  22153. /// </summary>
  22154. /// <param name="groupId"></param>
  22155. /// <returns></returns>
  22156. [HttpGet("{groupId}")]
  22157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22158. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22159. {
  22160. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22161. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22162. .Select(x => new
  22163. {
  22164. x.Id,
  22165. x.TourGuideName,
  22166. x.CityName,
  22167. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22168. x.CreateTime
  22169. })
  22170. .OrderBy(x => x.Id)
  22171. .ToListAsync();
  22172. return Ok(JsonView(data));
  22173. }
  22174. /// <summary>
  22175. /// 团组接待意见调查 - 信息管理
  22176. /// 保存
  22177. /// </summary>
  22178. /// <param name="dto"></param>
  22179. /// <returns></returns>
  22180. [HttpPost]
  22181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22182. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22183. {
  22184. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22185. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22186. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22187. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22188. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22189. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22190. _opinionaireRep.BeginTran();
  22191. if (addData != null && addData.Count > 0)
  22192. {
  22193. foreach (var item in addData)
  22194. {
  22195. item.CreateUserId = currUserInfo.UserId;
  22196. item.DiId = dto.DiId;
  22197. }
  22198. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22199. }
  22200. if (updData != null && updData.Count > 0)
  22201. {
  22202. var upd = await _opinionaireRep._sqlSugar
  22203. .Updateable(updData)
  22204. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22205. .WhereColumns(x => new { x.Id })
  22206. .ExecuteCommandAsync();
  22207. }
  22208. _opinionaireRep.CommitTran();
  22209. return Ok(JsonView("操作成功!"));
  22210. }
  22211. /// <summary>
  22212. /// 团组接待意见调查 - 信息管理
  22213. /// 删除
  22214. /// </summary>
  22215. /// <param name="id"></param>
  22216. /// <returns></returns>
  22217. [HttpDelete("{id}")]
  22218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22219. public async Task<IActionResult> OpinionaireManageDel(int id)
  22220. {
  22221. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22222. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22223. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22224. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22225. if (!del) return Ok(JsonView("操作失败!"));
  22226. return Ok(JsonView("操作成功!"));
  22227. }
  22228. /// <summary>
  22229. /// 团组接待意见调查 - 用户
  22230. /// 列表
  22231. /// </summary>
  22232. /// <param name="diId"></param>
  22233. /// <returns></returns>
  22234. [HttpGet("{diId}")]
  22235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22236. public async Task<IActionResult> OpinionaireUserList(int diId)
  22237. {
  22238. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22239. var sql = string.Format(@"
  22240. SELECT
  22241. o.Id,
  22242. o.DiId,
  22243. di.TeamName AS 'GroupName',
  22244. di.VisitPNumber AS 'PeopleNumber',
  22245. di.ClientName AS 'LeadGroup',
  22246. di.VisitCountry AS 'Travel',
  22247. di.VisitDays AS 'Days',
  22248. o.CityName,
  22249. o.TourGuideName,
  22250. o.Catering,
  22251. o.CateringReason,
  22252. o.Stay,
  22253. o.StayReason,
  22254. o.[Route],
  22255. o.RouteReason,
  22256. o.OfficialActivity,
  22257. o.OfficialActivityReason,
  22258. o.TourGuide,
  22259. o.TourGuideReason,
  22260. o.[Translate],
  22261. o.TranslateReason,
  22262. o.Trip,
  22263. o.TripReason,
  22264. o.ESFileName,
  22265. o.SignatureDate,
  22266. o.Remark
  22267. FROM
  22268. Grp_Opinionaire o
  22269. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22270. WHERE
  22271. o.IsDel = 0
  22272. AND o.DiId = {0}
  22273. ORDER BY
  22274. o.Id ASC", diId);
  22275. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22276. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22277. return Ok(JsonView(data));
  22278. }
  22279. /// <summary>
  22280. /// 团组接待意见调查 - 用户
  22281. /// 保存
  22282. /// </summary>
  22283. /// <param name="dto"></param>
  22284. /// <returns></returns>
  22285. [HttpPost]
  22286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22287. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22288. {
  22289. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22290. foreach (var item in dto)
  22291. {
  22292. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22293. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22294. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22295. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22296. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22297. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22298. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22299. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22300. }
  22301. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22302. if (!Directory.Exists(filePathBase))
  22303. {
  22304. Directory.CreateDirectory(filePathBase);
  22305. }
  22306. #region 上传文件
  22307. var filePaths = new List<string>();
  22308. foreach (var item in dto)
  22309. {
  22310. var file = item.File;
  22311. // 将文件保存到指定位置
  22312. var filePath = Path.Combine(filePathBase, file.FileName);
  22313. using (var stream = new FileStream(filePath, FileMode.Create))
  22314. {
  22315. await file.CopyToAsync(stream);
  22316. }
  22317. //验证文件是否上传成功
  22318. if (!System.IO.File.Exists(filePath))
  22319. {
  22320. foreach (var filePathStr in filePaths)
  22321. {
  22322. System.IO.File.Delete(filePathStr);
  22323. }
  22324. return Ok(JsonView(false, "文件上传失败!"));
  22325. }
  22326. item.ESFileName = file.FileName;
  22327. }
  22328. #endregion
  22329. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22330. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22331. .UpdateColumns(x => new
  22332. {
  22333. x.Catering,
  22334. x.CateringReason,
  22335. x.Stay,
  22336. x.StayReason,
  22337. x.Route,
  22338. x.RouteReason,
  22339. x.OfficialActivity,
  22340. x.OfficialActivityReason,
  22341. x.TourGuide,
  22342. x.TourGuideReason,
  22343. x.Translate,
  22344. x.TranslateReason,
  22345. x.Trip,
  22346. x.TripReason,
  22347. x.ESFileName,
  22348. x.SignatureDate,
  22349. x.Remark
  22350. })
  22351. .WhereColumns(x => new { x.Id })
  22352. .ExecuteCommandAsync();
  22353. if (upd < 1)
  22354. {
  22355. foreach (var filePathStr in filePaths)
  22356. {
  22357. System.IO.File.Delete(filePathStr);
  22358. }
  22359. return Ok(JsonView(false));
  22360. }
  22361. return Ok(JsonView(true));
  22362. }
  22363. #endregion
  22364. #region 团组餐厅相关信息
  22365. /// <summary>
  22366. /// 团组相关餐厅信息
  22367. /// 基础数据(团组)
  22368. /// </summary>
  22369. /// <returns></returns>
  22370. [HttpGet]
  22371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22372. public async Task<IActionResult> RestaurantInit()
  22373. {
  22374. return Ok(await _restaurantRep.InitAsync());
  22375. }
  22376. /// <summary>
  22377. /// 团组相关餐厅信息
  22378. /// Item
  22379. /// </summary>
  22380. /// <param name="dto"></param>
  22381. /// <returns></returns>
  22382. [HttpPost]
  22383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22384. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22385. {
  22386. int portType = dto.PortType,
  22387. groupId = dto.GroupId;
  22388. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22389. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22390. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22391. }
  22392. /// <summary>
  22393. /// 团组相关餐厅信息
  22394. /// List
  22395. /// </summary>
  22396. /// <param name="dto"></param>
  22397. /// <returns></returns>
  22398. [HttpPost]
  22399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22400. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22401. {
  22402. int portType = dto.PortType,
  22403. groupId = dto.GroupId;
  22404. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22405. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22406. var sql = string.Format(@" SELECT
  22407. ri.Id,
  22408. ri.GroupId,
  22409. ri.Date,
  22410. ri.StartTime,
  22411. ri.EndTime,
  22412. CASE WHEN ri.Type = 1 THEN '早餐'
  22413. WHEN ri.Type = 2 THEN '午餐'
  22414. WHEN ri.Type = 3 THEN '晚餐'
  22415. ELSE '其他'
  22416. END AS 'Type',
  22417. ri.Name,
  22418. ri.Address,
  22419. ri.Tel,
  22420. ri.Remark,
  22421. ri.CreateTime,
  22422. u.CnName AS CreateUserName
  22423. FROM
  22424. Grp_RestaurantInfo ri
  22425. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22426. WHERE
  22427. ri.IsDel = 0
  22428. AND ri.GroupId = {0}
  22429. ORDER BY
  22430. ri.Date ASC
  22431. ", groupId);
  22432. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22433. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22434. return Ok(JsonView(infos));
  22435. }
  22436. /// <summary>
  22437. /// 团组相关餐厅信息
  22438. /// Info
  22439. /// </summary>
  22440. /// <param name="dto"></param>
  22441. /// <returns></returns>
  22442. [HttpPost]
  22443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22444. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22445. {
  22446. int portType = dto.PortType,
  22447. id = dto.Id;
  22448. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22449. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22450. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22451. }
  22452. /// <summary>
  22453. /// 团组相关餐厅信息
  22454. /// Op
  22455. /// </summary>
  22456. /// <param name="dto"></param>
  22457. /// <returns></returns>
  22458. [HttpPost]
  22459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22460. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22461. {
  22462. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22463. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22464. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22465. return Ok(await _restaurantRep.OpAsync(dto));
  22466. }
  22467. /// <summary>
  22468. /// 团组相关餐厅信息
  22469. /// Del
  22470. /// </summary>
  22471. /// <param name="dto"></param>
  22472. /// <returns></returns>
  22473. [HttpPost]
  22474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22475. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22476. {
  22477. int userId = dto.DeleteUserId;
  22478. var id = dto.Id;
  22479. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22480. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22481. return Ok(await _restaurantRep.DelAsync(dto));
  22482. }
  22483. #endregion
  22484. /// <summary>
  22485. /// 123132123
  22486. /// </summary>
  22487. /// <param name="_dto"></param>
  22488. /// <returns></returns>
  22489. [HttpPost]
  22490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22491. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22492. {
  22493. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22494. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22495. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22496. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22497. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22498. dicDetail.Add(789, 1034);
  22499. dicDetail.Add(790, 1035);
  22500. dicDetail.Add(791, 1036);
  22501. dicDetail.Add(792, 1037);
  22502. dicDetail.Add(793, 1038);
  22503. dicDetail.Add(794, 1039);
  22504. dicDetail.Add(795, 1040);
  22505. dicDetail.Add(796, 1041);
  22506. dicDetail.Add(797, 1042);
  22507. dicDetail.Add(798, 1043);
  22508. dicDetail.Add(801, 1044);
  22509. dicDetail.Add(802, 1045);
  22510. dicDetail.Add(803, 1046);
  22511. Dictionary<int, int> dic = new Dictionary<int, int>();
  22512. dic.Add(806, 1027);
  22513. dic.Add(807, 1028);
  22514. dic.Add(808, 1029);
  22515. dic.Add(809, 1030);
  22516. dic.Add(810, 1031);
  22517. dic.Add(811, 1032);
  22518. dic.Add(812, 1033);
  22519. foreach (var item in list_visa)
  22520. {
  22521. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22522. temp.Coefficient = item.coefficient;
  22523. DateTime dtCrt;
  22524. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22525. if (b1)
  22526. {
  22527. temp.CreateTime = dtCrt;
  22528. }
  22529. else
  22530. {
  22531. temp.CreateTime = DateTime.Now;
  22532. }
  22533. temp.CreateUserId = item.Operators;
  22534. temp.DeleteTime = "";
  22535. temp.DeleteUserId = 0;
  22536. temp.DiId = int.Parse(item.DIID);
  22537. temp.FilePath = item.FilePath;
  22538. temp.IsDel = item.IsDel;
  22539. temp.Price = item.Price;
  22540. temp.PriceCount = 1;
  22541. temp.PriceCurrency = item.Currency;
  22542. int detailId = 0;
  22543. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22544. {
  22545. detailId = dicDetail[item.PriceTypeDetail];
  22546. }
  22547. temp.PriceDetailType = detailId;
  22548. temp.PriceDt = DateTime.Now;
  22549. temp.PriceName = item.PriceName;
  22550. temp.PriceSum = item.Price;
  22551. int tid = 0;
  22552. if (dic.ContainsKey(item.PriceType))
  22553. {
  22554. tid = dic[item.PriceType];
  22555. }
  22556. temp.PriceType = tid;
  22557. temp.Remark = item.Remark;
  22558. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22559. }
  22560. return Ok(JsonView(true, "操作成功!"));
  22561. }
  22562. [HttpPost]
  22563. public IActionResult TimeTest()
  22564. {
  22565. var jw = JsonView(false, "error");
  22566. _sqlSugar.BeginTran();
  22567. try
  22568. {
  22569. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22570. .Select(x => new Crm_NewClientData
  22571. {
  22572. Id = x.Id,
  22573. Client = x.Client,
  22574. Contact = x.Contact,
  22575. Location = x.Location,
  22576. })
  22577. .ToList();
  22578. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22579. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22580. Stopwatch stopwatch = new Stopwatch();
  22581. // 开始计时
  22582. stopwatch.Start();
  22583. foreach (var item in clientList)
  22584. {
  22585. EncryptionProcessor.DecryptProperties(item);
  22586. }
  22587. stopwatch.Stop();
  22588. jw.Code = 200;
  22589. jw.Data = stopwatch.ElapsedMilliseconds;
  22590. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22591. }
  22592. catch (Exception ex)
  22593. {
  22594. jw.Code = 400;
  22595. jw.Msg = ex.Message;
  22596. }
  22597. return Ok(jw);
  22598. }
  22599. }
  22600. }