GroupsController.cs 608 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. using static Pipelines.Sockets.Unofficial.SocketConnection;
  90. using System.Diagnostics.PerformanceData;
  91. using System.Drawing.Printing;
  92. namespace OASystem.API.Controllers
  93. {
  94. /// <summary>
  95. /// 团组相关
  96. /// </summary>
  97. //[Authorize]
  98. [Route("api/[controller]/[action]")]
  99. public class GroupsController : ControllerBase
  100. {
  101. private readonly GrpScheduleRepository _grpScheduleRep;
  102. private readonly IMapper _mapper;
  103. private readonly DelegationInfoRepository _groupRepository;
  104. private readonly TaskAssignmentRepository _taskAssignmentRep;
  105. private readonly AirTicketResRepository _airTicketResRep;
  106. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  107. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  108. private readonly DelegationEnDataRepository _delegationEnDataRep;
  109. private readonly DelegationVisaRepository _delegationVisaRep;
  110. private readonly VisaPriceRepository _visaPriceRep;
  111. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  112. private readonly HotelPriceRepository _hotelPriceRep;
  113. private readonly CustomersRepository _customersRep;
  114. private readonly MessageRepository _message;
  115. private readonly SqlSugarClient _sqlSugar;
  116. private readonly TourClientListRepository _tourClientListRep;
  117. private readonly TeamRateRepository _teamRateRep;
  118. #region 成本相关
  119. private readonly CheckBoxsRepository _checkBoxs;
  120. private readonly GroupCostRepository _GroupCostRepository;
  121. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  122. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  123. #endregion
  124. private readonly SetDataRepository _setDataRep;
  125. private string url;
  126. private string path;
  127. private readonly EnterExitCostRepository _enterExitCostRep;
  128. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  129. private readonly UsersRepository _usersRep;
  130. private readonly IJuHeApiService _juHeApi;
  131. private readonly InvertedListRepository _invertedListRep;
  132. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  133. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  134. private readonly ThreeCodeRepository _threeCodeRepository;
  135. private readonly HotelInquiryRepository _hotelInquiryRep;
  136. private readonly FeeAuditRepository _feeAuditRep;
  137. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  138. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  139. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  140. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  141. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  142. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  143. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  144. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  145. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  146. {
  147. _mapper = mapper;
  148. _grpScheduleRep = grpScheduleRep;
  149. _groupRepository = groupRepository;
  150. _taskAssignmentRep = taskAssignmentRep;
  151. _airTicketResRep = airTicketResRep;
  152. _sqlSugar = sqlSugar;
  153. url = AppSettingsHelper.Get("ExcelBaseUrl");
  154. path = AppSettingsHelper.Get("ExcelBasePath");
  155. if (!System.IO.Directory.Exists(path))
  156. {
  157. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  158. }
  159. _decreasePaymentsRep = decreasePaymentsRep;
  160. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  161. _delegationEnDataRep = delegationEnDataRep;
  162. _enterExitCostRep = enterExitCostRep;
  163. _delegationVisaRep = delegationVisaRep;
  164. _message = message;
  165. _visaPriceRep = visaPriceRep;
  166. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  167. _checkBoxs = checkBoxs;
  168. _GroupCostRepository = GroupCostRepository;
  169. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  170. _GroupCostParameterRepository = GroupCostParameterRepository;
  171. _hotelPriceRep = hotelPriceRep;
  172. _customersRep = customersRep;
  173. _setDataRep = setDataRep;
  174. _tourClientListRep = tourClientListRep;
  175. _teamRateRep = teamRateRep;
  176. _hubContext = hubContext;
  177. _usersRep = usersRep;
  178. _juHeApi = juHeApi;
  179. _invertedListRep = invertedListRep;
  180. _visaFeeInfoRep = visaFeeInfoRep;
  181. _ticketBlackCodeRep = ticketBlackCodeRep;
  182. _hotelInquiryRep = hotelInquiryRep;
  183. _threeCodeRepository = threeCodeRepository;
  184. _feeAuditRep = feeAuditRep;
  185. }
  186. #region 流程管控
  187. /// <summary>
  188. /// 获取团组流程管控信息
  189. /// </summary>
  190. /// <param name="paras">参数Json字符串</param>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  195. {
  196. if (string.IsNullOrEmpty(_jsonDto.Paras))
  197. {
  198. return Ok(JsonView(false, "参数为空"));
  199. }
  200. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  201. if (_ScheduleDto != null)
  202. {
  203. if (_ScheduleDto.SearchType == 2)//获取列表
  204. {
  205. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  206. return Ok(JsonView(_grpScheduleViewList));
  207. }
  208. else//获取对象
  209. {
  210. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  211. if (_grpScheduleView != null)
  212. {
  213. return Ok(JsonView(_grpScheduleView));
  214. }
  215. }
  216. }
  217. else
  218. {
  219. return Ok(JsonView(false, "参数反序列化失败"));
  220. }
  221. return Ok(JsonView(false, "暂无数据!"));
  222. }
  223. /// <summary>
  224. /// 修改团组流程管控详细表数据
  225. /// </summary>
  226. /// <param name="paras"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  230. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  231. {
  232. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  233. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  234. .SetColumns(it => it.Duty == _detail.Duty)
  235. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  236. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  237. .SetColumns(it => it.JobContent == _detail.JobContent)
  238. .SetColumns(it => it.Remark == _detail.Remark)
  239. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  240. .Where(s => s.Id == dto.Id)
  241. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  242. .ExecuteCommandAsync();
  243. if (result > 0)
  244. {
  245. return Ok(JsonView(true, "保存成功!"));
  246. }
  247. return Ok(JsonView(false, "保存失败!"));
  248. }
  249. /// <summary>
  250. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  257. {
  258. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  259. _detail.IsDel = 1;
  260. _detail.DeleteUserId = dto.Duty;
  261. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  262. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  263. .SetColumns(it => it.IsDel == _detail.IsDel)
  264. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  265. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  266. .Where(it => it.Id == dto.Id)
  267. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  268. //.WhereColumns(s => s.Id == dto.Id)
  269. .ExecuteCommandAsync();
  270. if (result > 0)
  271. {
  272. return Ok(JsonView(true, "删除成功!"));
  273. }
  274. return Ok(JsonView(false, "删除失败!"));
  275. }
  276. /// <summary>
  277. /// 增加团组流程管控详细表数据
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  284. {
  285. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  286. if (DateTime.Now < _detail.ExpectBeginDt)
  287. {
  288. _detail.StepStatus = 0;
  289. }
  290. else
  291. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  292. _detail.StepStatus = 1;
  293. }
  294. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  295. if (result > 0)
  296. {
  297. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  298. return Ok(JsonView(true, "添加成功!", _result));
  299. }
  300. return Ok(JsonView(false, "添加失败!"));
  301. }
  302. #endregion
  303. #region 团组基本信息
  304. /// <summary>
  305. /// 接团信息列表
  306. /// </summary>
  307. /// <param name="dto">团组列表请求dto</param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  312. {
  313. var groupData = await _groupRepository.GetGroupList(dto);
  314. if (groupData.Code != 0)
  315. {
  316. return Ok(JsonView(false, groupData.Msg));
  317. }
  318. return Ok(JsonView(groupData.Data));
  319. }
  320. /// <summary>
  321. /// 接团信息列表 Page
  322. /// </summary>
  323. /// <param name="dto">团组列表请求dto</param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  328. {
  329. #region 参数验证
  330. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  331. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  333. #region 页面操作权限验证
  334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  335. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  336. #endregion
  337. #endregion
  338. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  339. {
  340. string sqlWhere = string.Empty;
  341. if (dto.IsSure == 0) //未完成
  342. {
  343. sqlWhere += string.Format(@" And IsSure = 0");
  344. }
  345. else if (dto.IsSure == 1) //已完成
  346. {
  347. sqlWhere += string.Format(@" And IsSure = 1");
  348. }
  349. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  350. {
  351. string tj = dto.SearchCriteria;
  352. 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}%')",
  353. tj, tj, tj, tj, tj);
  354. }
  355. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  356. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  357. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  358. JietuanOperator,IsSure,CreateTime
  359. From (
  360. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  361. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  362. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  363. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  364. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  365. From Grp_DelegationInfo gdi
  366. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  367. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  368. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  369. Where gdi.IsDel = 0 {0}
  370. ) temp", sqlWhere);
  371. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  372. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  373. #region 处理所属部门
  374. /*
  375. * 1.sq 和 gyy 等显示 市场部
  376. * 2.王鸽和主管及张总还有管理员号统一国交部
  377. * 2-1. 4 管理员 ,21 张海麟
  378. */
  379. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  380. List<int> userIds1 = new List<int>() { 4, 21 };
  381. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  382. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  383. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  384. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  385. .ToList();
  386. foreach (var item in _DelegationList)
  387. {
  388. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  389. }
  390. #endregion
  391. var _view = new
  392. {
  393. PageFuncAuth = pageFunAuthView,
  394. Data = _DelegationList
  395. };
  396. return Ok(JsonView(true, "查询成功!", _view, total));
  397. }
  398. else
  399. {
  400. return Ok(JsonView(false, "查询失败"));
  401. }
  402. }
  403. /// <summary>
  404. /// 团组列表
  405. /// </summary>
  406. /// <returns></returns>
  407. [HttpPost]
  408. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  409. {
  410. #region 参数验证
  411. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  412. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  413. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  414. #region 页面操作权限验证
  415. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  416. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  417. #endregion
  418. #endregion
  419. if (dto.PortType != 1 && dto.PortType != 2)
  420. {
  421. return Ok(JsonView(false, "查询失败!"));
  422. }
  423. string orderbyStr = "order by gdi.CreateTime Desc";
  424. string sqlWhere = string.Empty;
  425. if (dto.IsSure == 0) //未完成
  426. {
  427. sqlWhere += string.Format(@" And IsSure = 0");
  428. }
  429. else if (dto.IsSure == 1) //已完成
  430. {
  431. sqlWhere += string.Format(@" And IsSure = 1");
  432. }
  433. //团组类型
  434. if (dto.TeamDid > 0)
  435. {
  436. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  437. }
  438. //团组名称
  439. if (!string.IsNullOrEmpty(dto.TeamName))
  440. {
  441. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  442. }
  443. //客户名称
  444. if (!string.IsNullOrEmpty(dto.ClientName))
  445. {
  446. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  447. }
  448. //客户单位
  449. if (!string.IsNullOrEmpty(dto.ClientUnit))
  450. {
  451. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  452. }
  453. //出访时间
  454. if (!string.IsNullOrEmpty(dto.visitDataTime))
  455. {
  456. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  457. orderbyStr = "order by gdi.VisitDate";
  458. }
  459. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  460. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  461. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  462. JietuanOperator,IsSure,CreateTime
  463. From (
  464. Select row_number() over({0}) as Row_Number,
  465. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  466. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  467. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  468. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  469. From Grp_DelegationInfo gdi
  470. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  471. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  472. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  473. Where gdi.IsDel = 0 {1}
  474. ) temp ", orderbyStr, sqlWhere);
  475. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  476. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  477. #region 处理所属部门
  478. /*
  479. * 1.sq 和 gyy 等显示 市场部
  480. * 2.王鸽和主管及张总还有管理员号统一国交部
  481. * 2-1. 4 管理员 ,21 张海麟
  482. */
  483. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  484. List<int> userIds1 = new List<int>() { 4, 21 };
  485. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  486. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  487. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  488. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  489. .ToList();
  490. foreach (var item in _DelegationList)
  491. {
  492. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  493. }
  494. #endregion
  495. var _view = new
  496. {
  497. PageFuncAuth = pageFunAuthView,
  498. Data = _DelegationList
  499. };
  500. return Ok(JsonView(true, "查询成功!", _view, total));
  501. }
  502. /// <summary>
  503. /// 接团信息详情
  504. /// </summary>
  505. /// <param name="dto">团组info请求dto</param>
  506. /// <returns></returns>
  507. [HttpPost]
  508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  509. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  510. {
  511. var groupData = await _groupRepository.GetGroupInfo(dto);
  512. if (groupData.Code != 0)
  513. {
  514. return Ok(JsonView(false, groupData.Msg));
  515. }
  516. return Ok(JsonView(groupData.Data));
  517. }
  518. /// <summary>
  519. /// 接团信息 编辑添加
  520. /// 基础信息数据源
  521. /// </summary>
  522. /// <param name="dto"></param>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  527. {
  528. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  529. if (groupData.Code != 0)
  530. {
  531. return Ok(JsonView(false, groupData.Msg));
  532. }
  533. return Ok(JsonView(groupData.Data));
  534. }
  535. /// <summary>
  536. /// 接团信息 操作(增改)
  537. /// </summary>
  538. /// <param name="dto"></param>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  543. {
  544. try
  545. {
  546. var groupData = await _groupRepository.GroupOperation(dto);
  547. if (groupData.Code != 0)
  548. {
  549. return Ok(JsonView(false, groupData.Msg));
  550. }
  551. int diId = 0;
  552. //添加时 默认加入团组汇率
  553. if (dto.Status == 1) //添加
  554. {
  555. diId = groupData.Data;
  556. //添加默认币种
  557. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  558. //默认分配权限
  559. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  560. //消息提示 王鸽 主管号
  561. List<int> _managerIds = new List<int>() { 22, 32 };
  562. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  563. if (userIds.Count > 0)
  564. {
  565. userIds.Add(208);
  566. //创建团组管控
  567. GroupStepForDelegation.CreateWorkStep(diId);
  568. //发送消息
  569. string groupName = dto.TeamName;
  570. string createGroupUser = string.Empty;
  571. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  572. if (userInfo != null) createGroupUser = userInfo.CnName;
  573. string title = $"系统通知";
  574. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  575. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  576. }
  577. //默认创建倒推表
  578. await _invertedListRep._Create(dto.UserId, diId);
  579. }
  580. else if (dto.Status == 2)
  581. {
  582. diId = dto.Id;
  583. }
  584. return Ok(JsonView(true, "操作成功!", diId));
  585. }
  586. catch (Exception ex)
  587. {
  588. Logs("[response]" + JsonConvert.SerializeObject(dto));
  589. Logs(ex.Message);
  590. return Ok(JsonView(false, ex.Message));
  591. }
  592. }
  593. /// <summary>
  594. /// 接团流程操作(增改)
  595. /// 安卓端使用 建团时添加客户名单
  596. /// </summary>
  597. /// <param name="dto"></param>
  598. /// <returns></returns>
  599. [HttpPost]
  600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  601. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  602. {
  603. try
  604. {
  605. #region 参数验证
  606. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  608. #region 页面操作权限验证
  609. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  610. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  611. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  612. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  613. #endregion
  614. #endregion
  615. _sqlSugar.BeginTran();
  616. var _dto = new GroupOperationDto();
  617. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  618. var groupData = await _groupRepository.GroupOperation(_dto);
  619. if (groupData.Code != 0)
  620. {
  621. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  622. }
  623. int diId = 0;
  624. //添加时 默认加入团组汇率
  625. if (dto.Status == 1) //添加
  626. {
  627. diId = groupData.Data;
  628. //添加默认币种
  629. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  630. //默认分配权限
  631. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  632. //消息提示 王鸽 主管号
  633. List<int> _managerIds = new List<int>() { 22, 32 };
  634. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  635. if (userIds.Count > 0)
  636. {
  637. userIds.Add(208);
  638. //创建团组管控
  639. GroupStepForDelegation.CreateWorkStep(diId);
  640. //发送消息
  641. string groupName = dto.TeamName;
  642. string createGroupUser = string.Empty;
  643. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  644. if (userInfo != null) createGroupUser = userInfo.CnName;
  645. string title = $"系统通知";
  646. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  647. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  648. }
  649. }
  650. if (dto.Status == 2)
  651. {
  652. diId = dto.Id;
  653. if (diId == 0)
  654. {
  655. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  656. }
  657. }
  658. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  659. if (viewData.Code != 0)
  660. {
  661. _sqlSugar.RollbackTran();
  662. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  663. }
  664. _sqlSugar.CommitTran();
  665. return Ok(JsonView(true, "添加成功"));
  666. }
  667. catch (Exception ex)
  668. {
  669. _sqlSugar.RollbackTran();
  670. return Ok(JsonView(false, ex.Message));
  671. }
  672. }
  673. /// <summary>
  674. /// 接团信息 操作(删除)
  675. /// </summary>
  676. /// <param name="dto"></param>
  677. /// <returns></returns>
  678. [HttpPost]
  679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  680. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  681. {
  682. try
  683. {
  684. var groupData = await _groupRepository.GroupDel(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(true));
  690. }
  691. catch (Exception ex)
  692. {
  693. Logs("[response]" + JsonConvert.SerializeObject(dto));
  694. Logs(ex.Message);
  695. return Ok(JsonView(false, ex.Message));
  696. }
  697. }
  698. /// <summary>
  699. /// 获取团组销售报价号
  700. /// 团组添加时 使用
  701. /// </summary>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupSalesQuoteNo()
  706. {
  707. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. object salesQuoteNo = new
  713. {
  714. SalesQuoteNo = groupData.Data
  715. };
  716. return Ok(JsonView(salesQuoteNo));
  717. }
  718. /// <summary>
  719. /// 设置确认出团
  720. /// </summary>
  721. /// <param name="dto"></param>
  722. /// <returns></returns>
  723. [HttpPost]
  724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  725. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  726. {
  727. var groupData = await _groupRepository.ConfirmationGroup(dto);
  728. if (groupData.Code != 0)
  729. {
  730. return Ok(JsonView(false, groupData.Msg));
  731. }
  732. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  733. #region OA消息推送
  734. try
  735. {
  736. string groupName = groupInfo.TeamName;
  737. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  738. List<int> userIds = new List<int>();
  739. listUser.ForEach(s => userIds.Add(s.Id));
  740. string title = $"系统通知";
  741. string content = $"团组[{groupName}]已确认出团!";
  742. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  743. }
  744. catch (Exception ex)
  745. {
  746. }
  747. #endregion
  748. #region 应用推送
  749. try
  750. {
  751. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  752. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  753. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  754. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  755. {
  756. List<string> userList = new List<string>() { users.QiyeChatUserId };
  757. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  758. }
  759. }
  760. catch (Exception ex)
  761. {
  762. }
  763. #endregion
  764. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  765. return Ok(JsonView(true, "操作成功!", groupData.Data));
  766. }
  767. /// <summary>
  768. /// 获取团组名称data And 签证国别Data
  769. /// </summary>
  770. /// <param name="dto"></param>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  775. {
  776. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  777. if (groupData.Code != 0)
  778. {
  779. return Ok(JsonView(false, groupData.Msg));
  780. }
  781. return Ok(JsonView(groupData.Data));
  782. }
  783. /// <summary>
  784. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  785. /// </summary>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  790. {
  791. try
  792. {
  793. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  794. if (groupData.Code != 0)
  795. {
  796. return Ok(JsonView(false, groupData.Msg));
  797. }
  798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  799. }
  800. catch (Exception ex)
  801. {
  802. return Ok(JsonView(false, "程序错误!"));
  803. throw;
  804. }
  805. }
  806. #endregion
  807. #region 团组&签证
  808. /// <summary>
  809. /// 根据团组Id获取签证客户信息List
  810. /// </summary>
  811. /// <param name="dto">请求dto</param>
  812. /// <returns></returns>
  813. [HttpPost]
  814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  815. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  816. {
  817. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  818. if (groupData.Code != 0)
  819. {
  820. return Ok(JsonView(false, groupData.Msg));
  821. }
  822. return Ok(JsonView(groupData.Data));
  823. }
  824. /// <summary>
  825. /// IOS获取团组签证拍照上传进度01(团组列表)
  826. /// </summary>
  827. /// <param name="dto">请求dto</param>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  832. {
  833. if (dto == null)
  834. {
  835. return Ok(JsonView(false, "参数为空"));
  836. }
  837. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  838. return Ok(JsonView(visaList));
  839. }
  840. /// <summary>
  841. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  842. /// </summary>
  843. /// <returns></returns>
  844. [HttpPost]
  845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  846. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  847. {
  848. if (dto == null)
  849. {
  850. return Ok(JsonView(false, "请求错误:"));
  851. }
  852. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  853. return Ok(JsonView(list));
  854. }
  855. /// <summary>
  856. /// IOS获取团组签证拍照上传进度03(相册)
  857. /// </summary>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  862. {
  863. if (dto == null)
  864. {
  865. return Ok(JsonView(false, "请求错误:"));
  866. }
  867. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  868. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  869. list.ForEach(s => s.url = url);
  870. return Ok(JsonView(list));
  871. }
  872. /// <summary>
  873. /// IOS获取团组签证拍照上传进度04(图片上传)
  874. /// </summary>
  875. /// <param name="dto"></param>
  876. /// <returns></returns>
  877. [HttpPost]
  878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  879. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  880. {
  881. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  882. //if (!string.IsNullOrEmpty(result))
  883. //{
  884. //}
  885. //else {
  886. // return Ok(JsonView(false, "上传失败"));
  887. //}
  888. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  889. int sucNum = 0;
  890. try
  891. {
  892. foreach (var item in dto.base64DataList)
  893. {
  894. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  895. string result = decodeBase64ToImage(item, imageName);
  896. if (!string.IsNullOrEmpty(result))
  897. {
  898. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  899. pic.CreateUserId = dto.CreateUserId;
  900. pic.PicName = imageName;
  901. pic.PicPath = result;
  902. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  903. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  904. if (insertResult > 0)
  905. {
  906. sucNum++;
  907. }
  908. }
  909. }
  910. }
  911. catch (Exception ex)
  912. {
  913. return Ok(JsonView(false, ex.Message));
  914. }
  915. string msg = string.Format(@"成功上传{0}张", sucNum);
  916. return Ok(JsonView(true, msg));
  917. }
  918. private string decodeBase64ToImage(string base64DataURL, string imgName)
  919. {
  920. string filename = "";//声明一个string类型的相对路径
  921. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  922. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  923. try//会有异常抛出,try,catch一下
  924. {
  925. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  926. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  927. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  928. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  929. //文件名称
  930. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  931. //上传的文件的路径
  932. string filePath = "";
  933. if (!Directory.Exists(fileDir))
  934. {
  935. Directory.CreateDirectory(fileDir);
  936. }
  937. //上传的文件的路径
  938. filePath = fileDir + filename;
  939. //string url = HttpRuntime.AppDomainAppPath.ToString();
  940. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  941. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  942. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  943. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  944. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  945. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  946. ms.Close();//关闭当前流,并释放所有与之关联的资源
  947. bitmap.Dispose();
  948. }
  949. catch (Exception e)
  950. {
  951. string massage = e.Message;
  952. Logs("IOS图片上传Error:" + massage);
  953. //filename = e.Message;
  954. }
  955. return filename;//返回相对路径
  956. }
  957. /// <summary>
  958. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  965. {
  966. if (dto == null)
  967. {
  968. return Ok(JsonView(false, "请求错误:"));
  969. }
  970. string msg = "参数错误";
  971. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  972. {
  973. try
  974. {
  975. //_delegationVisaRep.BeginTran();
  976. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  977. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  978. .Where(s => s.Id == dto.visaProgressCustomerId)
  979. .ExecuteCommandAsync();
  980. if (updCount > 0 && dto.publishCode == 1)
  981. {
  982. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  983. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  984. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  985. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  986. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  987. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  988. if (groupData == null)
  989. {
  990. _delegationVisaRep.RollbackTran();
  991. }
  992. string title = string.Format(@"[签证进度更新]");
  993. string content = string.Format(@"测试文本");
  994. bool rst = await _message.AddMsg(new MessageDto()
  995. {
  996. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  997. IssuerId = dto.publisher,
  998. Title = title,
  999. Content = content,
  1000. ReleaseTime = DateTime.Now,
  1001. UIdList = new List<int> {
  1002. 234
  1003. }
  1004. });
  1005. if (rst)
  1006. {
  1007. return Ok(JsonView(true, "发送通知成功"));
  1008. }
  1009. }
  1010. //_delegationVisaRep.CommitTran();
  1011. }
  1012. catch (Exception)
  1013. {
  1014. //_delegationVisaRep.RollbackTran();
  1015. }
  1016. }
  1017. return Ok(JsonView(true, msg));
  1018. }
  1019. #endregion
  1020. #region 团组任务分配
  1021. /// <summary>
  1022. /// 团组任务分配初始化
  1023. /// </summary>
  1024. /// <param name="dto"></param>
  1025. /// <returns></returns>
  1026. [HttpPost]
  1027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1028. public async Task<IActionResult> GetTaskAssignmen()
  1029. {
  1030. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1031. if (groupData.Code != 0)
  1032. {
  1033. return Ok(JsonView(false, groupData.Msg));
  1034. }
  1035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1036. }
  1037. /// <summary>
  1038. /// 团组任务分配查询
  1039. /// </summary>
  1040. /// <param name="dto"></param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1045. {
  1046. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1047. if (groupData.Code != 0)
  1048. {
  1049. return Ok(JsonView(false, groupData.Msg));
  1050. }
  1051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1052. }
  1053. /// <summary>
  1054. /// 团组任务分配操作
  1055. /// </summary>
  1056. /// <param name="dto"></param>
  1057. /// <returns></returns>
  1058. [HttpPost]
  1059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1060. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1061. {
  1062. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1063. if (groupData.Code != 0)
  1064. {
  1065. return Ok(JsonView(false, groupData.Msg));
  1066. }
  1067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1068. }
  1069. #endregion
  1070. #region 团组费用审核
  1071. /// <summary>
  1072. /// 费用审核
  1073. /// 团组列表 Page
  1074. /// </summary>
  1075. /// <param name="_dto">团组列表请求dto</param>
  1076. /// <returns></returns>
  1077. [HttpPost]
  1078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1079. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1080. {
  1081. #region 参数验证
  1082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1083. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1084. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1085. #region 页面操作权限验证
  1086. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1087. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1088. #endregion
  1089. #endregion
  1090. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1091. {
  1092. string sqlWhere = string.Empty;
  1093. if (_dto.IsSure == 0) //未完成
  1094. {
  1095. sqlWhere += string.Format(@" And IsSure = 0");
  1096. }
  1097. else if (_dto.IsSure == 1) //已完成
  1098. {
  1099. sqlWhere += string.Format(@" And IsSure = 1");
  1100. }
  1101. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1102. {
  1103. string tj = _dto.SearchCriteria;
  1104. 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}%')",
  1105. tj, tj, tj, tj, tj);
  1106. }
  1107. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1108. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1109. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1110. From (
  1111. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1112. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1113. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1114. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1115. From Grp_DelegationInfo gdi
  1116. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1117. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1118. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1119. Where gdi.IsDel = 0 {0}
  1120. ) temp ", sqlWhere);
  1121. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1122. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1123. var _view = new
  1124. {
  1125. PageFuncAuth = pageFunAuthView,
  1126. Data = _DelegationList
  1127. };
  1128. return Ok(JsonView(true, "查询成功!", _view, total));
  1129. }
  1130. else
  1131. {
  1132. return Ok(JsonView(false, "查询失败"));
  1133. }
  1134. }
  1135. /// <summary>
  1136. /// 获取团组费用审核
  1137. /// </summary>
  1138. /// <param name="paras">参数Json字符串</param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1143. {
  1144. try
  1145. {
  1146. #region 参数验证
  1147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1148. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1154. #endregion
  1155. #endregion
  1156. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1157. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1158. #region 费用清单
  1159. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1160. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1161. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1162. List<Grp_CreditCardPayment> entityList = _groupRepository
  1163. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1164. .Where(exp.ToExpression())
  1165. .ToList();
  1166. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1167. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1168. /*
  1169. * 76://酒店预订
  1170. */
  1171. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1172. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1175. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. /*
  1178. * 79://车/导游地接
  1179. */
  1180. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1181. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1182. .ToListAsync();
  1183. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. * 80: //签证
  1188. */
  1189. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1190. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. *81: //邀请/公务活动
  1194. */
  1195. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1196. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1197. .ToListAsync();
  1198. /*
  1199. * 82: //团组客户保险
  1200. */
  1201. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1202. /*
  1203. * Lable = 85 机票预订
  1204. */
  1205. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1206. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1207. .ToListAsync();
  1208. /*
  1209. * 85 机票预定
  1210. */
  1211. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1212. /*
  1213. * 98 其他款项
  1214. */
  1215. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1216. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 285:收款退还
  1220. */
  1221. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1222. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1223. .ToListAsync();
  1224. /*
  1225. * 1015: //超支费用
  1226. */
  1227. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 币种信息
  1230. */
  1231. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1232. /*
  1233. * 车/导游地接 费用类型
  1234. */
  1235. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 车/导游地接 费用类型
  1238. */
  1239. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1240. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1241. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1242. /*
  1243. * 用户信息
  1244. */
  1245. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1246. /*
  1247. * 费用模块
  1248. */
  1249. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1250. string priceModule = string.Empty;
  1251. if (sdPriceName != null)
  1252. {
  1253. priceModule = sdPriceName.Name;
  1254. }
  1255. /*
  1256. * 成本信息
  1257. */
  1258. var groupCost = _groupRepository.Query<Grp_GroupCostParameter >(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1259. decimal _groupRate = 0.0000M;
  1260. string _groupCurrencyCode = "-";
  1261. if (groupCost != null)
  1262. {
  1263. _groupRate = groupCost.Rate;
  1264. if (int.TryParse(groupCost.Currency, out int _currency))
  1265. {
  1266. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1267. }
  1268. }
  1269. string costContentSql = $"Select * From Grp_GroupCost";
  1270. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1271. //处理日期为空的天数
  1272. for (int i = 0; i < groupCostDetails.Count; i++)
  1273. if (i != 0)
  1274. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1275. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1276. /*
  1277. * 处理详情数据
  1278. */
  1279. foreach (var entity in entityList)
  1280. {
  1281. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1282. _detail.Id = entity.Id;
  1283. _detail.PriceName = priceModule;
  1284. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1285. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1286. /*
  1287. * 应付款金额
  1288. */
  1289. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1290. string PaymentCurrency_WaitPay = "Unknown";
  1291. string hotelCurrncyCode = "Unknown";
  1292. string hotelCurrncyName = "Unknown";
  1293. if (sdPaymentCurrency_WaitPay != null)
  1294. {
  1295. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1296. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1297. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1298. if (hotelCurrncyCode.Equals("CNY"))
  1299. {
  1300. entity.DayRate = 1.0000M;
  1301. }
  1302. }
  1303. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1304. /*
  1305. * 此次付款金额
  1306. */
  1307. decimal CurrPayStr = 0;
  1308. if (entity.PayPercentage == 0)
  1309. {
  1310. if (entity.PayThenMoney != 0)
  1311. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1312. }
  1313. else
  1314. {
  1315. if (entity.PayMoney != 0)
  1316. {
  1317. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1318. }
  1319. }
  1320. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1321. /*
  1322. * 剩余尾款
  1323. */
  1324. decimal BalanceStr = 0;
  1325. if (CurrPayStr != 0)
  1326. {
  1327. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1328. BalanceStr = 0;
  1329. else
  1330. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1331. }
  1332. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1333. /*
  1334. * Bus名称
  1335. */
  1336. _detail.BusName = "待增加";
  1337. /*
  1338. *费用所属
  1339. */
  1340. switch (entity.CTable)
  1341. {
  1342. case 76://酒店预订
  1343. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1344. if (hotelReservations != null)
  1345. {
  1346. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1347. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1348. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1349. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1350. /*
  1351. * 费用类型
  1352. * 1:房费
  1353. * 2:早餐
  1354. * 3:地税
  1355. * 4:城市税
  1356. * </summary>
  1357. */
  1358. //地税
  1359. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1360. if (governmentRentData != null)
  1361. {
  1362. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1363. governmentRentFee = governmentRentData.Price;
  1364. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1365. if (governmentRentCurrData != null)
  1366. {
  1367. governmentRentCode = governmentRentCurrData.Name;
  1368. governmentRentName = $"({governmentRentCurrData.Remark})";
  1369. }
  1370. }
  1371. //城市税
  1372. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1373. if (cityTaxData != null)
  1374. {
  1375. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1376. cityTaxFee = cityTaxData.Price;
  1377. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1378. if (cityTaxCurrData != null)
  1379. {
  1380. cityTaxCode = cityTaxCurrData.Name;
  1381. cityTaxName = $"({cityTaxCurrData.Remark})";
  1382. }
  1383. }
  1384. //酒店早餐
  1385. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1386. if (breakfastData != null)
  1387. {
  1388. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1389. breakfastFee = breakfastData.Price;
  1390. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1391. if (breakfastCurrData != null)
  1392. {
  1393. breakfastCode = breakfastCurrData.Name;
  1394. breakfastName = $"({breakfastCurrData.Remark})";
  1395. }
  1396. }
  1397. //房间费用
  1398. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1399. if (roomData != null)
  1400. {
  1401. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1402. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1403. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1404. roomFee = roomData.Price;
  1405. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1406. if (roomCurrData != null)
  1407. {
  1408. roomCode = roomCurrData.Name;
  1409. roomName = $"({roomCurrData.Remark})";
  1410. }
  1411. }
  1412. string hotelCostStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1413. if (groupCost != null)
  1414. {
  1415. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1416. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})</br>";
  1417. }
  1418. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= Convert.ToDateTime(hotelReservations.CheckInDate) &&
  1419. Convert.ToDateTime(x.Date) <= Convert.ToDateTime(hotelReservations.CheckOutDate)).ToList();
  1420. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1421. foreach (var item in hotelCostDetails1)
  1422. {
  1423. hotelCostStr += @$"{item.First()?.Date ?? "-"}";
  1424. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCostStr += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1425. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCostStr += @$" 1/2 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1426. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCostStr += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1427. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCostStr += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1428. hotelCostStr += @$"</br>";
  1429. }
  1430. _detail.PriceMsgContent = $"{hotelCostStr}<br/>"+
  1431. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1432. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1433. $"房间说明: {hotelReservations.Remark} <br/>" +
  1434. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率 {roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1435. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1436. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1437. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1438. _detail.PriceNameContent = hotelReservations.HotelName;
  1439. }
  1440. break;
  1441. case 79://车/导游地接
  1442. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1443. if (touristGuideGroundReservations != null)
  1444. {
  1445. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1446. {
  1447. _detail.BusName = touristGuideGroundReservations.BusName;
  1448. }
  1449. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1450. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1451. //if (isInt)
  1452. //{
  1453. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1454. // if (cityInfo != null)
  1455. // {
  1456. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1457. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1458. // if (carFeeItem != null)
  1459. // {
  1460. // nameContent += $@"({carFeeItem.Name})";
  1461. // }
  1462. // _detail.PriceNameContent = nameContent;
  1463. // }
  1464. //}
  1465. //else
  1466. //{
  1467. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1468. //}
  1469. var touristGuideGroundReservationsContents =
  1470. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1471. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1472. foreach (var item in touristGuideGroundReservationsContents)
  1473. {
  1474. string typeName = "Unknown";
  1475. string carCurrencyCode = "Unknown";
  1476. string carCurrencyName = "Unknown";
  1477. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1478. if (carTypeData != null) typeName = carTypeData.Name;
  1479. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1480. if (currencyData != null)
  1481. {
  1482. carCurrencyCode = currencyData.Name;
  1483. carCurrencyName = currencyData.Remark;
  1484. }
  1485. string opCostStr =string.Empty;
  1486. decimal opCostTypePrice = 0.00M;
  1487. #region 处理成本各项费用
  1488. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1489. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1490. if (opCost.Count > 0)
  1491. {
  1492. switch (item.SId)
  1493. {
  1494. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1495. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1496. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1497. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1498. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1499. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1500. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1501. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1502. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1503. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1504. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1505. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1506. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1507. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1508. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1509. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1510. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1511. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1512. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1513. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1514. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1515. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1516. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1517. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1518. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1519. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1520. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1521. }
  1522. opCostStr = $"&nbsp;&nbsp;/成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1523. }
  1524. #endregion
  1525. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1526. $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")}) {opCostStr}<br/>" +
  1527. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1528. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1529. }
  1530. _detail.PriceMsgContent = priceMsg;
  1531. }
  1532. break;
  1533. case 80: //签证
  1534. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1535. if (visaInfo != null)
  1536. {
  1537. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1538. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1539. }
  1540. break;
  1541. case 81: //邀请/公务活动
  1542. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1543. if (_ioa != null)
  1544. {
  1545. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1546. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1547. sendCurrName = "Unknown", //快递费用币种 Name
  1548. sendCurrCode = "Unknown", //快递费用币种 Code
  1549. eventsCurrName = "Unknown", //公务活动费币种 Name
  1550. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1551. translateCurrName = "Unknown", //公务翻译费 Name
  1552. translateCurrCode = "Unknown"; //公务翻译费 Code
  1553. #region 处理费用币种
  1554. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1555. if (inviteCurrData != null)
  1556. {
  1557. inviteCurrName = inviteCurrData.Remark;
  1558. inviteCurrCode = inviteCurrData.Name;
  1559. }
  1560. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1561. if (sendCurrData != null)
  1562. {
  1563. sendCurrName = sendCurrData.Remark;
  1564. sendCurrCode = sendCurrData.Name;
  1565. }
  1566. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1567. if (eventsCurrData != null)
  1568. {
  1569. eventsCurrName = eventsCurrData.Remark;
  1570. eventsCurrCode = eventsCurrData.Name;
  1571. }
  1572. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1573. if (translateCurrData != null)
  1574. {
  1575. translateCurrName = translateCurrData.Remark;
  1576. translateCurrCode = translateCurrData.Name;
  1577. }
  1578. #endregion
  1579. _detail.PriceNameContent = _ioa.InviterArea;
  1580. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1581. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1582. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1583. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1584. $@"备注:" + _ioa.Remark + "<br/>";
  1585. }
  1586. break;
  1587. case 82: //团组客户保险
  1588. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1589. if (customers != null)
  1590. {
  1591. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1592. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1593. }
  1594. break;
  1595. case 85: //机票预订
  1596. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1597. if (jpRes != null)
  1598. {
  1599. string FlightsDescription = jpRes.FlightsDescription;
  1600. string PriceDescription = jpRes.PriceDescription;
  1601. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1602. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1603. }
  1604. break;
  1605. case 98://其他款项
  1606. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1607. if (gdpRes != null)
  1608. {
  1609. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1610. _detail.PriceNameContent = gdpRes.PriceName;
  1611. }
  1612. break;
  1613. case 285://收款退还
  1614. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1615. if (refundAndOtherMoney != null)
  1616. {
  1617. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1618. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1619. }
  1620. break;
  1621. case 751://酒店早餐
  1622. break;
  1623. case 1015://超支费用
  1624. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1625. if (groupExtraCost != null)
  1626. {
  1627. _detail.PriceNameContent = groupExtraCost.PriceName;
  1628. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1629. }
  1630. break;
  1631. default:
  1632. break;
  1633. }
  1634. /*
  1635. * 申请人
  1636. */
  1637. string operatorName = " - ";
  1638. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1639. if (_opUser != null)
  1640. {
  1641. operatorName = _opUser.CnName;
  1642. }
  1643. _detail.OperatorName = operatorName;
  1644. /*
  1645. * 审核人
  1646. */
  1647. string auditOperatorName = "Unknown";
  1648. if (entity.AuditGMOperate == 0)
  1649. auditOperatorName = " - ";
  1650. else if (entity.AuditGMOperate == 4)
  1651. auditOperatorName = "自动审核";
  1652. else
  1653. {
  1654. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1655. if (_adUser != null)
  1656. {
  1657. auditOperatorName = _adUser.CnName;
  1658. }
  1659. }
  1660. _detail.AuditOperatorName = auditOperatorName;
  1661. /*
  1662. * 超预算比例
  1663. */
  1664. string overBudgetStr = "";
  1665. if (entity.ExceedBudget == -1)
  1666. overBudgetStr = sdPriceName.Name + "尚无预算";
  1667. else if (entity.ExceedBudget == 0)
  1668. {
  1669. if (entity.CTable == 76 || entity.CTable == 79)
  1670. {
  1671. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1672. else overBudgetStr = "超预算";
  1673. }
  1674. else
  1675. {
  1676. overBudgetStr = "未超预算";
  1677. }
  1678. }
  1679. else
  1680. overBudgetStr = entity.ExceedBudget.ToString("P");
  1681. _detail.OverBudget = overBudgetStr;
  1682. /*
  1683. * 费用总计
  1684. */
  1685. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1686. {
  1687. CurrencyId = entity.PaymentCurrency,
  1688. CurrencyName = PaymentCurrency_WaitPay,
  1689. AmountPayable = entity.PayMoney,
  1690. ThisPayment = CurrPayStr,
  1691. BalancePayment = BalanceStr,
  1692. AuditedFunds = CurrPayStr
  1693. });
  1694. _detail.IsAuditGM = entity.IsAuditGM;
  1695. detailList.Add(_detail);
  1696. }
  1697. #endregion
  1698. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1699. /*
  1700. * 下方描述处理
  1701. */
  1702. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1703. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1704. if (ccpCurrencyPrice != null)
  1705. {
  1706. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1707. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1708. }
  1709. else
  1710. {
  1711. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1712. }
  1713. string amountPayableStr = string.Format(@"应付款总金额: ");
  1714. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1715. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1716. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1717. foreach (var item in nonDuplicat)
  1718. {
  1719. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1720. if (strs.Count > 0)
  1721. {
  1722. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1723. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1724. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1725. //单独处理此次付款金额
  1726. if (item.CurrencyId == 836) //人民币
  1727. {
  1728. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1729. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1730. }
  1731. else
  1732. {
  1733. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1734. }
  1735. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1736. //单独处理已审核费用
  1737. if (item.CurrencyId == 836) //人民币
  1738. {
  1739. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1740. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1741. }
  1742. else
  1743. {
  1744. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1745. }
  1746. }
  1747. }
  1748. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1749. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1750. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1751. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1752. var _view1 = new
  1753. {
  1754. PageFuncAuth = pageFunAuthView,
  1755. Data = _view
  1756. };
  1757. return Ok(JsonView(_view1));
  1758. }
  1759. catch (Exception ex)
  1760. {
  1761. return Ok(JsonView(false, ex.Message));
  1762. }
  1763. }
  1764. /// <summary>
  1765. /// 费用审核
  1766. /// 修改团组费用审核状态
  1767. /// </summary>
  1768. /// <param name="_dto">参数Json字符串</param>
  1769. /// <returns></returns>
  1770. [HttpPost]
  1771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1772. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1773. {
  1774. #region 参数验证
  1775. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1776. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1777. #endregion
  1778. #region 页面操作权限验证
  1779. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1780. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1781. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1782. #endregion
  1783. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1784. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1785. DateTime dtNow = DateTime.Now;
  1786. _groupRepository.BeginTran();
  1787. int rst = 0;
  1788. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1789. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1790. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1791. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1792. List<dynamic> msgDatas = new List<dynamic>();
  1793. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1794. foreach (var item in idList)
  1795. {
  1796. int CreditId = int.Parse(item);
  1797. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1798. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1799. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1800. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1801. .Where(s => s.Id == CreditId)
  1802. .ExecuteCommandAsync();
  1803. if (result < 1)
  1804. {
  1805. rst = -1;
  1806. _groupRepository.RollbackTran();
  1807. return Ok(JsonView(false, "操作失败并回滚!"));
  1808. }
  1809. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1810. if (creditData != null)
  1811. {
  1812. #region 应用通知配置
  1813. try
  1814. {
  1815. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1816. }
  1817. catch (Exception ex)
  1818. {
  1819. }
  1820. #endregion
  1821. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1822. string groupNameStr = string.Empty;
  1823. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1824. if (groupData != null) groupNameStr = groupData.TeamName;
  1825. string creditTypeStr = string.Empty;
  1826. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1827. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1828. string creditCurrency = string.Empty;
  1829. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1830. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1831. if (creditCurrency.Equals("CNY"))
  1832. {
  1833. creditData.DayRate = 1.0000M;
  1834. }
  1835. if (creditData.PayPercentage == 0.00M)
  1836. {
  1837. creditData.PayPercentage = 100M;
  1838. }
  1839. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1840. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1841. string msgContent = "";
  1842. if (creditCurrency.Equals("CNY"))
  1843. {
  1844. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1845. }
  1846. else
  1847. {
  1848. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1849. }
  1850. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1851. }
  1852. }
  1853. if (rst == 0)
  1854. {
  1855. _groupRepository.CommitTran();
  1856. foreach (var item in msgDatas)
  1857. {
  1858. //发送消息
  1859. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1860. }
  1861. #region 应用推送
  1862. try
  1863. {
  1864. foreach (var ccpId in dic_ccp_user.Keys)
  1865. {
  1866. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1867. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1868. }
  1869. }
  1870. catch (Exception)
  1871. {
  1872. }
  1873. #endregion
  1874. return Ok(JsonView(true, "操作成功!"));
  1875. }
  1876. return Ok(JsonView(false, "操作失败!"));
  1877. }
  1878. #endregion
  1879. #region 机票费用录入
  1880. /// <summary>
  1881. /// 机票录入当前登录人可操作团组
  1882. /// </summary>
  1883. /// <param name="dto"></param>
  1884. /// <returns></returns>
  1885. [HttpPost]
  1886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1887. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1888. {
  1889. try
  1890. {
  1891. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1892. if (groupData.Code != 0)
  1893. {
  1894. return Ok(JsonView(false, groupData.Msg));
  1895. }
  1896. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1897. }
  1898. catch (Exception ex)
  1899. {
  1900. return Ok(JsonView(false, "程序错误!"));
  1901. throw;
  1902. }
  1903. }
  1904. /// <summary>
  1905. /// 机票费用录入列表
  1906. /// </summary>
  1907. /// <param name="dto"></param>
  1908. /// <returns></returns>
  1909. [HttpPost]
  1910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1911. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1912. {
  1913. try
  1914. {
  1915. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1916. if (groupData.Code != 0)
  1917. {
  1918. return Ok(JsonView(false, groupData.Msg));
  1919. }
  1920. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1921. }
  1922. catch (Exception ex)
  1923. {
  1924. return Ok(JsonView(false, ex.Message));
  1925. throw;
  1926. }
  1927. }
  1928. /// <summary>
  1929. /// 根据id查询费用录入信息
  1930. /// </summary>
  1931. /// <param name="dto"></param>
  1932. /// <returns></returns>
  1933. [HttpPost]
  1934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1935. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1936. {
  1937. try
  1938. {
  1939. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1940. if (groupData.Code != 0)
  1941. {
  1942. return Ok(JsonView(false, groupData.Msg));
  1943. }
  1944. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1945. }
  1946. catch (Exception ex)
  1947. {
  1948. return Ok(JsonView(false, "程序错误!"));
  1949. throw;
  1950. }
  1951. }
  1952. /// <summary>
  1953. /// 机票费用录入操作(Status:1.新增,2.修改)
  1954. /// </summary>
  1955. /// <param name="dto"></param>
  1956. /// <returns></returns>
  1957. [HttpPost]
  1958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1959. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1960. {
  1961. try
  1962. {
  1963. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1964. if (groupData.Code != 0)
  1965. {
  1966. return Ok(JsonView(false, groupData.Msg));
  1967. }
  1968. #region 应用推送
  1969. try
  1970. {
  1971. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1972. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1973. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1974. }
  1975. catch (Exception ex)
  1976. {
  1977. }
  1978. #endregion
  1979. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1980. }
  1981. catch (Exception ex)
  1982. {
  1983. return Ok(JsonView(false, "程序错误!"));
  1984. throw;
  1985. }
  1986. }
  1987. /// <summary>
  1988. /// 根据舱位类型查询接团客户名单信息
  1989. /// </summary>
  1990. /// <param name="dto"></param>
  1991. /// <returns></returns>
  1992. [HttpPost]
  1993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1994. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1995. {
  1996. try
  1997. {
  1998. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1999. if (crm_Groups.Count != 0)
  2000. {
  2001. List<dynamic> Customer = new List<dynamic>();
  2002. foreach (var item in crm_Groups)
  2003. {
  2004. var data = new
  2005. {
  2006. Id = item.Id,
  2007. Pinyin = item.Pinyin,
  2008. Name = item.LastName + item.FirstName
  2009. };
  2010. Customer.Add(data);
  2011. }
  2012. return Ok(JsonView(true, "查询成功!", Customer));
  2013. }
  2014. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2015. }
  2016. catch (Exception ex)
  2017. {
  2018. return Ok(JsonView(false, "程序错误!"));
  2019. throw;
  2020. }
  2021. }
  2022. /// <summary>
  2023. /// 根据团号获取客户信息
  2024. /// </summary>
  2025. /// <param name="dto"></param>
  2026. /// <returns></returns>
  2027. [HttpPost]
  2028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2029. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2030. {
  2031. var jw = JsonView(false);
  2032. if (dto.DIID < 1)
  2033. {
  2034. jw.Msg += "请输入正确的diid";
  2035. return Ok(jw);
  2036. }
  2037. var arr = getSimplClientList(dto.DIID);
  2038. jw = JsonView(true, "获取成功!", arr);
  2039. return Ok(jw);
  2040. }
  2041. private List<SimplClientInfo> getSimplClientList(int diId)
  2042. {
  2043. 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);
  2044. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2045. return arr;
  2046. }
  2047. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2048. {
  2049. string result = origin;
  2050. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2051. {
  2052. string[] temparr = origin.Split(',');
  2053. string fistrStr = temparr[0];
  2054. int count = temparr.Count();
  2055. int tempId;
  2056. bool success = int.TryParse(fistrStr, out tempId);
  2057. if (success)
  2058. {
  2059. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2060. if (tempInfo != null)
  2061. {
  2062. if (count > 1)
  2063. {
  2064. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2065. }
  2066. else
  2067. {
  2068. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2069. }
  2070. }
  2071. }
  2072. }
  2073. return result;
  2074. }
  2075. /// <summary>
  2076. /// 机票费用录入,删除
  2077. /// </summary>
  2078. /// <param name="dto"></param>
  2079. /// <returns></returns>
  2080. [HttpPost]
  2081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2082. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2083. {
  2084. try
  2085. {
  2086. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2087. if (res)
  2088. {
  2089. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2090. {
  2091. IsDel = 1,
  2092. DeleteUserId = dto.DeleteUserId,
  2093. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2094. }).ExecuteCommandAsync();
  2095. return Ok(JsonView(true, "删除成功!"));
  2096. }
  2097. return Ok(JsonView(false, "删除失败!"));
  2098. }
  2099. catch (Exception ex)
  2100. {
  2101. return Ok(JsonView(false, "程序错误!"));
  2102. throw;
  2103. }
  2104. }
  2105. /// <summary>
  2106. /// 导出机票录入报表
  2107. /// </summary>
  2108. /// <param name="dto"></param>
  2109. /// <returns></returns>
  2110. [HttpPost]
  2111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2112. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2113. {
  2114. try
  2115. {
  2116. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2117. if (groupData.Code != 0)
  2118. {
  2119. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2120. }
  2121. else
  2122. {
  2123. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2124. if (AirTicketReservations.Count != 0)
  2125. {
  2126. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2127. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2128. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2129. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2130. WorkbookDesigner designer = new WorkbookDesigner();
  2131. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2132. decimal countCost = 0;
  2133. foreach (var item in AirTicketReservations)
  2134. {
  2135. #region 处理客人姓名
  2136. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2137. item.ClientName = clientNames;
  2138. #endregion
  2139. if (item.BankType == "其他")
  2140. {
  2141. item.BankNo = "--";
  2142. }
  2143. else
  2144. {
  2145. if (!string.IsNullOrEmpty(item.BankType))
  2146. {
  2147. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2148. }
  2149. }
  2150. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2151. item.Price = System.Decimal.Round(item.Price, 2);
  2152. countCost += Convert.ToDecimal(item.Price);
  2153. }
  2154. designer.SetDataSource("Export", AirTicketReservations);
  2155. designer.SetDataSource("ExportDiCode", diCode);
  2156. designer.SetDataSource("ExportDiName", diName);
  2157. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2158. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2159. designer.Process();
  2160. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2161. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2162. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2163. return Ok(JsonView(true, "成功", url = rst));
  2164. }
  2165. else
  2166. {
  2167. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2168. }
  2169. }
  2170. }
  2171. catch (Exception ex)
  2172. {
  2173. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2174. throw;
  2175. }
  2176. }
  2177. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2178. /// <summary>
  2179. /// 行程单导出
  2180. /// </summary>
  2181. /// <param name="dto"></param>
  2182. /// <returns></returns>
  2183. [HttpPost]
  2184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2185. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2186. {
  2187. try
  2188. {
  2189. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2190. if (groupData.Code != 0)
  2191. {
  2192. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2193. }
  2194. else
  2195. {
  2196. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2197. if (dto.Language == "CN")
  2198. {
  2199. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2200. DocumentBuilder builder = new DocumentBuilder(doc);
  2201. int tableIndex = 0;//表格索引
  2202. //得到文档中的第一个表格
  2203. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2204. foreach (var item in _AirTicketReservations)
  2205. {
  2206. #region 处理固定数据
  2207. string[] FlightsCode = item.FlightsCode.Split('/');
  2208. if (FlightsCode.Length != 0)
  2209. {
  2210. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2211. if (_AirCompany != null)
  2212. {
  2213. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2214. }
  2215. else
  2216. {
  2217. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2218. }
  2219. }
  2220. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2221. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2222. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2223. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2224. string name = "";
  2225. foreach (string clientName in nameArray)
  2226. {
  2227. if (!name.Contains(clientName))
  2228. {
  2229. name += clientName + ",";
  2230. }
  2231. }
  2232. if (!string.IsNullOrWhiteSpace(name))
  2233. {
  2234. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2235. }
  2236. else
  2237. {
  2238. table.Range.Bookmarks["ClientName"].Text = "--";
  2239. }
  2240. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2241. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2242. table.Range.Bookmarks["JointTicket"].Text = "--";
  2243. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2244. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2245. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2246. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2247. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2248. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2249. #endregion
  2250. #region 循环数据处理
  2251. List<AirInfo> airs = new List<AirInfo>();
  2252. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2253. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2254. for (int i = 0; i < FlightsCode.Length; i++)
  2255. {
  2256. AirInfo air = new AirInfo();
  2257. string[] tempstr = DayArray[i]
  2258. .Replace("\r\n", string.Empty)
  2259. .Replace("\\r\\n", string.Empty)
  2260. .TrimStart().TrimEnd()
  2261. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2262. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2263. string starCity = "";
  2264. if (star_Three != null)
  2265. {
  2266. starCity = star_Three.AirPort;
  2267. }
  2268. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2269. string EndCity = "";
  2270. if (End_Three != null)
  2271. {
  2272. EndCity = End_Three.AirPort;
  2273. }
  2274. air.Destination = starCity + "/" + EndCity;
  2275. air.Flight = FlightsCode[i];
  2276. air.SeatingClass = item.CTypeName;
  2277. string dateTime = tempstr[2];
  2278. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2279. air.FlightDate = DateTemp;
  2280. air.DepartureTime = tempstr[5];
  2281. air.LandingTime = tempstr[6];
  2282. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2283. air.TicketStatus = "--";
  2284. air.Luggage = "--";
  2285. air.DepartureTerminal = "--";
  2286. air.LandingTerminal = "--";
  2287. airs.Add(air);
  2288. }
  2289. int row = 13;
  2290. for (int i = 0; i < airs.Count; i++)
  2291. {
  2292. if (airs.Count > 2)
  2293. {
  2294. for (int j = 0; j < airs.Count - 2; j++)
  2295. {
  2296. var CopyRow = table.Rows[12].Clone(true);
  2297. table.Rows.Add(CopyRow);
  2298. }
  2299. }
  2300. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2301. int index = 0;
  2302. foreach (PropertyInfo property in properties)
  2303. {
  2304. string value = property.GetValue(airs[i]).ToString();
  2305. Cell ishcel0 = table.Rows[row].Cells[index];
  2306. Paragraph p = new Paragraph(doc);
  2307. string s = value;
  2308. p.AppendChild(new Run(doc, s));
  2309. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2310. ishcel0.AppendChild(p);
  2311. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2312. index++;
  2313. }
  2314. row++;
  2315. }
  2316. #endregion
  2317. Paragraph lastParagraph = new Paragraph(doc);
  2318. //第一个表格末尾加段落
  2319. table.ParentNode.InsertAfter(lastParagraph, table);
  2320. //复制第一个表格
  2321. Table cloneTable = (Table)table.Clone(true);
  2322. //在文档末尾段落后面加入复制的表格
  2323. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2324. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2325. {
  2326. int rownewsIndex = 13;
  2327. for (int i = 0; i < 2; i++)
  2328. {
  2329. var CopyRow = table.Rows[12].Clone(true);
  2330. table.Rows.RemoveAt(13);
  2331. table.Rows.Add(CopyRow);
  2332. rownewsIndex++;
  2333. }
  2334. }
  2335. else
  2336. {
  2337. table.Rows.RemoveAt(12);
  2338. }
  2339. cloneTable.Rows.RemoveAt(12);
  2340. }
  2341. if (_AirTicketReservations.Count != 0)
  2342. {
  2343. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2344. if (FlightsCode.Length != 0)
  2345. {
  2346. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2347. if (_AirCompany != null)
  2348. {
  2349. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2350. }
  2351. else
  2352. {
  2353. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2354. }
  2355. }
  2356. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2357. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2358. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2359. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2360. string name = "";
  2361. foreach (string clientName in nameArray)
  2362. {
  2363. if (!name.Contains(clientName))
  2364. {
  2365. name += clientName + ",";
  2366. }
  2367. }
  2368. if (!string.IsNullOrWhiteSpace(name))
  2369. {
  2370. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2371. }
  2372. else
  2373. {
  2374. table.Range.Bookmarks["ClientName"].Text = "--";
  2375. }
  2376. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2377. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2378. table.Range.Bookmarks["JointTicket"].Text = "--";
  2379. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2380. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2381. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2382. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2383. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2384. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2385. }
  2386. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2387. //保存合并后的文档
  2388. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2389. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2390. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2391. return Ok(JsonView(true, "成功!", rst));
  2392. }
  2393. else
  2394. {
  2395. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2396. DocumentBuilder builder = new DocumentBuilder(doc);
  2397. int tableIndex = 0;//表格索引
  2398. //得到文档中的第一个表格
  2399. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2400. List<string> texts = new List<string>();
  2401. foreach (var item in _AirTicketReservations)
  2402. {
  2403. string[] FlightsCode = item.FlightsCode.Split('/');
  2404. if (FlightsCode.Length != 0)
  2405. {
  2406. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2407. if (_AirCompany != null)
  2408. {
  2409. if (!transDic.ContainsKey(_AirCompany.CnName))
  2410. {
  2411. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2412. }
  2413. }
  2414. else
  2415. {
  2416. if (!transDic.ContainsKey("--"))
  2417. {
  2418. transDic.Add("--", "--");
  2419. }
  2420. }
  2421. }
  2422. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2423. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2424. string name = "";
  2425. foreach (string clientName in nameArray)
  2426. {
  2427. name += clientName + ",";
  2428. }
  2429. if (!texts.Contains(name))
  2430. {
  2431. texts.Add(name);
  2432. }
  2433. List<AirInfo> airs = new List<AirInfo>();
  2434. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2435. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2436. for (int i = 0; i < FlightsCode.Length; i++)
  2437. {
  2438. AirInfo air = new AirInfo();
  2439. string[] tempstr = DayArray[i]
  2440. .Replace("\r\n", string.Empty)
  2441. .Replace("\\r\\n", string.Empty)
  2442. .TrimStart().TrimEnd()
  2443. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2444. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2445. if (star_Three != null)
  2446. {
  2447. if (!transDic.ContainsKey(star_Three.AirPort))
  2448. {
  2449. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2450. }
  2451. }
  2452. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2453. if (End_Three != null)
  2454. {
  2455. if (!transDic.ContainsKey(End_Three.AirPort))
  2456. {
  2457. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2458. }
  2459. }
  2460. if (!texts.Contains(item.CTypeName))
  2461. {
  2462. texts.Add(item.CTypeName);
  2463. }
  2464. }
  2465. }
  2466. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2467. if (transData.Count > 0)
  2468. {
  2469. foreach (TranslateResult item in transData)
  2470. {
  2471. if (!transDic.ContainsKey(item.Query))
  2472. {
  2473. transDic.Add(item.Query, item.Translation);
  2474. }
  2475. }
  2476. }
  2477. foreach (var item in _AirTicketReservations)
  2478. {
  2479. #region 处理固定数据
  2480. string[] FlightsCode = item.FlightsCode.Split('/');
  2481. if (FlightsCode.Length != 0)
  2482. {
  2483. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2484. if (_AirCompany != null)
  2485. {
  2486. string str = "--";
  2487. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2488. if (!string.IsNullOrEmpty(translateResult))
  2489. {
  2490. str = translateResult;
  2491. str = _airTicketResRep.Processing(str);
  2492. }
  2493. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2494. }
  2495. else
  2496. {
  2497. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2498. }
  2499. }
  2500. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2501. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2502. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2503. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2504. string names = "";
  2505. foreach (string clientName in nameArray)
  2506. {
  2507. names += clientName + ",";
  2508. }
  2509. if (!string.IsNullOrWhiteSpace(names))
  2510. {
  2511. string str = "--";
  2512. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2513. if (!string.IsNullOrEmpty(translateResult))
  2514. {
  2515. str = translateResult;
  2516. str = _airTicketResRep.Processing(str);
  2517. }
  2518. table.Range.Bookmarks["ClientName"].Text = str;
  2519. }
  2520. else
  2521. {
  2522. table.Range.Bookmarks["ClientName"].Text = "--";
  2523. }
  2524. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2525. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2526. table.Range.Bookmarks["JointTicket"].Text = "--";
  2527. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2528. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2529. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2530. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2531. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2532. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2533. #endregion
  2534. #region 循环数据处理
  2535. List<AirInfo> airs = new List<AirInfo>();
  2536. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2537. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2538. for (int i = 0; i < FlightsCode.Length; i++)
  2539. {
  2540. AirInfo air = new AirInfo();
  2541. string[] tempstr = DayArray[i]
  2542. .Replace("\r\n", string.Empty)
  2543. .Replace("\\r\\n", string.Empty)
  2544. .TrimStart().TrimEnd()
  2545. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2546. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2547. string starCity = "";
  2548. if (star_Three != null)
  2549. {
  2550. string str2 = "--";
  2551. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2552. if (!string.IsNullOrEmpty(translateResult2))
  2553. {
  2554. str2 = translateResult2;
  2555. str2 = _airTicketResRep.Processing(str2);
  2556. }
  2557. starCity = str2;
  2558. }
  2559. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2560. string EndCity = "";
  2561. if (End_Three != null)
  2562. {
  2563. string str1 = "--";
  2564. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2565. if (!string.IsNullOrEmpty(translateResult1))
  2566. {
  2567. str1 = translateResult1;
  2568. str1 = _airTicketResRep.Processing(str1);
  2569. }
  2570. EndCity = str1;
  2571. }
  2572. air.Destination = starCity + "/" + EndCity;
  2573. air.Flight = FlightsCode[i];
  2574. string str = "--";
  2575. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2576. if (!string.IsNullOrEmpty(translateResult))
  2577. {
  2578. str = translateResult;
  2579. str = _airTicketResRep.Processing(str);
  2580. }
  2581. air.SeatingClass = str;
  2582. string dateTime = tempstr[2];
  2583. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2584. air.FlightDate = DateTemp;
  2585. air.DepartureTime = tempstr[5];
  2586. air.LandingTime = tempstr[6];
  2587. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2588. air.TicketStatus = "--";
  2589. air.Luggage = "--";
  2590. air.DepartureTerminal = "--";
  2591. air.LandingTerminal = "--";
  2592. airs.Add(air);
  2593. }
  2594. int row = 13;
  2595. for (int i = 0; i < airs.Count; i++)
  2596. {
  2597. if (airs.Count > 2)
  2598. {
  2599. for (int j = 0; j < airs.Count - 2; j++)
  2600. {
  2601. var CopyRow = table.Rows[12].Clone(true);
  2602. table.Rows.Add(CopyRow);
  2603. }
  2604. }
  2605. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2606. int index = 0;
  2607. foreach (PropertyInfo property in properties)
  2608. {
  2609. string value = property.GetValue(airs[i]).ToString();
  2610. Cell ishcel0 = table.Rows[row].Cells[index];
  2611. Paragraph p = new Paragraph(doc);
  2612. string s = value;
  2613. p.AppendChild(new Run(doc, s));
  2614. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2615. ishcel0.AppendChild(p);
  2616. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2617. //ishcel0.CellFormat.VerticalAlignment=
  2618. index++;
  2619. }
  2620. row++;
  2621. }
  2622. #endregion
  2623. Paragraph lastParagraph = new Paragraph(doc);
  2624. //第一个表格末尾加段落
  2625. table.ParentNode.InsertAfter(lastParagraph, table);
  2626. //复制第一个表格
  2627. Table cloneTable = (Table)table.Clone(true);
  2628. //在文档末尾段落后面加入复制的表格
  2629. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2630. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2631. {
  2632. int rownewsIndex = 13;
  2633. for (int i = 0; i < 2; i++)
  2634. {
  2635. var CopyRow = table.Rows[12].Clone(true);
  2636. table.Rows.RemoveAt(13);
  2637. table.Rows.Add(CopyRow);
  2638. rownewsIndex++;
  2639. }
  2640. }
  2641. else
  2642. {
  2643. table.Rows.RemoveAt(12);
  2644. }
  2645. cloneTable.Rows.RemoveAt(12);
  2646. }
  2647. if (_AirTicketReservations.Count != 0)
  2648. {
  2649. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2650. if (FlightsCode.Length != 0)
  2651. {
  2652. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2653. if (_AirCompany != null)
  2654. {
  2655. string str = "--";
  2656. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2657. if (!string.IsNullOrEmpty(translateResult))
  2658. {
  2659. str = translateResult;
  2660. str = _airTicketResRep.Processing(str);
  2661. }
  2662. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2663. }
  2664. else
  2665. {
  2666. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2667. }
  2668. }
  2669. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2670. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2671. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2672. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2673. string names = "";
  2674. foreach (string clientName in nameArray)
  2675. {
  2676. names += clientName + ",";
  2677. }
  2678. if (!string.IsNullOrWhiteSpace(names))
  2679. {
  2680. string str = "--";
  2681. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2682. if (!string.IsNullOrEmpty(translateResult))
  2683. {
  2684. str = translateResult;
  2685. str = _airTicketResRep.Processing(str);
  2686. }
  2687. table.Range.Bookmarks["ClientName"].Text = str;
  2688. }
  2689. else
  2690. {
  2691. table.Range.Bookmarks["ClientName"].Text = "--";
  2692. }
  2693. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2694. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2695. table.Range.Bookmarks["JointTicket"].Text = "--";
  2696. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2697. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2698. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2699. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2700. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2701. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2702. }
  2703. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2704. //保存合并后的文档
  2705. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2706. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2707. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2708. return Ok(JsonView(true, "成功!", rst));
  2709. }
  2710. }
  2711. }
  2712. catch (Exception ex)
  2713. {
  2714. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2715. throw;
  2716. }
  2717. }
  2718. #endregion
  2719. #region 团组增减款项 --> 其他款项
  2720. /// <summary>
  2721. /// 团组增减款项下拉框绑定
  2722. /// </summary>
  2723. /// <param name="dto"></param>
  2724. /// <returns></returns>
  2725. [HttpPost]
  2726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2727. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2728. {
  2729. #region 参数验证
  2730. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2731. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2732. #endregion
  2733. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2734. }
  2735. /// <summary>
  2736. /// 根据团组Id查询团组增减款项
  2737. /// </summary>
  2738. /// <param name="dto"></param>
  2739. /// <returns></returns>
  2740. [HttpPost]
  2741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2742. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2743. {
  2744. #region 参数验证
  2745. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2746. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2747. #endregion
  2748. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2749. }
  2750. /// <summary>
  2751. /// 团组增减款项操作(Status:1.新增,2.修改)
  2752. /// </summary>
  2753. /// <param name="dto"></param>
  2754. /// <returns></returns>
  2755. [HttpPost]
  2756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2757. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2758. {
  2759. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2760. if (groupData.Code != 200)
  2761. {
  2762. return Ok(JsonView(false, groupData.Msg));
  2763. }
  2764. #region 应用推送
  2765. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2766. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2767. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2768. #endregion
  2769. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2770. }
  2771. /// <summary>
  2772. /// 团组增减款项操作 删除
  2773. /// </summary>
  2774. /// <param name="dto"></param>
  2775. /// <returns></returns>
  2776. [HttpPost]
  2777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2778. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2779. {
  2780. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2781. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2782. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2783. if (res.Code == 0)
  2784. {
  2785. return Ok(JsonView(true, "删除成功!"));
  2786. }
  2787. return Ok(JsonView(false, "删除失败!"));
  2788. }
  2789. /// <summary>
  2790. /// 根据团组增减款项Id查询
  2791. /// </summary>
  2792. /// <param name="dto"></param>
  2793. /// <returns></returns>
  2794. [HttpPost]
  2795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2796. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2797. {
  2798. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2799. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2800. }
  2801. /// <summary>
  2802. /// 查询供应商名称
  2803. /// </summary>
  2804. /// <param name="dto"></param>
  2805. /// <returns></returns>
  2806. [HttpPost]
  2807. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2808. {
  2809. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2810. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2811. ?? new List<Grp_DecreasePayments>();
  2812. dbResult = dbResult.Distinct(new
  2813. ProductComparer()).ToList();
  2814. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2815. {
  2816. x.Id,
  2817. x.SupplierAddress,
  2818. x.SupplierArea,
  2819. x.SupplierContact,
  2820. x.SupplierContactNumber,
  2821. x.SupplierEmail,
  2822. x.SupplierName,
  2823. x.SupplierSocialAccount,
  2824. x.SupplierTypeId,
  2825. }).ToList());
  2826. return Ok(jw);
  2827. }
  2828. #endregion
  2829. #region 文件上传、删除
  2830. /// <summary>
  2831. /// region 文件上传 可以带参数
  2832. /// </summary>
  2833. /// <param name="file"></param>
  2834. /// <returns></returns>
  2835. [HttpPost]
  2836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2837. public async Task<IActionResult> UploadProject(IFormFile file)
  2838. {
  2839. try
  2840. {
  2841. var TypeName = Request.Headers["TypeName"].ToString();
  2842. if (file != null)
  2843. {
  2844. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2845. //文件名称
  2846. string projectFileName = file.FileName;
  2847. //上传的文件的路径
  2848. string filePath = "";
  2849. if (TypeName == "A")//A代表团组增减款项
  2850. {
  2851. if (!Directory.Exists(fileDir))
  2852. {
  2853. Directory.CreateDirectory(fileDir);
  2854. }
  2855. //上传的文件的路径
  2856. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2857. }
  2858. else if (TypeName == "B")//B代表商邀相关文件
  2859. {
  2860. if (!Directory.Exists(fileDir))
  2861. {
  2862. Directory.CreateDirectory(fileDir);
  2863. }
  2864. //上传的文件的路径
  2865. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2866. }
  2867. using (FileStream fs = System.IO.File.Create(filePath))
  2868. {
  2869. file.CopyTo(fs);
  2870. fs.Flush();
  2871. }
  2872. return Ok(JsonView(true, "上传成功!", projectFileName));
  2873. }
  2874. else
  2875. {
  2876. return Ok(JsonView(false, "上传失败!"));
  2877. }
  2878. }
  2879. catch (Exception ex)
  2880. {
  2881. return Ok(JsonView(false, "程序错误!"));
  2882. throw;
  2883. }
  2884. }
  2885. /// <summary>
  2886. /// 删除指定文件
  2887. /// </summary>
  2888. /// <param name="dto"></param>
  2889. /// <returns></returns>
  2890. [HttpPost]
  2891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2892. public async Task<IActionResult> DelFile(DelFileDto dto)
  2893. {
  2894. try
  2895. {
  2896. var TypeName = Request.Headers["TypeName"].ToString();
  2897. string filePath = "";
  2898. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2899. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2900. int id = 0;
  2901. if (TypeName == "A")
  2902. {
  2903. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2904. // 删除该文件
  2905. System.IO.File.Delete(filePath);
  2906. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2907. }
  2908. else if (TypeName == "B")
  2909. {
  2910. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2911. // 删除该文件
  2912. System.IO.File.Delete(filePath);
  2913. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2914. }
  2915. if (id != 0)
  2916. {
  2917. return Ok(JsonView(true, "成功!"));
  2918. }
  2919. else
  2920. {
  2921. return Ok(JsonView(false, "失败!"));
  2922. }
  2923. }
  2924. catch (Exception ex)
  2925. {
  2926. return Ok(JsonView(false, "程序错误!"));
  2927. throw;
  2928. }
  2929. }
  2930. #endregion
  2931. #region 商邀费用录入
  2932. /// <summary>
  2933. /// 根据团组Id查询商邀费用列表
  2934. /// </summary>
  2935. /// <param name="dto"></param>
  2936. /// <returns></returns>
  2937. [HttpPost]
  2938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2939. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2940. {
  2941. try
  2942. {
  2943. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2944. if (groupData.Code != 0)
  2945. {
  2946. return Ok(JsonView(false, groupData.Msg));
  2947. }
  2948. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2949. }
  2950. catch (Exception ex)
  2951. {
  2952. return Ok(JsonView(false, "程序错误!"));
  2953. throw;
  2954. }
  2955. }
  2956. //
  2957. /// <summary>
  2958. /// 商邀费用 Info Page 基础数据源
  2959. /// </summary>
  2960. /// <param name="dto"></param>
  2961. /// <returns></returns>
  2962. [HttpPost]
  2963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2964. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2965. {
  2966. try
  2967. {
  2968. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2969. if (groupData.Code != 0)
  2970. {
  2971. return Ok(JsonView(false, groupData.Msg));
  2972. }
  2973. return Ok(JsonView(true, "操作成功", groupData.Data));
  2974. }
  2975. catch (Exception ex)
  2976. {
  2977. return Ok(JsonView(false, ex.Message));
  2978. throw;
  2979. }
  2980. }
  2981. /// <summary>
  2982. /// 根据商邀费用ID查询C表和商邀费用数据
  2983. /// </summary>
  2984. /// <param name="dto"></param>
  2985. /// <returns></returns>
  2986. [HttpPost]
  2987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2988. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2989. {
  2990. try
  2991. {
  2992. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2993. if (groupData.Code != 0)
  2994. {
  2995. return Ok(JsonView(false, groupData.Msg));
  2996. }
  2997. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2998. }
  2999. catch (Exception ex)
  3000. {
  3001. return Ok(JsonView(false, ex.Message));
  3002. throw;
  3003. }
  3004. }
  3005. /// <summary>
  3006. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3007. /// </summary>
  3008. /// <param name="dto"></param>
  3009. /// <returns></returns>
  3010. [HttpPost]
  3011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3012. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3013. {
  3014. try
  3015. {
  3016. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3017. if (groupData.Code != 0)
  3018. {
  3019. return Ok(JsonView(false, groupData.Msg));
  3020. }
  3021. #region 应用推送
  3022. try
  3023. {
  3024. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3025. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3026. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3027. }
  3028. catch (Exception ex)
  3029. {
  3030. }
  3031. #endregion
  3032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3033. }
  3034. catch (Exception ex)
  3035. {
  3036. return Ok(JsonView(false, "程序错误!"));
  3037. throw;
  3038. }
  3039. }
  3040. /// <summary>
  3041. /// 商邀删除
  3042. /// </summary>
  3043. /// <param name="dto"></param>
  3044. /// <returns></returns>
  3045. [HttpPost]
  3046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3047. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3048. {
  3049. try
  3050. {
  3051. _sqlSugar.BeginTran();
  3052. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3053. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3054. {
  3055. IsDel = 1,
  3056. DeleteUserId = dto.DeleteUserId,
  3057. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3058. })
  3059. .Where(it => it.Id == dto.Id)
  3060. .ExecuteCommand();
  3061. if (res1 > 0)
  3062. {
  3063. int _diId = 0;
  3064. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3065. if (_ioaInfo != null)
  3066. {
  3067. _diId = _ioaInfo.DiId;
  3068. }
  3069. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3070. .SetColumns(a => new Grp_CreditCardPayment()
  3071. {
  3072. IsDel = 1,
  3073. DeleteUserId = dto.DeleteUserId,
  3074. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3075. })
  3076. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3077. .ExecuteCommand();
  3078. if (res2 > 0)
  3079. {
  3080. _sqlSugar.CommitTran();
  3081. return Ok(JsonView(true, "删除成功!"));
  3082. }
  3083. }
  3084. _sqlSugar.RollbackTran();
  3085. return Ok(JsonView(false, "删除失败"));
  3086. }
  3087. catch (Exception ex)
  3088. {
  3089. _sqlSugar.RollbackTran();
  3090. return Ok(JsonView(false, ex.Message));
  3091. }
  3092. }
  3093. #endregion
  3094. #region 团组英文资料
  3095. /// <summary>
  3096. /// 查询团组英文所有资料
  3097. /// </summary>
  3098. /// <param name="dto"></param>
  3099. /// <returns></returns>
  3100. [HttpPost]
  3101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3102. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3103. {
  3104. try
  3105. {
  3106. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3107. if (groupData.Code != 0)
  3108. {
  3109. return Ok(JsonView(false, groupData.Msg));
  3110. }
  3111. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3112. }
  3113. catch (Exception ex)
  3114. {
  3115. return Ok(JsonView(false, "程序错误!"));
  3116. throw;
  3117. }
  3118. }
  3119. /// <summary>
  3120. /// 团组英文资料操作(Status:1.新增,2.修改)
  3121. /// </summary>
  3122. /// <param name="dto"></param>
  3123. /// <returns></returns>
  3124. [HttpPost]
  3125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3126. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3127. {
  3128. try
  3129. {
  3130. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3131. if (groupData.Code != 0)
  3132. {
  3133. return Ok(JsonView(false, groupData.Msg));
  3134. }
  3135. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3136. }
  3137. catch (Exception ex)
  3138. {
  3139. return Ok(JsonView(false, "程序错误!"));
  3140. throw;
  3141. }
  3142. }
  3143. /// <summary>
  3144. /// 团组英文资料Id查询数据
  3145. /// </summary>
  3146. /// <param name="dto"></param>
  3147. /// <returns></returns>
  3148. [HttpPost]
  3149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3150. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3151. {
  3152. try
  3153. {
  3154. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3155. if (_DelegationEnData != null)
  3156. {
  3157. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3158. }
  3159. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3160. }
  3161. catch (Exception ex)
  3162. {
  3163. return Ok(JsonView(false, "程序错误!"));
  3164. throw;
  3165. }
  3166. }
  3167. /// <summary>
  3168. /// 团组英文资料删除
  3169. /// </summary>
  3170. /// <param name="dto"></param>
  3171. /// <returns></returns>
  3172. [HttpPost]
  3173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3174. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3175. {
  3176. try
  3177. {
  3178. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3179. if (!res)
  3180. {
  3181. return Ok(JsonView(false, "删除失败"));
  3182. }
  3183. return Ok(JsonView(true, "删除成功!"));
  3184. }
  3185. catch (Exception ex)
  3186. {
  3187. return Ok(JsonView(false, "程序错误!"));
  3188. throw;
  3189. }
  3190. }
  3191. #endregion
  3192. #region 导出邀请函
  3193. /// <summary>
  3194. /// 导出邀请函页面初始化
  3195. /// </summary>
  3196. /// <param name="dto"></param>
  3197. /// <returns></returns>
  3198. [HttpPost]
  3199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3200. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3201. {
  3202. try
  3203. {
  3204. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3205. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3206. if (dto.DiId == 0)
  3207. {
  3208. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3209. }
  3210. else
  3211. {
  3212. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3213. }
  3214. return Ok(JsonView(true, "查询成功!", new
  3215. {
  3216. deleClient = crm_Deles,
  3217. delegations = grp_Delegations
  3218. }));
  3219. }
  3220. catch (Exception ex)
  3221. {
  3222. return Ok(JsonView(false, "程序错误!"));
  3223. throw;
  3224. }
  3225. }
  3226. /// <summary>
  3227. /// 导出邀请函
  3228. /// </summary>
  3229. /// <param name="dto"></param>
  3230. /// <returns></returns>
  3231. [HttpPost]
  3232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3233. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3234. {
  3235. #region 参数验证
  3236. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3237. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3238. #endregion
  3239. try
  3240. {
  3241. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3242. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3243. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3244. From Grp_TourClientList tcl
  3245. Left Join
  3246. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3247. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3248. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3249. From Crm_DeleClient dc
  3250. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3251. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3252. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3253. Where dc.IsDel = 0) temp
  3254. On temp.DcId =tcl.ClientId
  3255. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3256. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3257. List<string> texts = new List<string>();
  3258. if (datas.Count != 0)
  3259. {
  3260. foreach (TourClientListDetailsView item in datas)
  3261. {
  3262. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3263. {
  3264. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3265. }
  3266. else
  3267. {
  3268. string name = item.LastName + item.FirstName;
  3269. texts.Add(name);
  3270. }
  3271. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3272. {
  3273. if (!transDic.ContainsKey(item.Job))
  3274. {
  3275. texts.Add(item.Job);
  3276. }
  3277. }
  3278. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3279. {
  3280. texts.Add(item.CompanyFullName);
  3281. }
  3282. }
  3283. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3284. if (transData.Count > 0)
  3285. {
  3286. foreach (TranslateResult item in transData)
  3287. {
  3288. if (!transDic.ContainsKey(item.Query))
  3289. {
  3290. transDic.Add(item.Query, item.Translation);
  3291. }
  3292. }
  3293. }
  3294. List<GuestList> list = new List<GuestList>();
  3295. foreach (TourClientListDetailsView dele in datas)
  3296. {
  3297. GuestList guestList = new GuestList();
  3298. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3299. {
  3300. guestList.Name = dele.Pinyin;
  3301. }
  3302. else
  3303. {
  3304. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3305. guestList.Name = Name;
  3306. }
  3307. if (dele.Sex == 0)
  3308. {
  3309. guestList.Sex = "Male";
  3310. }
  3311. else if (dele.Sex == 1)
  3312. {
  3313. guestList.Sex = "Female";
  3314. }
  3315. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3316. if (!string.IsNullOrEmpty(dele.Job))
  3317. {
  3318. guestList.Job = dele.Job;
  3319. }
  3320. list.Add(guestList);
  3321. }
  3322. //载入模板
  3323. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3324. DocumentBuilder builder = new DocumentBuilder(doc);
  3325. //获取word里所有表格
  3326. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3327. //获取所填表格的序数
  3328. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3329. var rowStart = tableOne.Rows[0]; //获取第1行
  3330. //循环赋值
  3331. for (int i = 0; i < list.Count; i++)
  3332. {
  3333. builder.MoveToCell(0, i + 1, 0, 0);
  3334. builder.Write(list[i].Name.ToString());
  3335. builder.MoveToCell(0, i + 1, 1, 0);
  3336. builder.Write(list[i].Sex.ToString());
  3337. builder.MoveToCell(0, i + 1, 2, 0);
  3338. builder.Write(list[i].DOB.ToString());
  3339. builder.MoveToCell(0, i + 1, 3, 0);
  3340. builder.Write(list[i].Job.ToString());
  3341. }
  3342. //删除多余行
  3343. while (tableOne.Rows.Count > list.Count + 1)
  3344. {
  3345. tableOne.Rows.RemoveAt(list.Count + 1);
  3346. }
  3347. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3348. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3349. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3350. doc.Save(filePath);
  3351. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3352. return Ok(JsonView(true, "操作成功!", Url));
  3353. }
  3354. else
  3355. {
  3356. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3357. }
  3358. }
  3359. catch (Exception ex)
  3360. {
  3361. return Ok(JsonView(false, ex.Message));
  3362. throw;
  3363. }
  3364. }
  3365. #endregion
  3366. #region 团组经理模块 出入境费用
  3367. ///// <summary>
  3368. ///// 团组模块 - 出入境费用
  3369. ///// </summary>
  3370. ///// <returns></returns>
  3371. //[HttpPost]
  3372. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3373. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3374. //{
  3375. // try
  3376. // {
  3377. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3378. // if (data.Code != 0)
  3379. // {
  3380. // return Ok(JsonView(false, data.Msg));
  3381. // }
  3382. // return Ok(JsonView(true, "查询成功!"));
  3383. // }
  3384. // catch (Exception ex)
  3385. // {
  3386. // return Ok(JsonView(false, ex.Message));
  3387. // throw;
  3388. // }
  3389. //}
  3390. /// <summary>
  3391. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3392. /// </summary>
  3393. /// <returns></returns>
  3394. [HttpPost]
  3395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3396. public async Task<IActionResult> SetDayAndCostAreaChange()
  3397. {
  3398. try
  3399. {
  3400. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3401. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3402. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3403. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3404. foreach (var item in unite) //处理交集数据
  3405. {
  3406. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3407. }
  3408. foreach (var item in merge) //处理差集数据
  3409. {
  3410. int nationalTravelFeeId = 0;
  3411. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3412. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3413. else
  3414. {
  3415. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3416. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3417. }
  3418. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3419. }
  3420. //只更新dayAndCost 的 nationalTravelFeeId;
  3421. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3422. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3423. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3424. }
  3425. catch (Exception ex)
  3426. {
  3427. return Ok(JsonView(false, ex.Message));
  3428. throw;
  3429. }
  3430. }
  3431. /// <summary>
  3432. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3433. /// </summary>
  3434. /// <returns></returns>
  3435. [HttpPost]
  3436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3437. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3438. {
  3439. try
  3440. {
  3441. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3442. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3443. //SetDataInfoView
  3444. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3445. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3446. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3447. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3448. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3449. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3450. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3451. //默认币种显示
  3452. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3453. {
  3454. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3455. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3456. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3457. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3458. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3459. };
  3460. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3461. if (_currencyRate.Count > 0)
  3462. {
  3463. foreach (var item in _currencyInfos)
  3464. {
  3465. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3466. if (rateInfo != null)
  3467. {
  3468. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3469. rate1 *= 1.035M;
  3470. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3471. }
  3472. }
  3473. }
  3474. return Ok(JsonView(true, "查询成功!", new
  3475. {
  3476. GroupNameData = groupNameData.Data,
  3477. CurrencyData = _CurrencyData,
  3478. WordTypeData = _WordTypeData,
  3479. ExcelTypeData = _ExcelTypeData,
  3480. CurrencyInit = _currencyInfos
  3481. }));
  3482. }
  3483. catch (Exception ex)
  3484. {
  3485. return Ok(JsonView(false, ex.Message));
  3486. throw;
  3487. }
  3488. }
  3489. /// <summary>
  3490. /// 团组模块 - 出入境费用
  3491. /// 实时汇率 tips
  3492. /// 签证费用 tips
  3493. /// </summary>
  3494. /// <returns></returns>
  3495. [HttpPost]
  3496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3497. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3498. {
  3499. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3500. //默认币种显示
  3501. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3502. {
  3503. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3504. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3505. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3506. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3507. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3508. };
  3509. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3510. List<dynamic> reteInfos = new List<dynamic>();
  3511. if (_currencyRate.Count > 0)
  3512. {
  3513. foreach (var item in _currencyInfos)
  3514. {
  3515. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3516. if (rateInfo != null)
  3517. {
  3518. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3519. decimal rate1 = item.Rate;
  3520. rate1 *= 1.03M;
  3521. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3522. reteInfos.Add(new
  3523. {
  3524. currCode = item.CurrencyCode,
  3525. currName = item.CurrencyName,
  3526. rate = rate2,
  3527. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3528. });
  3529. }
  3530. }
  3531. }
  3532. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3533. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3534. return Ok(JsonView(true, "查询成功!", new
  3535. {
  3536. //GroupNameData = groupNameData.Data,
  3537. visaData = visaData.Data,
  3538. airData = airData.Data,
  3539. reteInfos = reteInfos
  3540. }));
  3541. }
  3542. /// <summary>
  3543. /// 团组模块 - 出入境费用 - Info
  3544. /// </summary>
  3545. /// <returns></returns>
  3546. [HttpPost]
  3547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3548. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3549. {
  3550. try
  3551. {
  3552. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3553. if (data.Code != 0)
  3554. {
  3555. return Ok(JsonView(false, data.Msg));
  3556. }
  3557. return Ok(JsonView(true, "查询成功!", data.Data));
  3558. }
  3559. catch (Exception ex)
  3560. {
  3561. return Ok(JsonView(false, ex.Message));
  3562. }
  3563. }
  3564. /// <summary>
  3565. /// 团组模块 - 出入境费用 - Add And Update
  3566. /// </summary>
  3567. /// <returns></returns>
  3568. [HttpPost]
  3569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3570. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3571. {
  3572. try
  3573. {
  3574. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3575. if (data.Code != 0)
  3576. {
  3577. return Ok(JsonView(false, data.Msg));
  3578. }
  3579. return Ok(JsonView(true, data.Msg, data.Data));
  3580. }
  3581. catch (Exception ex)
  3582. {
  3583. return Ok(JsonView(false, ex.Message));
  3584. }
  3585. }
  3586. /// <summary>
  3587. /// 团组模块 - 出入境费用 - File downlaod
  3588. /// </summary>
  3589. /// <param name="dto"></param>
  3590. /// <returns></returns>
  3591. [HttpPost]
  3592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3593. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3594. {
  3595. try
  3596. {
  3597. if (dto.DiId < 1)
  3598. {
  3599. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3600. }
  3601. if (dto.ExportType < 1)
  3602. {
  3603. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3604. }
  3605. if (dto.SubTypeId < 1)
  3606. {
  3607. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3608. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3609. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3610. 3 团组成员名单 1 团组成员名单"));
  3611. }
  3612. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3613. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3614. if (_EnterExitCosts == null)
  3615. {
  3616. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3617. }
  3618. //数据源
  3619. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3620. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3621. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3622. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3623. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3624. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3625. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3626. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3627. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3628. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3629. .Select((tcl, dc, cc) => new
  3630. {
  3631. Name = dc.LastName + dc.FirstName,
  3632. Sex = dc.Sex,
  3633. Birthday = dc.BirthDay,
  3634. Company = cc.CompanyFullName,
  3635. Job = dc.Job
  3636. })
  3637. .ToList();
  3638. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3639. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3640. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3641. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3642. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3643. if (dto.ExportType == 1) //明细表
  3644. {
  3645. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3646. {
  3647. //获取模板
  3648. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3649. //载入模板
  3650. Document doc = new Document(tempPath);
  3651. DocumentBuilder builder = new DocumentBuilder(doc);
  3652. //利用键值对存放数据
  3653. Dictionary<string, string> dic = new Dictionary<string, string>();
  3654. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3655. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3656. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3657. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3658. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3659. string row1_1 = "";
  3660. if (_EnterExitCosts.Visa > 0)
  3661. {
  3662. //insidePayTotal += _EnterExitCosts.Visa;
  3663. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3664. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3665. {
  3666. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3667. }
  3668. }
  3669. string row1_2 = "";
  3670. if (_EnterExitCosts.YiMiao > 0)
  3671. {
  3672. //insidePayTotal += _EnterExitCosts.YiMiao;
  3673. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3674. }
  3675. if (_EnterExitCosts.HeSuan > 0)
  3676. {
  3677. //insidePayTotal += _EnterExitCosts.HeSuan;
  3678. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3679. }
  3680. if (_EnterExitCosts.Service > 0)
  3681. {
  3682. //insidePayTotal += _EnterExitCosts.Service;
  3683. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3684. }
  3685. string row1_3 = "";
  3686. if (_EnterExitCosts.Safe > 0)
  3687. {
  3688. //insidePayTotal += _EnterExitCosts.Safe;
  3689. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3690. }
  3691. if (_EnterExitCosts.Ticket > 0)
  3692. {
  3693. //insidePayTotal += _EnterExitCosts.Ticket;
  3694. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3695. }
  3696. string row1 = "";
  3697. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3698. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3699. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3700. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3701. dic.Add("Row1Str", row1);
  3702. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3703. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3704. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3705. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3706. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3707. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3708. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3709. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3710. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3711. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3712. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3713. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3714. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3715. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3716. #region 填充word模板书签内容
  3717. foreach (var key in dic.Keys)
  3718. {
  3719. builder.MoveToBookmark(key);
  3720. builder.Write(dic[key]);
  3721. }
  3722. #endregion
  3723. #region 填充word表格内容
  3724. ////获读取指定表格方法二
  3725. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3726. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3727. for (int i = 0; i < dac1.Count; i++)
  3728. {
  3729. Grp_DayAndCost dac = dac1[i];
  3730. if (dac == null) continue;
  3731. builder.MoveToCell(0, i, 0, 0);
  3732. builder.Write("第" + dac.Days.ToString() + "晚:");
  3733. builder.MoveToCell(0, i, 1, 0);
  3734. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3735. //builder.Write(dac.Place == null ? "" : dac.Place);
  3736. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3737. builder.MoveToCell(0, i, 2, 0);
  3738. builder.Write("费用标准:");
  3739. string curr = "";
  3740. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3741. if (currData != null)
  3742. {
  3743. curr = currData.Name;
  3744. }
  3745. builder.MoveToCell(0, i, 3, 0);
  3746. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3747. builder.MoveToCell(0, i, 4, 0);
  3748. builder.Write("费用小计:");
  3749. builder.MoveToCell(0, i, 5, 0);
  3750. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3751. }
  3752. //删除多余行
  3753. while (table1.Rows.Count > dac1.Count)
  3754. {
  3755. table1.Rows.RemoveAt(dac1.Count);
  3756. }
  3757. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3758. for (int i = 0; i < dac2.Count; i++)
  3759. {
  3760. Grp_DayAndCost dac = dac2[i];
  3761. if (dac == null) continue;
  3762. builder.MoveToCell(1, i, 0, 0);
  3763. builder.Write("第" + dac.Days.ToString() + "天:");
  3764. builder.MoveToCell(1, i, 1, 0);
  3765. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3766. builder.MoveToCell(1, i, 2, 0);
  3767. builder.Write("费用标准:");
  3768. string curr = "";
  3769. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3770. if (currData != null)
  3771. {
  3772. curr = currData.Name;
  3773. }
  3774. builder.MoveToCell(1, i, 3, 0);
  3775. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3776. builder.MoveToCell(1, i, 4, 0);
  3777. builder.Write("费用小计:");
  3778. builder.MoveToCell(1, i, 5, 0);
  3779. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3780. }
  3781. //删除多余行
  3782. while (table2.Rows.Count > dac2.Count)
  3783. {
  3784. table2.Rows.RemoveAt(dac2.Count);
  3785. }
  3786. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3787. for (int i = 0; i < dac3.Count; i++)
  3788. {
  3789. Grp_DayAndCost dac = dac3[i];
  3790. if (dac == null) continue;
  3791. builder.MoveToCell(2, i, 0, 0);
  3792. builder.Write("第" + dac.Days.ToString() + "天:");
  3793. builder.MoveToCell(2, i, 1, 0);
  3794. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3795. builder.MoveToCell(2, i, 2, 0);
  3796. builder.Write("费用标准:");
  3797. string curr = "";
  3798. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3799. if (currData != null)
  3800. {
  3801. curr = currData.Name;
  3802. }
  3803. builder.MoveToCell(2, i, 3, 0);
  3804. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3805. builder.MoveToCell(2, i, 4, 0);
  3806. builder.Write("费用小计:");
  3807. builder.MoveToCell(2, i, 5, 0);
  3808. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3809. }
  3810. //删除多余行
  3811. while (table3.Rows.Count > dac3.Count)
  3812. {
  3813. table3.Rows.RemoveAt(dac3.Count);
  3814. }
  3815. #endregion
  3816. //文件名
  3817. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3818. AsposeHelper.removewatermark_v2180();
  3819. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3820. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3821. return Ok(JsonView(true, "成功", new { Url = url }));
  3822. }
  3823. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3824. {
  3825. //获取模板
  3826. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3827. //载入模板
  3828. Document doc = new Document(tempPath);
  3829. DocumentBuilder builder = new DocumentBuilder(doc);
  3830. Dictionary<string, string> dic = new Dictionary<string, string>();
  3831. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3832. {
  3833. List<string> list = new List<string>();
  3834. try
  3835. {
  3836. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3837. foreach (var item in spilitArr)
  3838. {
  3839. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3840. var depCode = spDotandEmpty[2].Substring(0, 3);
  3841. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3842. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3843. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3844. list.Add(depName);
  3845. list.Add(arrName);
  3846. }
  3847. list = list.Distinct().ToList();
  3848. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3849. }
  3850. catch (Exception)
  3851. {
  3852. dic.Add("ReturnCode", "行程录入不正确!");
  3853. }
  3854. }
  3855. else
  3856. {
  3857. dic.Add("ReturnCode", "未录入行程!");
  3858. }
  3859. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3860. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3861. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3862. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3863. {
  3864. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3865. dic.Add("Day", sp.Days.ToString());
  3866. }
  3867. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3868. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3869. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3870. //dic.Add("Names", Names);
  3871. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3872. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3873. decimal dac1totalPrice = 0.00M;
  3874. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3875. foreach (var dac in dac1)
  3876. {
  3877. if (dac.SubTotal == 0.00M)
  3878. {
  3879. continue;
  3880. }
  3881. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3882. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3883. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3884. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3885. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3886. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3887. builder.Write(currency);//币种
  3888. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3889. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3890. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3891. builder.Write("");//人数
  3892. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3893. builder.Write("");//天数
  3894. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3895. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3896. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3897. decimal rate = 0.00M;
  3898. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3899. builder.Write(rate.ToString("#0.0000"));//汇率
  3900. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3901. decimal rbmPrice = dac.SubTotal;
  3902. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3903. accommodationStartIndex++;
  3904. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3905. }
  3906. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3907. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3908. {
  3909. table1.Rows.RemoveAt(i - 1);
  3910. foodandotherStartIndex--;
  3911. }
  3912. if (dac2.Count == dac3.Count)//国家 币种 金额
  3913. {
  3914. for (int i = 0; i < dac2.Count; i++)
  3915. {
  3916. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3917. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3918. }
  3919. }
  3920. decimal dac2totalPrice = 0.00M;
  3921. foreach (var dac in dac2)
  3922. {
  3923. if (dac.SubTotal == 0)
  3924. {
  3925. continue;
  3926. }
  3927. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3928. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3929. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3930. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3931. builder.Write(currency);//币种
  3932. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3933. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3934. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3935. builder.Write("");//人数
  3936. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3937. builder.Write("");//天数
  3938. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3939. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3940. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3941. decimal rate = 0.00M;
  3942. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3943. builder.Write(rate.ToString("#0.0000"));//汇率
  3944. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3945. decimal rbmPrice = dac.SubTotal;
  3946. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3947. foodandotherStartIndex++;
  3948. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3949. }
  3950. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3951. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3952. {
  3953. table1.Rows.RemoveAt(i - 1);
  3954. }
  3955. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3956. string otherFeeStr = "";
  3957. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3958. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3959. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3960. if (otherFeeStr.Length > 0)
  3961. {
  3962. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3963. otherFeeStr = $"({otherFeeStr})";
  3964. dic.Add("OtherFeeStr", otherFeeStr);
  3965. }
  3966. //总计
  3967. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3968. //国际旅费
  3969. string outsideJJ = "";
  3970. string allPriceJJ = "";
  3971. if (_EnterExitCosts.SumJJC == 1)
  3972. {
  3973. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3974. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3975. }
  3976. string outsideGW = "";
  3977. string allPriceGW = "";
  3978. if (_EnterExitCosts.SumGWC == 1)
  3979. {
  3980. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3981. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3982. }
  3983. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3984. {
  3985. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3986. dic.Add("InTravelPrice", InTravelPriceStr);
  3987. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3988. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3989. }
  3990. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3991. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3992. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3993. foreach (var key in dic.Keys)
  3994. {
  3995. builder.MoveToBookmark(key);
  3996. builder.Write(dic[key]);
  3997. }
  3998. //模板文件名
  3999. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4000. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4001. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4002. return Ok(JsonView(true, "成功", new { Url = url }));
  4003. }
  4004. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4005. {
  4006. //获取模板
  4007. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4008. //载入模板
  4009. WorkbookDesigner designer = new WorkbookDesigner();
  4010. designer.Workbook = new Workbook(tempPath);
  4011. Dictionary<string, string> dic = new Dictionary<string, string>();
  4012. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4013. {
  4014. List<string> list = new List<string>();
  4015. try
  4016. {
  4017. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4018. foreach (var item in spilitArr)
  4019. {
  4020. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4021. var depCode = spDotandEmpty[2].Substring(0, 3);
  4022. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4023. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4024. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4025. list.Add(depName);
  4026. list.Add(arrName);
  4027. }
  4028. list = list.Distinct().ToList();
  4029. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4030. }
  4031. catch (Exception)
  4032. {
  4033. dic.Add("ReturnCode", "行程录入不正确!");
  4034. }
  4035. }
  4036. else
  4037. {
  4038. dic.Add("ReturnCode", "未录入行程!");
  4039. }
  4040. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4041. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4042. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4043. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4044. {
  4045. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4046. dic.Add("Day", sp.Days.ToString());
  4047. }
  4048. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4049. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4050. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4051. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4052. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4053. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4054. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4055. designer.SetDataSource("Name", Names);
  4056. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4057. designer.SetDataSource("Day", dic["Day"] + "天");
  4058. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4059. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4060. int startIndex = 10;
  4061. const int startIndexcopy = 10;
  4062. if (dac2.Count == dac3.Count)//国家 币种 金额
  4063. {
  4064. for (int i = 0; i < dac2.Count; i++)
  4065. {
  4066. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4067. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4068. }
  4069. }
  4070. DataTable dtdac1 = new DataTable();
  4071. List<string> place = new List<string>();
  4072. dtdac1.Columns.AddRange(new DataColumn[] {
  4073. new DataColumn(){ ColumnName = "city"},
  4074. new DataColumn(){ ColumnName = "curr"},
  4075. new DataColumn(){ ColumnName = "criterion"},
  4076. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4077. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4078. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4079. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4080. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4081. });
  4082. DataTable dtdac2 = new DataTable();
  4083. dtdac2.Columns.AddRange(new DataColumn[] {
  4084. new DataColumn(){ ColumnName = "city"},
  4085. new DataColumn(){ ColumnName = "curr"},
  4086. new DataColumn(){ ColumnName = "criterion"},
  4087. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4088. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4089. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4090. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4091. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4092. });
  4093. dtdac1.TableName = "tb1";
  4094. dtdac2.TableName = "tb2";
  4095. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4096. foreach (var item in dac1)
  4097. {
  4098. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4099. if (place.Contains(item.Place))
  4100. {
  4101. continue;
  4102. }
  4103. DataRow row = dtdac1.NewRow();
  4104. row["city"] = item.Place;
  4105. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4106. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4107. row["curr"] = currency;
  4108. row["rate"] = rate.ToString("#0.0000");
  4109. row["criterion"] = item.Cost.ToString("#0.00");
  4110. row["number"] = 1;
  4111. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4112. //row["costRMB"] = rbmPrice;
  4113. dtdac1.Rows.Add(row);
  4114. place.Add(item.Place);
  4115. }
  4116. place = new List<string>();
  4117. foreach (var item in dac2)
  4118. {
  4119. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4120. if (place.Contains(item.Place))
  4121. {
  4122. continue;
  4123. }
  4124. DataRow row = dtdac2.NewRow();
  4125. row["city"] = item.Place;
  4126. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4127. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4128. row["curr"] = currency;
  4129. row["rate"] = rate.ToString("#0.0000");
  4130. row["criterion"] = item.Cost.ToString("#0.00");
  4131. row["number"] = 1;
  4132. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4133. //row["cost"] = item.SubTotal;
  4134. //row["costRMB"] = rbmPrice;
  4135. dtdac2.Rows.Add(row);
  4136. place.Add(item.Place);
  4137. //dac2totalPrice += rbmPrice;
  4138. }
  4139. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4140. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4141. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4142. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4143. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4144. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4145. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4146. string cellStr = $" 5.其他费用(";
  4147. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4148. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4149. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4150. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4151. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4152. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4153. if (cellStr.Length > 8)
  4154. {
  4155. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4156. }
  4157. cellStr += ")";
  4158. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4159. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4160. decimal pxFee = dac4.Sum(it => it.Cost);
  4161. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4162. string celllastStr1 = "";
  4163. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4164. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4165. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4166. celllastStr1 += $",国际旅费 元";
  4167. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4168. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4169. designer.SetDataSource("cell4Str", cell4Str);
  4170. designer.SetDataSource("cellStr", cellStr);
  4171. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4172. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4173. designer.SetDataSource("celllastStr", celllastStr);
  4174. Workbook wb = designer.Workbook;
  4175. var sheet = wb.Worksheets[0];
  4176. //绑定datatable数据集
  4177. designer.SetDataSource(dtdac1);
  4178. designer.SetDataSource(dtdac2);
  4179. designer.Process();
  4180. var rowStart = dtdac1.Rows.Count;
  4181. while (rowStart > 0)
  4182. {
  4183. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4184. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4185. startIndex++;
  4186. rowStart--;
  4187. }
  4188. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4189. startIndex += 1; //总计行
  4190. rowStart = dtdac2.Rows.Count;
  4191. while (rowStart > 0)
  4192. {
  4193. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4194. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4195. startIndex++;
  4196. rowStart--;
  4197. }
  4198. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4199. wb.CalculateFormula(true);
  4200. //模板文件名
  4201. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4202. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4203. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4204. return Ok(JsonView(true, "成功", new { Url = url }));
  4205. }
  4206. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4207. {
  4208. //获取模板
  4209. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4210. //载入模板
  4211. Document doc = new Document(tempPath);
  4212. DocumentBuilder builder = new DocumentBuilder(doc);
  4213. Dictionary<string, string> dic = new Dictionary<string, string>();
  4214. dic.Add("GroupName", _DelegationInfo.TeamName);
  4215. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4216. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4217. string missionLeaderJob = "";//负责人job
  4218. int groupNumber = 0; //团人数
  4219. if (DeleClientList.Count > 0)
  4220. {
  4221. missionLeader = DeleClientList[0]?.Name ?? "";
  4222. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4223. }
  4224. dic.Add("MissionLeader", missionLeader); //团负责人
  4225. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4226. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4227. #region MyRegion
  4228. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4229. //{
  4230. // List<string> list = new List<string>();
  4231. // try
  4232. // {
  4233. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4234. // foreach (var item in spilitArr)
  4235. // {
  4236. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4237. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4238. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4239. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4240. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4241. // list.Add(depName);
  4242. // list.Add(arrName);
  4243. // }
  4244. // list = list.Distinct().ToList();
  4245. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4246. // }
  4247. // catch (Exception)
  4248. // {
  4249. // dic.Add("ReturnCode", "行程录入不正确!");
  4250. // }
  4251. //}
  4252. //else
  4253. //{
  4254. // dic.Add("ReturnCode", "未录入行程!");
  4255. //}
  4256. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4257. dic.Add("ReturnCode", string.Join("、", countrys));
  4258. #endregion
  4259. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4260. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4261. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4262. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4263. //{
  4264. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4265. // dic.Add("Day", sp.Days.ToString());
  4266. //}
  4267. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4268. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4269. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4270. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4271. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4272. //培训人员名单
  4273. int cultivateRowIndex = 7;
  4274. foreach (var item in DeleClientList)
  4275. {
  4276. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4277. builder.Write(item.Name);
  4278. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4279. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4280. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4281. string birthDay = "";
  4282. if (item.Birthday != null)
  4283. {
  4284. DateTime dt = Convert.ToDateTime(item.Birthday);
  4285. birthDay = $"{dt.Year}.{dt.Month}";
  4286. }
  4287. builder.Write(birthDay);
  4288. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4289. builder.Write(item.Company);
  4290. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4291. builder.Write(item.Job);
  4292. cultivateRowIndex++;
  4293. }
  4294. //删除多余行
  4295. //cultivateRowIndex -= 2;
  4296. int delRows = 10 + 7 - cultivateRowIndex;
  4297. if (delRows > 0)
  4298. {
  4299. for (int i = 0; i < delRows; i++)
  4300. {
  4301. table1.Rows.RemoveAt(cultivateRowIndex);
  4302. //cultivateRowIndex++;
  4303. }
  4304. }
  4305. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4306. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4307. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4308. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4309. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4310. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4311. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4312. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4313. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4314. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4315. //其他费用
  4316. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4317. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4318. //其他费用合计
  4319. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4320. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4321. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4322. //公务舱合计
  4323. //国际旅费
  4324. string outsideJJ = "";
  4325. string allPriceJJ = "";
  4326. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4327. {
  4328. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4329. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4330. }
  4331. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4332. {
  4333. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4334. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4335. }
  4336. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4337. {
  4338. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4339. dic.Add("AirFeeTotal", airFeeTotalStr);
  4340. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4341. dic.Add("FeeTotal", feeTotalStr);
  4342. }
  4343. foreach (var key in dic.Keys)
  4344. {
  4345. builder.MoveToBookmark(key);
  4346. builder.Write(dic[key]);
  4347. }
  4348. //模板文件名
  4349. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4350. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4351. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4352. return Ok(JsonView(true, "成功", new { Url = url }));
  4353. }
  4354. }
  4355. else if (dto.ExportType == 2) //表格
  4356. {
  4357. //利用键值对存放数据
  4358. Dictionary<string, string> dic = new Dictionary<string, string>();
  4359. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4360. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4361. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4362. dic.Add("Day", sp.Days.ToString());
  4363. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4364. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4365. {
  4366. //获取模板
  4367. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4368. //载入模板
  4369. Document doc = new Document(tempPath);
  4370. DocumentBuilder builder = new DocumentBuilder(doc);
  4371. dic.Add("TeamName", _DelegationInfo.TeamName);
  4372. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4373. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4374. string missionLeaderName = "",
  4375. missionLeaderJob = "";
  4376. if (DeleClientList.Count > 0)
  4377. {
  4378. missionLeaderName = DeleClientList[0].Name;
  4379. missionLeaderJob = DeleClientList[0].Job;
  4380. }
  4381. dic.Add("MissionLeaderName", missionLeaderName);
  4382. dic.Add("MissionLeaderJob", missionLeaderJob);
  4383. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4384. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4385. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4386. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4387. int rowCount = 10;//总人数行
  4388. int startRowIndex = 7; //起始行
  4389. for (int i = 0; i < DeleClientList.Count; i++)
  4390. {
  4391. builder.MoveToCell(0, startRowIndex, 0, 0);
  4392. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4393. builder.MoveToCell(0, startRowIndex, 1, 0);
  4394. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4395. builder.Write(sex);//性别
  4396. builder.MoveToCell(0, startRowIndex, 2, 0);
  4397. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4398. builder.MoveToCell(0, startRowIndex, 3, 0);
  4399. builder.Write(DeleClientList[i].Company);//工作单位
  4400. builder.MoveToCell(0, startRowIndex, 4, 0);
  4401. builder.Write(DeleClientList[i].Job);//职务及级别
  4402. builder.MoveToCell(0, startRowIndex, 5, 0);
  4403. builder.Write("");//人员属性
  4404. builder.MoveToCell(0, startRowIndex, 6, 0);
  4405. builder.Write("");//上次出国时间
  4406. startRowIndex++;
  4407. }
  4408. int nullRow = rowCount - DeleClientList.Count;//空行
  4409. for (int i = 0; i < nullRow; i++)
  4410. {
  4411. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4412. }
  4413. foreach (var key in dic.Keys)
  4414. {
  4415. builder.MoveToBookmark(key);
  4416. builder.Write(dic[key]);
  4417. }
  4418. //模板文件名
  4419. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4420. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4421. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4422. return Ok(JsonView(true, "成功", new { Url = url }));
  4423. }
  4424. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4425. {
  4426. //获取模板
  4427. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4428. //载入模板
  4429. Document doc = new Document(tempPath);
  4430. DocumentBuilder builder = new DocumentBuilder(doc);
  4431. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4432. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4433. dic.Add("Names", Names);
  4434. int accommodationRows = 12, foodandotherRows = 12;
  4435. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4436. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4437. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4438. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4439. int accommodationStartIndex = 6;
  4440. decimal dac1totalPrice = 0.00M;
  4441. foreach (var dac in dac1)
  4442. {
  4443. if (dac.SubTotal == 0)
  4444. {
  4445. continue;
  4446. }
  4447. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4448. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4449. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4450. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4451. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4452. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4453. builder.Write(currency);//币种
  4454. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4455. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4456. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4457. builder.Write("");//人数
  4458. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4459. builder.Write("");//天数
  4460. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4461. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4462. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4463. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4464. builder.Write(rate.ToString("#0.0000"));//汇率
  4465. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4466. decimal rbmPrice = rate * dac.SubTotal;
  4467. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4468. accommodationStartIndex++;
  4469. dac1totalPrice += rbmPrice;
  4470. }
  4471. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4472. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4473. builder.Write("小计");
  4474. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4475. builder.Write(dac1totalPrice.ToString("#0.00"));
  4476. accommodationStartIndex++;
  4477. int nullRow = accommodationRows - dac1.Count;
  4478. //删除空行
  4479. //if (nullRow > 0)
  4480. //{
  4481. // int rowIndex = accommodationStartIndex;
  4482. // for (int i = 0; i < nullRow; i++)
  4483. // {
  4484. // Row row = table1.Rows[rowIndex];
  4485. // row.Remove();
  4486. // rowIndex++;
  4487. // }
  4488. //}
  4489. if (dac2.Count == dac3.Count)//国家 币种 金额
  4490. {
  4491. for (int i = 0; i < dac2.Count; i++)
  4492. {
  4493. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4494. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4495. }
  4496. }
  4497. int foodandotherStartIndex = 19;//
  4498. decimal dac2totalPrice = 0.00M;
  4499. foreach (var dac in dac2)
  4500. {
  4501. if (dac.SubTotal == 0)
  4502. {
  4503. continue;
  4504. }
  4505. //foodandotherStartIndex = 12;
  4506. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4507. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4508. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4509. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4510. builder.Write(currency);//币种
  4511. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4512. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4513. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4514. builder.Write("");//人数
  4515. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4516. builder.Write("");//天数
  4517. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4518. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4519. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4520. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4521. builder.Write(rate.ToString("#0.0000"));//汇率
  4522. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4523. decimal rbmPrice = rate * dac.SubTotal;
  4524. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4525. foodandotherStartIndex++;
  4526. dac2totalPrice += rbmPrice;
  4527. }
  4528. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4529. //删除空行
  4530. if (dac2.Count < foodandotherRows)
  4531. {
  4532. //int nullRow = accommodationRows - dac2.Count;
  4533. //while (table2.Rows.Count > dac2.Count)
  4534. //{
  4535. // table2.Rows.RemoveAt(dac2.Count);
  4536. //}
  4537. }
  4538. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4539. string otherFeeStr = "";
  4540. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4541. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4542. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4543. if (otherFeeStr.Length > 0)
  4544. {
  4545. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4546. otherFeeStr = $"({otherFeeStr})";
  4547. dic.Add("OtherFeeStr", otherFeeStr);
  4548. }
  4549. foreach (var key in dic.Keys)
  4550. {
  4551. builder.MoveToBookmark(key);
  4552. builder.Write(dic[key]);
  4553. }
  4554. //模板文件名
  4555. string strFileName = $"省级单位出(境)经费报销单.docx";
  4556. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4557. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4558. return Ok(JsonView(true, "成功", new { Url = url }));
  4559. }
  4560. }
  4561. else if (dto.ExportType == 3)
  4562. {
  4563. if (dto.SubTypeId == 1) //团组成员名单
  4564. {
  4565. if (DeleClientList.Count < 1)
  4566. {
  4567. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4568. }
  4569. //获取模板
  4570. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4571. //载入模板
  4572. Document doc = new Document(tempPath);
  4573. DocumentBuilder builder = new DocumentBuilder(doc);
  4574. //获取word里所有表格
  4575. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4576. //获取所填表格的序数
  4577. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4578. var rowStart = tableOne.Rows[0]; //获取第1行
  4579. //循环赋值
  4580. for (int i = 0; i < DeleClientList.Count; i++)
  4581. {
  4582. builder.MoveToCell(0, i + 1, 0, 0);
  4583. builder.Write(DeleClientList[i].Name);
  4584. builder.MoveToCell(0, i + 1, 1, 0);
  4585. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4586. builder.Write(sex);
  4587. builder.MoveToCell(0, i + 1, 2, 0);
  4588. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4589. builder.MoveToCell(0, i + 1, 3, 0);
  4590. builder.Write(DeleClientList[i].Company);
  4591. builder.MoveToCell(0, i + 1, 4, 0);
  4592. builder.Write(DeleClientList[i].Job);
  4593. }
  4594. //删除多余行
  4595. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4596. {
  4597. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4598. }
  4599. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4600. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4601. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4602. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4603. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4604. return Ok(JsonView(true, "成功", new { Url = url }));
  4605. }
  4606. }
  4607. return Ok(JsonView(false, "操作失败!"));
  4608. }
  4609. catch (Exception ex)
  4610. {
  4611. return Ok(JsonView(false, ex.Message));
  4612. }
  4613. }
  4614. /// <summary>
  4615. /// 获取三公费用标准city
  4616. /// </summary>
  4617. /// <param name="placeData"></param>
  4618. /// <param name="nationalTravelFeeId"></param>
  4619. /// <returns></returns>
  4620. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4621. {
  4622. string _city = string.Empty;
  4623. if (placeData.Count < 1) return _city;
  4624. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4625. if (data == null) return _city;
  4626. string country = data.Country;
  4627. string city = data.City;
  4628. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4629. else _city = city;
  4630. return _city;
  4631. }
  4632. /// <summary>
  4633. /// 团组模块 - 出入境费用 - 明细表导出
  4634. /// </summary>
  4635. /// <returns></returns>
  4636. [HttpPost]
  4637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4638. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4639. {
  4640. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4641. if (data.Code != 0)
  4642. {
  4643. return Ok(JsonView(false, data.Msg));
  4644. }
  4645. return Ok(JsonView(true, data.Msg, data.Data));
  4646. }
  4647. /// <summary>
  4648. /// 团组模块 - 出入境费用 - 一键清空
  4649. /// </summary>
  4650. /// <returns></returns>
  4651. [HttpPost]
  4652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4653. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4654. {
  4655. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4656. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4657. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4658. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4659. if (_view.Code == 0)
  4660. {
  4661. return Ok(JsonView(true, "操作成功"));
  4662. }
  4663. return Ok(JsonView(false, "操作失败"));
  4664. }
  4665. /// <summary>
  4666. /// 团组模块 - 出入境费用 - 子项删除
  4667. /// </summary>
  4668. /// <returns></returns>
  4669. [HttpPost]
  4670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4671. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4672. {
  4673. try
  4674. {
  4675. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4676. if (data.Code != 0)
  4677. {
  4678. return Ok(JsonView(false, data.Msg));
  4679. }
  4680. return Ok(JsonView(true, "操作成功!", data.Data));
  4681. }
  4682. catch (Exception ex)
  4683. {
  4684. return Ok(JsonView(false, ex.Message));
  4685. }
  4686. }
  4687. /// <summary>
  4688. /// 团组模块 - 出入境国家费用标准 List
  4689. /// </summary>
  4690. /// <returns></returns>
  4691. [HttpPost]
  4692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4693. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4694. {
  4695. try
  4696. {
  4697. Stopwatch sw = new Stopwatch();
  4698. sw.Start();
  4699. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4700. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4701. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4702. Where gntf.Isdel = 0");
  4703. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4704. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4705. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4706. //foreach (var item in nationalTravel)
  4707. //{
  4708. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4709. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4710. // if (otherData != null)
  4711. // {
  4712. // cityData.Remove(otherData);
  4713. // cityData.Add(otherData);
  4714. // }
  4715. // nationalTravelFeeData1.Add(new
  4716. // {
  4717. // Country = item.Country,
  4718. // CityData = cityData
  4719. // });
  4720. //}
  4721. sw.Stop();
  4722. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4723. }
  4724. catch (Exception ex)
  4725. {
  4726. return Ok(JsonView(false, ex.Message));
  4727. throw;
  4728. }
  4729. }
  4730. /// <summary>
  4731. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4732. /// </summary>
  4733. /// <returns></returns>
  4734. [HttpPost]
  4735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4736. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4737. {
  4738. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4739. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4740. List<string> countryData = new List<string>();
  4741. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4742. countryData = countryData.Distinct().ToList();
  4743. List<dynamic> dataSource = new List<dynamic>();
  4744. foreach (var item in countryData)
  4745. {
  4746. List<string> cityData1 = new List<string>();
  4747. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4748. var countryData2 = new
  4749. {
  4750. CountryName = item,
  4751. CityData = cityData1
  4752. };
  4753. dataSource.Add(countryData2);
  4754. }
  4755. return Ok(JsonView(true, "查询成功!", dataSource));
  4756. }
  4757. /// <summary>
  4758. /// 团组模块 - 出入境国家费用标准 Page List
  4759. /// </summary>
  4760. /// <returns></returns>
  4761. [HttpPost]
  4762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4763. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4764. {
  4765. int portId = dto.PortType;
  4766. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4767. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4768. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4769. string whereSql = string.Empty;
  4770. if (!string.IsNullOrEmpty(dto.Country))
  4771. {
  4772. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4773. }
  4774. if (!string.IsNullOrEmpty(dto.City))
  4775. {
  4776. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4777. }
  4778. string pageSql = string.Format(@"Select * From (
  4779. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4780. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4781. From Grp_NationalTravelFee gntf
  4782. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4783. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4784. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4785. RefAsync<int> total = 0;
  4786. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4787. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4788. }
  4789. /// <summary>
  4790. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4791. /// </summary>
  4792. /// <returns></returns>
  4793. [HttpPost]
  4794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4795. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4796. {
  4797. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4798. int portId = dto.PortType;
  4799. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4800. string whereSql = string.Empty;
  4801. if (!string.IsNullOrEmpty(dto.Country))
  4802. {
  4803. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4804. }
  4805. if (!string.IsNullOrEmpty(dto.City))
  4806. {
  4807. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4808. }
  4809. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4810. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4811. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4812. From Grp_NationalTravelFee gntf
  4813. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4814. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4815. Where gntf.Isdel = 0 {0} ", whereSql);
  4816. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4817. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4818. }
  4819. /// <summary>
  4820. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4821. /// </summary>
  4822. /// <returns></returns>
  4823. [HttpPost]
  4824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4825. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4826. {
  4827. try
  4828. {
  4829. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4830. if (data.Code != 0)
  4831. {
  4832. return Ok(JsonView(false, data.Msg));
  4833. }
  4834. return Ok(JsonView(true, "操作成功!", data.Data));
  4835. }
  4836. catch (Exception ex)
  4837. {
  4838. return Ok(JsonView(false, ex.Message));
  4839. }
  4840. }
  4841. /// <summary>
  4842. /// 团组模块 - 出入境国家费用标准 - Del
  4843. /// </summary>
  4844. /// <returns></returns>
  4845. [HttpPost]
  4846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4847. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4848. {
  4849. try
  4850. {
  4851. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4852. {
  4853. Id = dto.Id,
  4854. DeleteUserId = dto.DeleteUserId,
  4855. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4856. IsDel = 1
  4857. };
  4858. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4859. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4860. .WhereColumns(it => new { it.Id })
  4861. .ExecuteCommandAsync();
  4862. if (delStatus <= 0)
  4863. {
  4864. return Ok(JsonView(false, "删除失败!"));
  4865. }
  4866. return Ok(JsonView(true, "操作成功!"));
  4867. }
  4868. catch (Exception ex)
  4869. {
  4870. return Ok(JsonView(false, ex.Message));
  4871. }
  4872. }
  4873. #endregion
  4874. #region 签证费用录入
  4875. /// <summary>
  4876. /// 根据diid查询签证费用列表
  4877. /// </summary>
  4878. /// <param name="dto"></param>
  4879. /// <returns></returns>
  4880. [HttpPost]
  4881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4882. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4883. {
  4884. try
  4885. {
  4886. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4887. if (groupData.Code != 0)
  4888. {
  4889. return Ok(JsonView(false, groupData.Msg));
  4890. }
  4891. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4892. }
  4893. catch (Exception ex)
  4894. {
  4895. return Ok(JsonView(false, ex.Message));
  4896. }
  4897. }
  4898. /// <summary>
  4899. /// 根据签证费用Id查询单条数据及c表数据
  4900. /// </summary>
  4901. /// <param name="dto"></param>
  4902. /// <returns></returns>
  4903. [HttpPost]
  4904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4905. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4906. {
  4907. try
  4908. {
  4909. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4910. if (groupData.Code != 0)
  4911. {
  4912. return Ok(JsonView(false, groupData.Msg));
  4913. }
  4914. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4915. }
  4916. catch (Exception ex)
  4917. {
  4918. return Ok(JsonView(false, ex.Message));
  4919. }
  4920. }
  4921. /// <summary>
  4922. /// 签证费用删除
  4923. /// </summary>
  4924. /// <param name="dto"></param>
  4925. /// <returns></returns>
  4926. [HttpPost]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4929. {
  4930. _sqlSugar.BeginTran();
  4931. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4932. if (!res)
  4933. {
  4934. _sqlSugar.RollbackTran();
  4935. return Ok(JsonView(false, "删除失败"));
  4936. }
  4937. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4938. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4939. .SetColumns(a => new Grp_CreditCardPayment()
  4940. {
  4941. IsDel = 1,
  4942. DeleteUserId = dto.DeleteUserId,
  4943. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4944. }).ExecuteCommand();
  4945. if (resSub < 1)
  4946. {
  4947. _sqlSugar.RollbackTran();
  4948. return Ok(JsonView(false, "删除失败"));
  4949. }
  4950. _sqlSugar.CommitTran();
  4951. return Ok(JsonView(true, "删除成功!"));
  4952. }
  4953. /// <summary>
  4954. /// 签证费用录入下拉框初始化
  4955. /// </summary>
  4956. /// <returns></returns>
  4957. [HttpPost]
  4958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4959. public async Task<IActionResult> VisaPriceAddSelect()
  4960. {
  4961. try
  4962. {
  4963. //支付方式
  4964. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4965. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4966. //币种
  4967. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4968. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4969. //乘客类型
  4970. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4971. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4972. //卡类型
  4973. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4974. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4975. var data = new
  4976. {
  4977. Payment = _Payment,
  4978. CurrencyList = _CurrencyList,
  4979. PassengerType = _PassengerType,
  4980. BankCard = _BankCard
  4981. };
  4982. return Ok(JsonView(true, "查询成功!", data));
  4983. }
  4984. catch (Exception ex)
  4985. {
  4986. return Ok(JsonView(false, "程序错误!"));
  4987. throw;
  4988. }
  4989. }
  4990. /// <summary>
  4991. /// 签证费用录入操作(Status:1.新增,2.修改)
  4992. /// </summary>
  4993. /// <param name="dto"></param>
  4994. /// <returns></returns>
  4995. [HttpPost]
  4996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4997. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4998. {
  4999. try
  5000. {
  5001. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5002. if (groupData.Code != 0)
  5003. {
  5004. return Ok(JsonView(false, groupData.Msg));
  5005. }
  5006. #region 应用推送
  5007. try
  5008. {
  5009. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5010. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5011. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5012. }
  5013. catch (Exception ex)
  5014. {
  5015. }
  5016. #endregion
  5017. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5018. }
  5019. catch (Exception ex)
  5020. {
  5021. return Ok(JsonView(false, ex.Message));
  5022. }
  5023. }
  5024. #endregion
  5025. #region op费用录入
  5026. /// <summary>
  5027. /// 根据diid查询op费用列表
  5028. /// </summary>
  5029. /// <param name="dto"></param>
  5030. /// <returns></returns>
  5031. [HttpPost]
  5032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5033. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5034. {
  5035. try
  5036. {
  5037. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5038. if (groupData.Code != 0)
  5039. {
  5040. return Ok(JsonView(false, groupData.Msg));
  5041. }
  5042. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5043. }
  5044. catch (Exception ex)
  5045. {
  5046. return Ok(JsonView(false, ex.Message));
  5047. }
  5048. }
  5049. /// <summary>
  5050. /// 根据op费用Id查询单条数据及c表数据
  5051. /// </summary>
  5052. /// <param name="dto"></param>
  5053. /// <returns></returns>
  5054. [HttpPost]
  5055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5056. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5057. {
  5058. try
  5059. {
  5060. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5061. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5062. var data = new
  5063. {
  5064. CarTouristGuideGround = _groupData,
  5065. CreditCardPayment = _creditCardPayment
  5066. };
  5067. return Ok(JsonView(true, "查询成功!", data));
  5068. }
  5069. catch (Exception ex)
  5070. {
  5071. return Ok(JsonView(false, "程序错误!"));
  5072. }
  5073. }
  5074. /// <summary>
  5075. /// op费用删除
  5076. /// </summary>
  5077. /// <param name="dto"></param>
  5078. /// <returns></returns>
  5079. [HttpPost]
  5080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5081. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5082. {
  5083. try
  5084. {
  5085. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5086. if (!res)
  5087. {
  5088. return Ok(JsonView(false, "删除失败"));
  5089. }
  5090. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5091. {
  5092. IsDel = 1,
  5093. DeleteUserId = dto.DeleteUserId,
  5094. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5095. }).ExecuteCommandAsync();
  5096. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5097. {
  5098. IsDel = 1,
  5099. DeleteUserId = dto.DeleteUserId,
  5100. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5101. }).ExecuteCommandAsync();
  5102. return Ok(JsonView(true, "删除成功!"));
  5103. }
  5104. catch (Exception ex)
  5105. {
  5106. return Ok(JsonView(false, "程序错误!"));
  5107. throw;
  5108. }
  5109. }
  5110. /// <summary>
  5111. /// op费用录入操作(Status:1.新增,2.修改)
  5112. /// </summary>
  5113. /// <param name="dto"></param>
  5114. /// <returns></returns>
  5115. [HttpPost]
  5116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5117. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5118. {
  5119. try
  5120. {
  5121. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5122. if (groupData.Code != 0)
  5123. {
  5124. return Ok(JsonView(false, groupData.Msg));
  5125. }
  5126. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5127. }
  5128. catch (Exception ex)
  5129. {
  5130. return Ok(JsonView(false, ex.Message));
  5131. }
  5132. }
  5133. /// <summary>
  5134. /// 填写费用详细页面初始化绑定
  5135. /// </summary>
  5136. /// <param name="dto"></param>
  5137. /// <returns></returns>
  5138. [HttpPost]
  5139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5140. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5141. {
  5142. try
  5143. {
  5144. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5145. if (groupData.Code != 0)
  5146. {
  5147. return Ok(JsonView(false, groupData.Msg));
  5148. }
  5149. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5150. }
  5151. catch (Exception ex)
  5152. {
  5153. return Ok(JsonView(false, ex.Message));
  5154. }
  5155. }
  5156. /// <summary>
  5157. /// 根据op费用Id查询详细数据
  5158. /// </summary>
  5159. /// <param name="dto"></param>
  5160. /// <returns></returns>
  5161. [HttpPost]
  5162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5163. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5164. {
  5165. try
  5166. {
  5167. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5168. if (groupData.Code != 0)
  5169. {
  5170. return Ok(JsonView(false, groupData.Msg));
  5171. }
  5172. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5173. }
  5174. catch (Exception ex)
  5175. {
  5176. return Ok(JsonView(false, ex.Message));
  5177. }
  5178. }
  5179. /// <summary>
  5180. /// OP费用录入填写详情
  5181. /// </summary>
  5182. /// <param name="dto"></param>
  5183. /// <returns></returns>
  5184. [HttpPost]
  5185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5186. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5187. {
  5188. try
  5189. {
  5190. #region 参数校验
  5191. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5192. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5193. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5194. #endregion
  5195. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5196. if (groupData.Code != 0)
  5197. {
  5198. return Ok(JsonView(false, groupData.Msg));
  5199. }
  5200. //自动审核
  5201. await _feeAuditRep.FeeAutomaticAudit(2,dto.DiId,dto.CTGGRId);
  5202. #region 应用推送
  5203. try
  5204. {
  5205. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5206. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5207. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5208. }
  5209. catch (Exception ex)
  5210. {
  5211. }
  5212. #endregion
  5213. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5214. }
  5215. catch (Exception ex)
  5216. {
  5217. return Ok(JsonView(false, ex.Message));
  5218. }
  5219. }
  5220. /// <summary>
  5221. /// 获取三公详细所有城市
  5222. /// </summary>
  5223. /// <returns></returns>
  5224. [HttpGet]
  5225. public IActionResult OpCarCityResult()
  5226. {
  5227. var jw = JsonView(false);
  5228. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5229. {
  5230. x.Id,
  5231. x.Country,
  5232. x.City,
  5233. }).ToList();
  5234. if (data.Count > 0)
  5235. {
  5236. jw = JsonView(true, "获取成功!", data);
  5237. }
  5238. else
  5239. {
  5240. jw.Msg = "城市数据为空!";
  5241. jw.Data = new string[0];
  5242. }
  5243. return Ok(jw);
  5244. }
  5245. /// <summary>
  5246. /// 导出地接费用明细
  5247. /// </summary>
  5248. /// <param name="dto"></param>
  5249. /// <returns></returns>
  5250. [HttpPost]
  5251. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5252. {
  5253. var jw = JsonView(false);
  5254. if (dto.Diid < 1)
  5255. {
  5256. jw.Msg = "请输入正确的diid!";
  5257. return Ok(jw);
  5258. }
  5259. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5260. if (group == null)
  5261. {
  5262. jw.Msg = "未找到团组信息!";
  5263. return Ok(jw);
  5264. }
  5265. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5266. if (localGuideArr.Count == 0)
  5267. {
  5268. jw.Msg = "该团组暂无地接信息!";
  5269. return Ok(jw);
  5270. }
  5271. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5272. var overspendSoure = new Dictionary<int, int>
  5273. {
  5274. { 91, 982 }, //车
  5275. { 92 , 1059} ,//导游
  5276. { 994 , 1073}, //翻译
  5277. { 988 , 1074 }, //早餐
  5278. { 93 , 1075 }, //午餐
  5279. { 989 , 1076 }, //晚餐
  5280. };
  5281. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5282. foreach (var groupArr in localGroup)
  5283. {
  5284. var keyValue = groupArr.Key;
  5285. if (int.TryParse(keyValue, out int cityid))
  5286. {
  5287. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5288. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5289. }
  5290. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5291. foreach (var item in groupArr)
  5292. {
  5293. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5294. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5295. new Grp_CarTouristGuideGroundReservationsContentExtend
  5296. {
  5297. Count = a.Count,
  5298. CreateTime = a.CreateTime,
  5299. CreateUserId = a.CreateUserId,
  5300. CTGGRId = a.CTGGRId,
  5301. Currency = a.Currency,
  5302. DatePrice = a.DatePrice,
  5303. DeleteTime = a.DeleteTime,
  5304. DeleteUserId = a.DeleteUserId,
  5305. DiId = a.DiId,
  5306. Id = a.Id,
  5307. IsDel = a.IsDel,
  5308. Price = a.Price,
  5309. PriceContent = a.PriceContent,
  5310. Remark = a.Remark,
  5311. SId = a.SId,
  5312. SidName = b.Name,
  5313. Units = a.Units,
  5314. }
  5315. ).ToList();
  5316. if (content.Count > 0)
  5317. {
  5318. contentArr.Add(content);
  5319. }
  5320. }
  5321. //open excel
  5322. //set excel
  5323. //save excel
  5324. try
  5325. {
  5326. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5327. IWorkbook workbook;
  5328. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5329. {
  5330. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5331. }
  5332. else
  5333. {
  5334. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5335. }
  5336. ISheet sheet = workbook.GetSheetAt(0);
  5337. var rowStartIndex = 2;
  5338. var clounmCount = 10;
  5339. var initStyleRow = sheet.GetRow(2);
  5340. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5341. //var overspendArrDetail =
  5342. var existsId = new List<CarCompare>();
  5343. var lastElem = arr.Last();
  5344. var thisSid = -1;
  5345. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5346. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5347. {
  5348. Name = "未知币种!",
  5349. Remark = "未知币种!",
  5350. };
  5351. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5352. Action cloneRowFn = () =>
  5353. {
  5354. rowStartIndex++;
  5355. var cloneRow = sheet.CreateRow(rowStartIndex);
  5356. // 复制样式
  5357. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5358. {
  5359. ICell sourceCell = initStyleRow.GetCell(i);
  5360. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5361. // 确保单元格存在样式
  5362. if (sourceCell.CellStyle != null)
  5363. {
  5364. targetCell.CellStyle = sourceCell.CellStyle;
  5365. }
  5366. }
  5367. };
  5368. var mergeRow = () =>
  5369. {
  5370. for (int i = 2; i < sheet.LastRowNum; i++)
  5371. {
  5372. var row = sheet.GetRow(i);
  5373. var cellFirst = row.GetCell(0);
  5374. var thisIndex = i + 1;
  5375. while (thisIndex < sheet.LastRowNum)
  5376. {
  5377. var nextRow = sheet.GetRow(thisIndex);
  5378. var nextCellFirst = nextRow.GetCell(0);
  5379. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5380. {
  5381. thisIndex++;
  5382. }
  5383. else
  5384. {
  5385. break;
  5386. }
  5387. }
  5388. thisIndex--;
  5389. if (thisIndex != i)
  5390. {
  5391. //合并row
  5392. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5393. i, // 起始行索引(0-based)
  5394. thisIndex, // 结束行索引(0-based)
  5395. 0, // 起始列索引(0-based)
  5396. 0 // 结束列索引(0-based)
  5397. );
  5398. sheet.AddMergedRegion(cellRangeAddress);
  5399. i = thisIndex;
  5400. }
  5401. }
  5402. };
  5403. var chaoshiNumber = 0;
  5404. var totalNumber = 0.00M;
  5405. string lastStr = "";
  5406. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5407. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5408. {
  5409. b.IsAuditGM,
  5410. x.Id,
  5411. x.Area,
  5412. b.PayPercentage,
  5413. b.PayMoney,
  5414. }).ToList();
  5415. string yesPayment = "", noPayment = "";
  5416. foreach (var item in queryCarArrByCityAndDiid)
  5417. {
  5418. if (item.IsAuditGM == 1)
  5419. {
  5420. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5421. }
  5422. else
  5423. {
  5424. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5425. }
  5426. }
  5427. lastStr = yesPayment + noPayment;
  5428. foreach (var item in arr)
  5429. {
  5430. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5431. {
  5432. if (thisSid != item.SId)
  5433. {
  5434. if (thisSid == -1)
  5435. {
  5436. thisSid = item.SId;
  5437. }
  5438. else
  5439. {
  5440. //合并小计行
  5441. //创建合并区域的实例
  5442. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5443. rowStartIndex, // 起始行索引(0-based)
  5444. rowStartIndex, // 结束行索引(0-based)
  5445. 0, // 起始列索引(0-based)
  5446. 3 // 结束列索引(0-based)
  5447. );
  5448. sheet.AddMergedRegion(cellRangeAddress);
  5449. var CellStyle = workbook.CreateCellStyle();
  5450. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5451. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5452. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5453. for (int i = 0; i <= clounmCount; i++)
  5454. {
  5455. if (i > 6)
  5456. {
  5457. var CellStyle1 = workbook.CreateCellStyle();
  5458. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5459. IFont Font = workbook.CreateFont(); // 创建字体
  5460. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5461. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5462. CellStyle1.SetFont(Font);
  5463. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5464. }
  5465. else
  5466. {
  5467. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5468. }
  5469. }
  5470. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5471. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5472. //超时合计
  5473. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5474. //超时数
  5475. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5476. //超时合计费用
  5477. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5478. thisSid = item.SId;
  5479. cloneRowFn();
  5480. chaoshiNumber = 0;
  5481. totalNumber = 0;
  5482. }
  5483. }
  5484. IRow row = sheet.GetRow(rowStartIndex);
  5485. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5486. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5487. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5488. if (isOpenOverspendSoure)
  5489. {
  5490. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5491. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5492. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5493. }
  5494. for (int i = 0; i <= clounmCount; i++)
  5495. {
  5496. var cell = row.GetCell(i);
  5497. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5498. if (cell == null)
  5499. {
  5500. cell = row.CreateCell(i);
  5501. }
  5502. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5503. fontRed.CloneStyleFrom(cell.CellStyle);
  5504. IFont Font = workbook.CreateFont(); // 创建字体
  5505. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5506. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5507. fontRed.SetFont(Font);
  5508. byte[] rgb = new byte[3] { 255, 242, 204 };
  5509. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5510. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5511. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5512. if (workbook is XSSFWorkbook)
  5513. {
  5514. BackgroundColor255_242_204.FillForegroundColor = 0;
  5515. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5516. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5517. }
  5518. else
  5519. {
  5520. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5521. }
  5522. if (i == 1 || i > 6)
  5523. {
  5524. if (i > 6)
  5525. {
  5526. fontRed.FillForegroundColor = 0;
  5527. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5528. fontRed.FillPattern = FillPattern.SolidForeground;
  5529. }
  5530. cell.CellStyle = fontRed;
  5531. }
  5532. if (i > 2 && i < 7)
  5533. {
  5534. cell.CellStyle = BackgroundColor255_242_204;
  5535. }
  5536. cell.SetCellValue(setCellValue); //写入单元格
  5537. }
  5538. if (overspendSoure.ContainsKey(thisSid)) {
  5539. var overspendId = overspendSoure[thisSid];
  5540. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5541. }
  5542. cloneRowFn();
  5543. existsId.Add(new CarCompare
  5544. {
  5545. DataPrice = item.DatePrice.ObjToDate(),
  5546. Sid = item.SId
  5547. });
  5548. }
  5549. if (item.Equals(lastElem))
  5550. {
  5551. //合并小计行
  5552. //创建合并区域的实例
  5553. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5554. rowStartIndex, // 起始行索引(0-based)
  5555. rowStartIndex, // 结束行索引(0-based)
  5556. 0, // 起始列索引(0-based)
  5557. 3 // 结束列索引(0-based)
  5558. );
  5559. sheet.AddMergedRegion(cellRangeAddress);
  5560. var CellStyle = workbook.CreateCellStyle();
  5561. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5562. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5563. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5564. for (int i = 0; i <= clounmCount; i++)
  5565. {
  5566. if (i > 6)
  5567. {
  5568. var CellStyle1 = workbook.CreateCellStyle();
  5569. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5570. IFont Font = workbook.CreateFont(); // 创建字体
  5571. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5572. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5573. CellStyle1.SetFont(Font);
  5574. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5575. }
  5576. else
  5577. {
  5578. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5579. }
  5580. }
  5581. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5582. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5583. //超时合计
  5584. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5585. //超时数
  5586. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5587. //超时合计费用
  5588. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5589. cloneRowFn();
  5590. // 创建合并区域的实例
  5591. cellRangeAddress = new CellRangeAddress(
  5592. rowStartIndex, // 起始行索引(0-based)
  5593. rowStartIndex, // 结束行索引(0-based)
  5594. 0, // 起始列索引(0-based)
  5595. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5596. );
  5597. // 添加合并区域
  5598. sheet.AddMergedRegion(cellRangeAddress);
  5599. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5600. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5601. }
  5602. }
  5603. mergeRow();
  5604. // 保存修改后的Excel文件到新文件
  5605. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5606. // new FileStream(newFilePath, FileMode.CreateNew)
  5607. using (var stream = new MemoryStream())
  5608. {
  5609. workbook.Write(stream, true);
  5610. stream.Flush();
  5611. stream.Seek(0, SeekOrigin.Begin);
  5612. MemoryStream memoryStream = new MemoryStream();
  5613. stream.CopyTo(memoryStream);
  5614. memoryStream.Seek(0, SeekOrigin.Begin);
  5615. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5616. }
  5617. workbook.Close();
  5618. workbook.Dispose();
  5619. }
  5620. catch (Exception ex)
  5621. {
  5622. jw.Msg = "出现异常!" + ex.Message;
  5623. return Ok(jw);
  5624. }
  5625. }
  5626. if (Zips.Count > 0)
  5627. {
  5628. IOOperatorHelper io = new IOOperatorHelper();
  5629. var byts = io.ConvertZipStream(Zips);
  5630. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5631. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5632. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5633. }
  5634. else
  5635. {
  5636. jw.Msg = "暂无生成文件!";
  5637. }
  5638. return Ok(jw);
  5639. }
  5640. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5641. {
  5642. string outStr = string.Empty;
  5643. switch (i)
  5644. {
  5645. case 0:
  5646. outStr = arr[0].SidName;
  5647. break;
  5648. case 1:
  5649. outStr = arr[0].DataPriceStr;
  5650. break;
  5651. case 2:
  5652. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5653. break;
  5654. case 4:
  5655. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5656. break;
  5657. case 7:
  5658. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5659. {
  5660. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5661. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5662. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5663. }
  5664. break;
  5665. case 8:
  5666. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5667. {
  5668. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5669. }
  5670. break;
  5671. case 9:
  5672. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5673. {
  5674. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5675. }
  5676. break;
  5677. case 10:
  5678. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5679. {
  5680. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5681. }
  5682. break;
  5683. }
  5684. return outStr;
  5685. }
  5686. #region OP行程单
  5687. /// <summary>
  5688. /// OP行程单初始化
  5689. /// </summary>
  5690. /// <param name="dto"></param>
  5691. /// <returns></returns>
  5692. [HttpPost]
  5693. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5694. {
  5695. var jw = JsonView(false);
  5696. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5697. var group = groupList.First();
  5698. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5699. if (group == null)
  5700. {
  5701. jw.Msg = "暂无团组!";
  5702. return Ok(jw);
  5703. }
  5704. group = groupList.Find(x => x.Id == diid);
  5705. if (group == null)
  5706. {
  5707. jw.Msg = "请输入正确的团组ID!";
  5708. return Ok(jw);
  5709. }
  5710. string city = string.Empty;
  5711. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5712. if (blackCode.Count > 0)
  5713. {
  5714. var black = blackCode.First();
  5715. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5716. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5717. if (blackSp.Length > 0)
  5718. {
  5719. try
  5720. {
  5721. var cityArrCode = new List<string>(20);
  5722. foreach (var item in blackSp)
  5723. {
  5724. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5725. var IndexSelect = itemSp[2];
  5726. var cityArrCodeLength = cityArrCode.Count - 1;
  5727. var startCity = IndexSelect.Substring(0, 3);
  5728. if (cityArrCodeLength > 0)
  5729. {
  5730. var arrEndCity = cityArrCode[cityArrCodeLength];
  5731. if (arrEndCity != startCity)
  5732. {
  5733. cityArrCode.Add(startCity.ToUpper());
  5734. }
  5735. }
  5736. else
  5737. {
  5738. cityArrCode.Add(startCity.ToUpper());
  5739. }
  5740. var endCity = IndexSelect.Substring(3, 3);
  5741. cityArrCode.Add(endCity.ToUpper());
  5742. }
  5743. var cityThree = string.Empty;
  5744. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5745. cityThree = cityThree.TrimEnd(',');
  5746. if (string.IsNullOrWhiteSpace(cityThree))
  5747. {
  5748. throw new
  5749. Exception("error");
  5750. }
  5751. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5752. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5753. foreach (var item in cityArrCode)
  5754. {
  5755. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5756. if (find != null)
  5757. {
  5758. city += find.City + "/";
  5759. }
  5760. else
  5761. {
  5762. city += item + "三字码未收入/";
  5763. }
  5764. }
  5765. city = city.TrimEnd('/');
  5766. }
  5767. catch (Exception e)
  5768. {
  5769. city = "黑屏代码格式不正确!";
  5770. }
  5771. }
  5772. }
  5773. else
  5774. {
  5775. city = "未录入黑屏代码";
  5776. }
  5777. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5778. {
  5779. Date = x.Date,
  5780. Days = x.Days,
  5781. Diffgroup = x.Diffgroup,
  5782. Diid = x.Diid,
  5783. Traffic_First = x.Traffic_First,
  5784. Traffic_Second = x.Traffic_Second,
  5785. Trip = x.Trip,
  5786. WeekDay = x.WeekDay,
  5787. Id = x.Id
  5788. }).ToList();
  5789. jw.Data = new
  5790. {
  5791. groupList = groupList.Select(x => new
  5792. {
  5793. x.Id,
  5794. x.TeamName,
  5795. x.TourCode
  5796. }).ToList(),
  5797. groupInfo = new
  5798. {
  5799. group.VisitDays,
  5800. group.TourCode,
  5801. group.VisitPNumber,
  5802. group.TeamName,
  5803. city
  5804. },
  5805. OpTravelList
  5806. };
  5807. jw.Code = 200;
  5808. jw.Msg = "操作成功!";
  5809. return Ok(jw);
  5810. }
  5811. /// <summary>
  5812. /// 删除团组行程单
  5813. /// </summary>
  5814. /// <returns></returns>
  5815. [HttpPost]
  5816. public IActionResult DelTravel(DelOpTravelDto dto)
  5817. {
  5818. var jw = JsonView(false);
  5819. if (dto.UserId <= 0 || dto.Diid <= 0)
  5820. {
  5821. jw.Msg = "请输入正确的参数!";
  5822. return Ok(jw);
  5823. }
  5824. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5825. .SetColumns(x => new Grp_TravelList
  5826. {
  5827. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5828. DeleteUserId = dto.UserId,
  5829. IsDel = 1,
  5830. }).ExecuteCommand();
  5831. jw = JsonView(true);
  5832. return Ok(jw);
  5833. }
  5834. /// <summary>
  5835. /// 行程单保存
  5836. /// </summary>
  5837. /// <returns></returns>
  5838. [HttpPost]
  5839. public IActionResult TravelSave(TravelSaveDto dto)
  5840. {
  5841. var jw = JsonView(false);
  5842. if (dto.Arr.Count > 0)
  5843. {
  5844. try
  5845. {
  5846. _sqlSugar.BeginTran();
  5847. foreach (var item in dto.Arr)
  5848. {
  5849. if (item.Id == 0)
  5850. {
  5851. throw new Exception("请传入正确的Id");
  5852. }
  5853. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5854. .SetColumns(x => new Grp_TravelList
  5855. {
  5856. Trip = item.Trip
  5857. }).ExecuteCommand();
  5858. }
  5859. _sqlSugar.CommitTran();
  5860. jw = JsonView(true);
  5861. }
  5862. catch (Exception ex)
  5863. {
  5864. _sqlSugar.RollbackTran();
  5865. jw.Msg = "程序异常!" + ex.Message;
  5866. }
  5867. }
  5868. else
  5869. {
  5870. jw.Msg = "请传入正确的参数!";
  5871. }
  5872. return Ok(jw);
  5873. }
  5874. /// <summary>
  5875. /// 导出行程单
  5876. /// </summary>
  5877. /// <param name="dto"></param>
  5878. /// <returns></returns>
  5879. [HttpPost]
  5880. public IActionResult ExportTravel(ExportTravelDto dto)
  5881. {
  5882. var jw = JsonView(false);
  5883. int diid = 0;
  5884. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5885. if (Find == null)
  5886. {
  5887. jw.Msg = "请选择正确的团组!";
  5888. return Ok(jw);
  5889. }
  5890. else
  5891. {
  5892. diid = Find.Id;
  5893. }
  5894. //数据源
  5895. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5896. DataTable dtBlack = null;
  5897. try
  5898. {
  5899. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  5900. }
  5901. catch (Exception)
  5902. {
  5903. jw.Msg = "机票黑屏代码有误!";
  5904. return Ok(jw);
  5905. }
  5906. string CityStr = string.Empty;
  5907. if (dtBlack.Rows.Count == 0)
  5908. {
  5909. jw.Msg = "机票黑屏代码有误!";
  5910. return Ok(jw);
  5911. }
  5912. else
  5913. {
  5914. foreach (DataRow row in dtBlack.Rows)
  5915. {
  5916. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  5917. {
  5918. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  5919. return Ok(jw);
  5920. }
  5921. }
  5922. CityStr = GeneralMethod.GetGroupCityLine(diid,"/");
  5923. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  5924. }
  5925. //创建数据源Table
  5926. DataTable dtSource = new DataTable();
  5927. dtSource.Columns.Add("Days", typeof(string));
  5928. dtSource.Columns.Add("Date", typeof(string));
  5929. dtSource.Columns.Add("Week", typeof(string));
  5930. dtSource.Columns.Add("Traffic", typeof(string));
  5931. dtSource.Columns.Add("Trip", typeof(string));
  5932. //获取数据,放到datatable
  5933. foreach (var item in _travelList)
  5934. {
  5935. DataRow dr = dtSource.NewRow();
  5936. dr["Days"] = item.Days;
  5937. dr["Date"] = item.Date;
  5938. dr["Week"] = item.WeekDay;
  5939. dr["Traffic"] = item.Traffic_First
  5940. + "\r\n"
  5941. + item.Traffic_Second;
  5942. dr["Trip"] = item.Trip;
  5943. dtSource.Rows.Add(dr);
  5944. }
  5945. Dictionary<string, string> dic = new Dictionary<string, string>();
  5946. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5947. dic.Add("City", CityStr);
  5948. dic.Add("Days", Find.VisitDays.ToString());
  5949. dic.Add("DeleCode", Find.TourCode);
  5950. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5951. //模板路径
  5952. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5953. //载入模板
  5954. Document doc = null;
  5955. DocumentBuilder builder = null;
  5956. try
  5957. {
  5958. //载入模板
  5959. doc = new Document(tempPath);
  5960. builder = new DocumentBuilder(doc);
  5961. }
  5962. catch (Exception)
  5963. {
  5964. jw.Msg = "模板位置不存在!";
  5965. return Ok(jw);
  5966. }
  5967. foreach (var key in dic.Keys)
  5968. {
  5969. Bookmark bookmark = doc.Range.Bookmarks[key];
  5970. if (bookmark != null)
  5971. {
  5972. builder.MoveToBookmark(key);
  5973. builder.Write(dic[key]);
  5974. }
  5975. }
  5976. //获取word里所有表格
  5977. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5978. //获取所填表格的序数
  5979. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5980. try
  5981. {
  5982. //循环赋值
  5983. for (int i = 0; i < dtSource.Rows.Count; i++)
  5984. {
  5985. builder.MoveToCell(0, i + 1, 0, 0);
  5986. builder.Write(dtSource.Rows[i]["Days"].ToString());
  5987. builder.MoveToCell(0, i + 1, 1, 0);
  5988. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  5989. builder.MoveToCell(0, i + 1, 2, 0);
  5990. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  5991. var trip = dtSource.Rows[i]["Trip"].ToString();
  5992. builder.MoveToCell(0, i + 1, 3, 0);
  5993. builder.Write(trip);
  5994. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  5995. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  5996. // 获取特定索引的段落
  5997. Paragraph paragraph = (Paragraph)paragraphs[0];
  5998. Run run = paragraph.Runs[0];
  5999. Aspose.Words.Font font = run.Font;
  6000. font.Name = "黑体";
  6001. //设置双休红色
  6002. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6003. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6004. paragraph = (Paragraph)paragraphs[1];
  6005. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6006. {
  6007. run = paragraph.Runs[0];
  6008. font = run.Font;
  6009. font.Color = Color.Red;
  6010. }
  6011. }
  6012. }
  6013. catch (Exception ex)
  6014. {
  6015. }
  6016. //删除多余行
  6017. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6018. {
  6019. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6020. }
  6021. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6022. if (!Directory.Exists(savePath))
  6023. {
  6024. try
  6025. {
  6026. Directory.CreateDirectory(savePath);
  6027. }
  6028. catch
  6029. {
  6030. }
  6031. }
  6032. string path = savePath + Find.TeamName + "出访日程.docx";
  6033. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6034. try
  6035. {
  6036. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6037. string postfix = ".docx";
  6038. if (dto.IsPDF)
  6039. {
  6040. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6041. postfix = ".pdf";
  6042. }
  6043. doc.Save(path, saveFormat);
  6044. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6045. }
  6046. catch (Exception)
  6047. {
  6048. jw = JsonView(false);
  6049. }
  6050. return Ok(jw);
  6051. }
  6052. /// <summary>
  6053. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6054. /// </summary>
  6055. /// <param name="num"></param>
  6056. /// <returns></returns>
  6057. string GetNum(string num)
  6058. {
  6059. string str = "";
  6060. switch (num)
  6061. {
  6062. case "1":
  6063. str = "一";
  6064. break;
  6065. case "2":
  6066. str = "二";
  6067. break;
  6068. case "3":
  6069. str = "三";
  6070. break;
  6071. case "4":
  6072. str = "四";
  6073. break;
  6074. case "5":
  6075. str = "五";
  6076. break;
  6077. case "6":
  6078. str = "六";
  6079. break;
  6080. case "7":
  6081. str = "七";
  6082. break;
  6083. case "8":
  6084. str = "八";
  6085. break;
  6086. case "9":
  6087. str = "九";
  6088. break;
  6089. case "10":
  6090. str = "十";
  6091. break;
  6092. case "11":
  6093. str = "十一";
  6094. break;
  6095. case "12":
  6096. str = "十二";
  6097. break;
  6098. case "一":
  6099. str = "1";
  6100. break;
  6101. case "二":
  6102. str = "2";
  6103. break;
  6104. case "三":
  6105. str = "3";
  6106. break;
  6107. case "四":
  6108. str = "4";
  6109. break;
  6110. case "五":
  6111. str = "5";
  6112. break;
  6113. case "六":
  6114. str = "6";
  6115. break;
  6116. case "七":
  6117. str = "7";
  6118. break;
  6119. case "八":
  6120. str = "8";
  6121. break;
  6122. case "九":
  6123. str = "9";
  6124. break;
  6125. case "十":
  6126. str = "10";
  6127. break;
  6128. case "十一":
  6129. str = "11";
  6130. break;
  6131. case "十二":
  6132. str = "12";
  6133. break;
  6134. }
  6135. return str;
  6136. }
  6137. #endregion
  6138. #endregion
  6139. #region 团组成本
  6140. /// <summary>
  6141. /// 团组成本数据初始化
  6142. /// </summary>
  6143. /// <param name="dto"></param>
  6144. /// <returns></returns>
  6145. [HttpPost]
  6146. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6147. {
  6148. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6149. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6150. WHEN COUNT(*) >= 0 THEN 'True'
  6151. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6152. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6153. ").ToList(); //团组列表
  6154. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6155. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6156. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6157. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6158. if (groupinfoValue != null)
  6159. {
  6160. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6161. var spArr = new string[1] { countryArr };
  6162. if (countryArr.Contains("|"))
  6163. {
  6164. spArr = countryArr.Split("|");
  6165. }
  6166. else if (countryArr.Contains("、"))
  6167. {
  6168. spArr = countryArr.Split("、");
  6169. }
  6170. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6171. {
  6172. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6173. if (dbQueryCountry != null)
  6174. {
  6175. visaCountryInfoArr.Add(dbQueryCountry);
  6176. }
  6177. }
  6178. }
  6179. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6180. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6181. var create = _GroupCostRepository.
  6182. CreateGroupCostByBlackCode(dto.Diid);
  6183. if (groupCost.Count == 0 && create.Code == 0)
  6184. {
  6185. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6186. }
  6187. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6188. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6189. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6190. groupCostMap = groupCostMap.Select(x =>
  6191. {
  6192. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6193. {
  6194. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6195. }
  6196. return x;
  6197. }).ToList();
  6198. //GroupCostParameter.Add(new
  6199. // Grp_GroupCostParameter());
  6200. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6201. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6202. return Ok(JsonView(new
  6203. {
  6204. groupList,
  6205. groupInfo,
  6206. groupChecks,
  6207. groupCost = groupCostMap,
  6208. hotelNumber,
  6209. GroupCostParameter = GroupCostParameterMap,
  6210. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6211. {
  6212. x.VisaCountry,
  6213. x.VisaPrice,
  6214. x.Id,
  6215. }).ToList(),
  6216. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6217. blackCodeIsTrue = create.Code == 0 ? true : false,
  6218. hotelIsTrue = hotelIsTrue,
  6219. }));
  6220. }
  6221. /// <summary>
  6222. /// 团组成本信息保存
  6223. /// </summary>
  6224. /// <param name="dto"></param>
  6225. /// <returns></returns>
  6226. [HttpPost]
  6227. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6228. {
  6229. if (dto.Diid <= 0 || dto.Userid <= 0)
  6230. {
  6231. return Ok(JsonView(false));
  6232. }
  6233. JsonView jw = null;
  6234. bool isTrue = false;
  6235. #region 复制团组成本
  6236. //if (dto.Diid == 2581)
  6237. //{
  6238. // dto.Diid = 2599;
  6239. // dto.CheckBoxs.ForEach(x =>
  6240. // {
  6241. // x.Diid = 2599;
  6242. // });
  6243. // dto.GroupCosts.ForEach(x =>
  6244. // {
  6245. // x.Diid = 2599;
  6246. // });
  6247. // dto.CostTypeHotelNumbers.ForEach(x =>
  6248. // {
  6249. // x.Diid = 2599;
  6250. // });
  6251. // dto.GroupCostParameters.ForEach(x =>
  6252. // {
  6253. // x.DiId = 2599;
  6254. // });
  6255. //}
  6256. #endregion
  6257. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6258. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6259. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6260. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6261. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6262. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6263. try
  6264. {
  6265. _sqlSugar.BeginTran();
  6266. isTrue = await _GroupCostRepository.
  6267. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6268. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6269. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6270. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6271. _sqlSugar.CommitTran();
  6272. jw = JsonView(true, "保存成功!", isTrue);
  6273. }
  6274. catch (Exception)
  6275. {
  6276. _sqlSugar.RollbackTran();
  6277. jw = JsonView(false);
  6278. }
  6279. return Ok(jw);
  6280. }
  6281. /// <summary>
  6282. /// 司兼导数据
  6283. /// </summary>
  6284. /// <param name="dto"></param>
  6285. /// <returns></returns>
  6286. [HttpPost]
  6287. public IActionResult GetCarGuides(CarGuidesDto dto)
  6288. {
  6289. JsonView jw = null;
  6290. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6291. jw = JsonView(true, "获取成功!", Data);
  6292. return Ok(jw);
  6293. }
  6294. /// <summary>
  6295. /// 导游数据
  6296. /// </summary>
  6297. /// <param name="dto"></param>
  6298. /// <returns></returns>
  6299. [HttpPost]
  6300. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6301. {
  6302. JsonView jw = null;
  6303. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6304. // 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
  6305. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6306. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6307. jw = JsonView(true, "获取成功!", Data);
  6308. return Ok(jw);
  6309. }
  6310. /// <summary>
  6311. /// 成本车数据
  6312. /// </summary>
  6313. /// <param name="dto"></param>
  6314. /// <returns></returns>
  6315. [HttpPost]
  6316. public IActionResult GetCarInfo(CarGuidesDto dto)
  6317. {
  6318. JsonView jw = null;
  6319. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6320. jw = JsonView(true, "获取成功!", Data);
  6321. return Ok(jw);
  6322. }
  6323. /// <summary>
  6324. /// 景点数据
  6325. /// </summary>
  6326. /// <param name="dto"></param>
  6327. /// <returns></returns>
  6328. [HttpPost]
  6329. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6330. {
  6331. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6332. return Ok(JsonView(true, "获取成功!", Data));
  6333. }
  6334. /// <summary>
  6335. /// 成本通知
  6336. /// </summary>
  6337. /// <param name="dto"></param>
  6338. /// <returns></returns>
  6339. [HttpPost]
  6340. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6341. {
  6342. if (dto.Diid < 0)
  6343. {
  6344. return Ok(JsonView(false));
  6345. }
  6346. JsonView jw = null;
  6347. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6348. if (GroupCostParameter != null)
  6349. {
  6350. int IsShare = 0;
  6351. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6352. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6353. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6354. string msg = string.Empty;
  6355. if (isTrue)
  6356. {
  6357. if (IsShare == 0)
  6358. {
  6359. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6360. }
  6361. else
  6362. {
  6363. #region 企微通知对应岗位用户
  6364. try
  6365. {
  6366. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6367. }
  6368. catch (Exception ex)
  6369. {
  6370. }
  6371. #endregion
  6372. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6373. }
  6374. jw = JsonView(isTrue, msg, new { IsShare });
  6375. }
  6376. else
  6377. {
  6378. msg = "修改失败!";
  6379. jw = JsonView(isTrue, msg);
  6380. }
  6381. }
  6382. else
  6383. {
  6384. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6385. }
  6386. return Ok(jw);
  6387. }
  6388. /// <summary>
  6389. /// 导出报价单
  6390. /// </summary>
  6391. /// <param name="dto"></param>
  6392. /// <returns></returns>
  6393. [HttpPost]
  6394. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6395. {
  6396. if (dto.Diid == 0)
  6397. {
  6398. return Ok(JsonView(false, "请传递团组id"));
  6399. }
  6400. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6401. if (deleInfo.Code != 0)
  6402. {
  6403. return Ok(JsonView(false, "团组信息查询失败!"));
  6404. }
  6405. var di = deleInfo.Data as DelegationInfoWebView;
  6406. if (di != null)
  6407. {
  6408. //文件名
  6409. string strFileName = di.TeamName + "-收款账单.doc";
  6410. //获取模板
  6411. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6412. //载入模板
  6413. Document doc = new Document(tmppath);
  6414. decimal TotalPrice = 0.00M;
  6415. string itemStr = string.Empty;
  6416. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6417. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6418. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6419. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6420. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6421. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6422. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6423. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6424. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6425. foreach (var cost in groupCostType)
  6426. {
  6427. var List = cost.ToList();
  6428. if (cost.Key == "A")
  6429. {
  6430. foreach (var ListItem in List)
  6431. {
  6432. if (ListItem.number > 0)
  6433. {
  6434. if (ListItem.code.Contains("TBR"))
  6435. {
  6436. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6437. }
  6438. else
  6439. {
  6440. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6441. }
  6442. TotalPrice += (ListItem.number * ListItem.price);
  6443. }
  6444. }
  6445. }
  6446. else
  6447. {
  6448. itemStr = itemStr.Insert(0, "A段\r\n");
  6449. itemStr += "B段\r\n";
  6450. foreach (var ListItem in List)
  6451. {
  6452. if (ListItem.number > 0)
  6453. {
  6454. if (ListItem.code.Contains("TBR"))
  6455. {
  6456. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6457. }
  6458. else
  6459. {
  6460. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6461. }
  6462. TotalPrice += (ListItem.number * ListItem.price);
  6463. }
  6464. }
  6465. }
  6466. }
  6467. #region 替换Word模板书签内容
  6468. Dictionary<string, string> marks = new Dictionary<string, string>();
  6469. marks.Add("To", di.ClientUnit);//付款方
  6470. marks.Add("ToTel", di.TellPhone);//付款方电话
  6471. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6472. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6473. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6474. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6475. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6476. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6477. marks.Add("PayItemContent", itemStr);//详细信息
  6478. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6479. #endregion
  6480. ////注
  6481. //if (doc.Range.Bookmarks["Attention"] != null)
  6482. //{
  6483. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6484. // mark.Text = frList[0].Attention;
  6485. //}
  6486. foreach (var item in marks.Keys)
  6487. {
  6488. if (doc.Range.Bookmarks[item] != null)
  6489. {
  6490. Bookmark mark = doc.Range.Bookmarks[item];
  6491. mark.Text = marks[item];
  6492. }
  6493. }
  6494. byte[] bytes = null;
  6495. using (MemoryStream stream = new MemoryStream())
  6496. {
  6497. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6498. bytes = stream.ToArray();
  6499. }
  6500. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6501. return Ok(JsonView(true, "", new
  6502. {
  6503. Data = bytes,
  6504. strFileName,
  6505. }));
  6506. }
  6507. else
  6508. {
  6509. return Ok(JsonView(false, "团组信息不存在!"));
  6510. }
  6511. }
  6512. /// <summary>
  6513. /// 导出团组成本
  6514. /// </summary>
  6515. /// <param name="dto"></param>
  6516. /// <returns></returns>
  6517. [HttpPost]
  6518. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6519. {
  6520. var jw = JsonView(false);
  6521. if (dto.Diid == 0)
  6522. {
  6523. return Ok(JsonView(false, "请传递团组id"));
  6524. }
  6525. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6526. if (deleInfo.Code != 0)
  6527. {
  6528. return Ok(JsonView(false, "团组信息查询失败!"));
  6529. }
  6530. var di = deleInfo.Data as DelegationInfoWebView;
  6531. if (di == null)
  6532. {
  6533. return Ok(JsonView(false, "团组信息查询失败!"));
  6534. }
  6535. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6536. WorkbookDesigner designer = new WorkbookDesigner();
  6537. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6538. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6539. for (int i = 0; i < List_GC.Count; i++)
  6540. {
  6541. GroupCost_Excel gc = new GroupCost_Excel();
  6542. gc.Id = List_GC[i].Id;
  6543. gc.Diid = List_GC[i].Diid.ToString();
  6544. gc.DAY = List_GC[i].DAY;
  6545. string week = "";
  6546. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6547. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6548. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6549. gc.ITIN = List_GC[i].ITIN;
  6550. gc.CarType = List_GC[i].CarType;
  6551. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6552. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6553. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6554. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6555. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6556. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6557. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6558. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6559. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6560. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6561. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6562. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6563. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6564. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6565. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6566. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6567. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6568. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6569. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6570. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6571. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6572. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6573. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6574. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6575. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6576. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6577. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6578. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6579. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6580. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6581. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6582. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6583. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6584. List_GC1.Add(gc);
  6585. }
  6586. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6587. dt.TableName = "TB";
  6588. //报表标题等不用dt的值
  6589. designer.SetDataSource("TeamName", dto.title.TeamName);
  6590. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6591. designer.SetDataSource("Tax", dto.title.Tax);
  6592. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6593. designer.SetDataSource("Currency", dto.title.Currency);
  6594. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6595. designer.SetDataSource("Rate", dto.title.Rate);
  6596. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6597. var Aparams = hotels.Find(x => x.Type == "Default");
  6598. if (Aparams == null)
  6599. {
  6600. return Ok(jw);
  6601. }
  6602. //酒店数量
  6603. var txtSGRNumber = Aparams.SGR.ToString();
  6604. var txtTBRNumber = Aparams.TBR.ToString();
  6605. var txtJSESNumber = Aparams.JSES.ToString();
  6606. var txtSUITENumbe = Aparams.SUITE.ToString();
  6607. if (dto.costType == "B")
  6608. {
  6609. Aparams = hotels.Find(x => x.Type == "A");
  6610. var Bparams = hotels.Find(x => x.Type == "B");
  6611. if (Aparams == null || Bparams == null)
  6612. {
  6613. return Ok(jw);
  6614. }
  6615. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6616. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6617. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6618. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6619. }
  6620. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6621. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6622. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6623. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6624. var ws = designer.Workbook.Worksheets[0];
  6625. int Row = List_GC.Count;
  6626. int startIndex = 11;
  6627. int HideRows = 0;
  6628. List<int> hideRowsList = new List<int>();
  6629. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6630. #region A段left数据
  6631. var left = dto.leftInfo.Find(x => x.Type == "A");
  6632. if (left == null)
  6633. {
  6634. return Ok(jw);
  6635. }
  6636. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6637. if (leftBindData != null)
  6638. {
  6639. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6640. designer.SetDataSource("VisaRS", leftBindData.rs);
  6641. designer.SetDataSource("VisaXS", leftBindData.xs);
  6642. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6643. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6644. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6645. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6646. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6647. }
  6648. else
  6649. {
  6650. hideRowsList.Add(Row + startIndex + HideRows);
  6651. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6652. }
  6653. HideRows += 2;
  6654. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6655. if (leftBindData != null)
  6656. {
  6657. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6658. designer.SetDataSource("BXRS", leftBindData.rs);
  6659. designer.SetDataSource("BXXS", leftBindData.xs);
  6660. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6661. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6662. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6663. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6664. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6665. }
  6666. else
  6667. {
  6668. hideRowsList.Add(Row + startIndex + HideRows);
  6669. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6670. }
  6671. HideRows += 2;
  6672. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6673. if (leftBindData != null)
  6674. {
  6675. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6676. designer.SetDataSource("HSRS", leftBindData.rs);
  6677. designer.SetDataSource("HSXS", leftBindData.xs);
  6678. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6679. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6680. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6681. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6682. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6683. }
  6684. else
  6685. {
  6686. hideRowsList.Add(Row + startIndex + HideRows);
  6687. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6688. }
  6689. HideRows += 2;
  6690. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6691. if (leftBindData != null)
  6692. {
  6693. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6694. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6695. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6696. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6697. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6698. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6699. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6700. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6701. }
  6702. else
  6703. {
  6704. hideRowsList.Add(Row + startIndex + HideRows);
  6705. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6706. }
  6707. HideRows += 2;
  6708. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6709. if (leftBindData != null)
  6710. {
  6711. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6712. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6713. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6714. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6715. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6716. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6717. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6718. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6719. }
  6720. else
  6721. {
  6722. hideRowsList.Add(Row + startIndex + HideRows);
  6723. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6724. }
  6725. HideRows += 2;
  6726. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6727. if (leftBindData != null)
  6728. {
  6729. ////TBR
  6730. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6731. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6732. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6733. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6734. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6735. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6736. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6737. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6738. }
  6739. else
  6740. {
  6741. hideRowsList.Add(Row + startIndex + HideRows);
  6742. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6743. }
  6744. HideRows += 2;
  6745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6746. if (leftBindData != null)
  6747. {
  6748. ////SGR
  6749. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6750. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6751. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6752. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6753. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6754. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6755. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6756. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6757. }
  6758. else
  6759. {
  6760. hideRowsList.Add(Row + startIndex + HideRows);
  6761. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6762. }
  6763. HideRows += 2;
  6764. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6765. if (leftBindData != null)
  6766. {
  6767. ////JS/ES
  6768. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6769. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6770. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6771. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6772. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6773. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6774. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6775. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6776. }
  6777. else
  6778. {
  6779. hideRowsList.Add(Row + startIndex + HideRows);
  6780. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6781. }
  6782. HideRows += 2;
  6783. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6784. if (leftBindData != null)
  6785. {
  6786. ////SUITE
  6787. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6788. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6789. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6790. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6791. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6792. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6793. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6794. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6795. }
  6796. else
  6797. {
  6798. hideRowsList.Add(Row + startIndex + HideRows);
  6799. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6800. }
  6801. HideRows += 2;
  6802. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6803. if (leftBindData != null)
  6804. {
  6805. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6806. designer.SetDataSource("DJRS", leftBindData.rs);
  6807. designer.SetDataSource("DJXS", leftBindData.xs);
  6808. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6809. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6810. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6811. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6812. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6813. }
  6814. else
  6815. {
  6816. hideRowsList.Add(Row + startIndex + HideRows);
  6817. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6818. }
  6819. HideRows += 2;
  6820. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6821. if (leftBindData != null)
  6822. {
  6823. designer.SetDataSource("HCPCB", leftBindData.cb);
  6824. designer.SetDataSource("HCPRS", leftBindData.rs);
  6825. designer.SetDataSource("HCPXS", leftBindData.xs);
  6826. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6827. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6828. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6829. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6830. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6831. }
  6832. else
  6833. {
  6834. hideRowsList.Add(Row + startIndex + HideRows);
  6835. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6836. }
  6837. HideRows += 2;
  6838. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  6839. if (leftBindData != null)
  6840. {
  6841. designer.SetDataSource("CPCB", leftBindData.cb);
  6842. designer.SetDataSource("CPRS", leftBindData.rs);
  6843. designer.SetDataSource("CPXS", leftBindData.xs);
  6844. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6845. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6846. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6847. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6848. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6849. }
  6850. else
  6851. {
  6852. hideRowsList.Add(Row + startIndex + HideRows);
  6853. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6854. }
  6855. HideRows += 2;
  6856. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  6857. if (leftBindData != null)
  6858. {
  6859. designer.SetDataSource("GWDRCD", leftBindData.cb);
  6860. designer.SetDataSource("GWRS", leftBindData.rs);
  6861. designer.SetDataSource("GWXS", leftBindData.xs);
  6862. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6863. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6864. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6865. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6866. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6867. }
  6868. else
  6869. {
  6870. hideRowsList.Add(Row + startIndex + HideRows);
  6871. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6872. }
  6873. HideRows += 2;
  6874. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  6875. if (leftBindData != null)
  6876. {
  6877. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  6878. designer.SetDataSource("LYJRS", leftBindData.rs);
  6879. designer.SetDataSource("LYJXS", leftBindData.xs);
  6880. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6881. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6882. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6883. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6884. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6885. }
  6886. else
  6887. {
  6888. hideRowsList.Add(Row + startIndex + HideRows);
  6889. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6890. }
  6891. #endregion
  6892. #region A段Right信息
  6893. var right = dto.rightInfo.Find(x => x.Type == "A");
  6894. if (right == null)
  6895. {
  6896. return Ok(jw);
  6897. }
  6898. HideRows += 4;
  6899. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  6900. if (rightBindData != null)
  6901. {
  6902. //经济舱 + 双人间 TBR
  6903. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  6904. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  6905. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6906. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  6907. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6908. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6909. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6910. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6911. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6912. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6913. }
  6914. else
  6915. {
  6916. hideRowsList.Add(Row + startIndex + HideRows);
  6917. }
  6918. HideRows += 2;
  6919. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  6920. if (rightBindData != null)
  6921. {
  6922. //经济舱 + 单人间 SGR
  6923. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  6924. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  6925. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6926. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  6927. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6928. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6929. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6930. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6931. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6932. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6933. }
  6934. else
  6935. {
  6936. hideRowsList.Add(Row + startIndex + HideRows);
  6937. }
  6938. HideRows += 2;
  6939. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  6940. if (rightBindData != null)
  6941. {
  6942. //公务舱 + 单人间 SGR
  6943. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  6944. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  6945. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6946. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  6947. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6948. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6949. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6950. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6951. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6952. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6953. }
  6954. else
  6955. {
  6956. hideRowsList.Add(Row + startIndex + HideRows);
  6957. }
  6958. HideRows += 2;
  6959. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  6960. if (rightBindData != null)
  6961. {
  6962. //公务舱 + 小套房 JSES
  6963. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  6964. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  6965. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6966. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  6967. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6968. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6969. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6970. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6971. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6972. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6973. }
  6974. else
  6975. {
  6976. hideRowsList.Add(Row + startIndex + HideRows);
  6977. }
  6978. HideRows += 2;
  6979. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  6980. if (rightBindData != null)
  6981. {
  6982. //公务舱 + 小套房 JSES
  6983. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  6984. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  6985. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6986. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  6987. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6988. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6989. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6990. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6991. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6992. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6993. }
  6994. else
  6995. {
  6996. hideRowsList.Add(Row + startIndex + HideRows);
  6997. }
  6998. HideRows += 2;
  6999. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7000. if (rightBindData != null)
  7001. {
  7002. //经济舱 + 大套房
  7003. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7004. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7005. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7006. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7007. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7008. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7009. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7010. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7011. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7012. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7013. }
  7014. else
  7015. {
  7016. hideRowsList.Add(Row + startIndex + HideRows);
  7017. }
  7018. #endregion
  7019. #region B段标题清空
  7020. designer.SetDataSource("CostBDRCB", "");
  7021. designer.SetDataSource("CostBRS", "");
  7022. designer.SetDataSource("CostBXS", "");
  7023. designer.SetDataSource("CostBZCB", "");
  7024. designer.SetDataSource("CostBDRBJ", "");
  7025. designer.SetDataSource("CostBZBJ", "");
  7026. designer.SetDataSource("CostBDRLR", "");
  7027. designer.SetDataSource("CostBZLR", "");
  7028. designer.SetDataSource("CostBDRCBOM", "");
  7029. designer.SetDataSource("CostBRSOM", "");
  7030. designer.SetDataSource("CostBZCBOM", "");
  7031. designer.SetDataSource("CostBDRBJOM", "");
  7032. designer.SetDataSource("CostBZBJOM", "");
  7033. designer.SetDataSource("CostBDRLROM", "");
  7034. designer.SetDataSource("CostBZLROM", "");
  7035. #endregion
  7036. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7037. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7038. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7039. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7040. designer.SetDataSource("DJName", "地接(CNY)");
  7041. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7042. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7043. designer.SetDataSource("GWName", "公务(CNY)");
  7044. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7045. designer.SetDataSource("LYJName", "零用金(CNY)");
  7046. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7047. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7048. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7049. designer.SetDataSource("BXName", "保险(CNY)");
  7050. designer.SetDataSource("VisaName", "签证(CNY)");
  7051. #region B段基本数据
  7052. if (dto.costType == "B")
  7053. {
  7054. left = dto.leftInfo.Find(x => x.Type == "B");
  7055. if (left == null)
  7056. {
  7057. return Ok(jw);
  7058. }
  7059. #region B段left数据
  7060. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7061. if (leftBindData != null)
  7062. {
  7063. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7064. designer.SetDataSource("BHSRS", leftBindData.rs);
  7065. designer.SetDataSource("BHSXS", leftBindData.xs);
  7066. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7067. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7068. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7069. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7070. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7071. }
  7072. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7073. if (leftBindData != null)
  7074. {
  7075. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7076. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7077. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7078. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7079. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7080. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7081. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7082. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7083. }
  7084. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7085. if (leftBindData != null)
  7086. {
  7087. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7088. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7089. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7090. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7091. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7092. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7093. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7094. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7095. }
  7096. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7097. if (leftBindData != null)
  7098. {
  7099. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7100. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7101. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7102. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7103. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7104. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7105. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7106. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7107. }
  7108. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7109. if (leftBindData != null)
  7110. {
  7111. designer.SetDataSource("BCPCB", leftBindData.cb);
  7112. designer.SetDataSource("BCPRS", leftBindData.rs);
  7113. designer.SetDataSource("BCPXS", leftBindData.xs);
  7114. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7115. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7116. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7117. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7118. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7119. }
  7120. //TBR
  7121. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7122. if (leftBindData != null)
  7123. {
  7124. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7125. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7126. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7127. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7128. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7129. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7130. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7131. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7132. }
  7133. //SGR
  7134. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7135. if (leftBindData != null)
  7136. {
  7137. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7138. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7139. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7140. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7141. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7142. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7143. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7144. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7145. }
  7146. //JS/ES
  7147. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7148. if (leftBindData != null)
  7149. {
  7150. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7151. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7152. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7153. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7154. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7155. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7156. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7157. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7158. }
  7159. //SUITE
  7160. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7161. if (leftBindData != null)
  7162. {
  7163. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7164. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7165. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7166. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7167. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7168. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7169. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7170. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7171. }
  7172. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7173. if (leftBindData != null)
  7174. {
  7175. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7176. designer.SetDataSource("BDJRS", leftBindData.rs);
  7177. designer.SetDataSource("BDJXS", leftBindData.xs);
  7178. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7179. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7180. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7181. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7182. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7183. }
  7184. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7185. if (leftBindData != null)
  7186. {
  7187. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7188. designer.SetDataSource("BGWRS", leftBindData.rs);
  7189. designer.SetDataSource("BGWXS", leftBindData.xs);
  7190. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7191. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7192. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7193. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7194. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7195. }
  7196. #region 优化方案
  7197. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7198. //excelBind.Add("零用金", new {
  7199. //cb="",
  7200. //rs="",
  7201. //xs ="",
  7202. //zcb = "",
  7203. //});
  7204. #endregion
  7205. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7206. if (leftBindData != null)
  7207. {
  7208. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7209. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7210. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7211. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7212. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7213. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7214. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7215. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7216. }
  7217. #endregion
  7218. #region B段Right信息
  7219. right = dto.rightInfo.Find(x => x.Type == "B");
  7220. if (right == null)
  7221. {
  7222. return Ok(jw);
  7223. }
  7224. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7225. if (rightBindData != null)
  7226. {
  7227. //经济舱 + 双人间 TBR
  7228. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7229. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7230. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7231. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7232. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7233. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7234. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7235. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7236. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7237. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7238. }
  7239. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7240. if (rightBindData != null)
  7241. {
  7242. //经济舱 + 单人间 SGR
  7243. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7244. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7245. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7246. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7247. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7248. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7249. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7250. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7251. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7252. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7253. }
  7254. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7255. if (rightBindData != null)
  7256. {
  7257. //公务舱 + 单人间 SGR
  7258. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7259. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7260. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7261. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7262. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7263. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7264. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7265. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7266. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7267. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7268. }
  7269. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7270. if (rightBindData != null)
  7271. {
  7272. //公务舱 + 小套房 JSES
  7273. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7274. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7275. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7276. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7277. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7278. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7279. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7280. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7281. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7282. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7283. }
  7284. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7285. if (rightBindData != null)
  7286. {
  7287. //公务舱 + 小套房 JSES
  7288. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7289. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7290. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7291. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7292. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7293. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7294. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7295. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7296. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7297. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7298. }
  7299. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7300. if (rightBindData != null)
  7301. {
  7302. //经济舱 + 大套房
  7303. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7304. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7305. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7306. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7307. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7308. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7309. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7310. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7311. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7312. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7313. }
  7314. #endregion
  7315. #region 标题
  7316. designer.SetDataSource("CostBDRCB", "单人成本");
  7317. designer.SetDataSource("CostBRS", "人数");
  7318. designer.SetDataSource("CostBXS", "系数");
  7319. designer.SetDataSource("CostBZCB", "总成本");
  7320. designer.SetDataSource("CostBDRBJ", "单人报价");
  7321. designer.SetDataSource("CostBZBJ", "总报价");
  7322. designer.SetDataSource("CostBDRLR", "单人利润");
  7323. designer.SetDataSource("CostBZLR", "总利润");
  7324. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7325. designer.SetDataSource("CostBRSOM", "人数");
  7326. designer.SetDataSource("CostBZCBOM", "总成本");
  7327. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7328. designer.SetDataSource("CostBZBJOM", "总报价");
  7329. designer.SetDataSource("CostBDRLROM", "单人利润");
  7330. designer.SetDataSource("CostBZLROM", "总利润");
  7331. #endregion
  7332. }
  7333. #endregion
  7334. designer.SetDataSource("TzZCB2", TzZCB2);
  7335. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7336. designer.SetDataSource("TzZLR2", TzZLR2);
  7337. string[] dataSourceKeys = new string[]
  7338. {
  7339. "VF",
  7340. "TGS",
  7341. "TGOF",
  7342. "TGM",
  7343. "TGA",
  7344. "TGTF",
  7345. "TGEF",
  7346. "CFM",
  7347. "CFOF",
  7348. "B",
  7349. "L",
  7350. "D",
  7351. "TBR",
  7352. "SGR",
  7353. "JSES",
  7354. "Suite",
  7355. "TV",
  7356. "1L",
  7357. "IF",
  7358. "EF",
  7359. "BRF",
  7360. "TE",
  7361. "TGT",
  7362. "DRVT",
  7363. "PC",
  7364. "TLF",
  7365. "ECT"
  7366. };
  7367. foreach (var item in dataSourceKeys)
  7368. {
  7369. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7370. if (find != null)
  7371. {
  7372. designer.SetDataSource(item, find.text);
  7373. }
  7374. else
  7375. {
  7376. designer.SetDataSource(item, 0);
  7377. }
  7378. }
  7379. designer.SetDataSource(dt);
  7380. //根据数据源处理生成报表内容
  7381. designer.Process();
  7382. designer.Workbook.Worksheets[0].Name = "清单";
  7383. Worksheet sheet = designer.Workbook.Worksheets[0];
  7384. foreach (var Rowindex in hideRowsList)
  7385. {
  7386. ws.Cells.HideRows(Rowindex, 2);
  7387. }
  7388. byte[] bytes = null;
  7389. string strFileName = di.TeamName + "-团组-成本.xls";
  7390. using (MemoryStream stream = new MemoryStream())
  7391. {
  7392. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7393. bytes = stream.ToArray();
  7394. }
  7395. return Ok(JsonView(true, "", new
  7396. {
  7397. Data = bytes,
  7398. strFileName,
  7399. }));
  7400. }
  7401. /// <summary>
  7402. /// 导出客户报表
  7403. /// </summary>
  7404. /// <returns></returns>
  7405. [HttpPost]
  7406. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7407. {
  7408. var jw = JsonView(false);
  7409. if (dto.Diid == 0)
  7410. {
  7411. return Ok(JsonView(false, "请传递团组id"));
  7412. }
  7413. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7414. if (deleInfo.Code != 0)
  7415. {
  7416. return Ok(JsonView(false, "团组信息查询失败!"));
  7417. }
  7418. var di = deleInfo.Data as DelegationInfoWebView;
  7419. if (di == null)
  7420. {
  7421. return Ok(JsonView(false, "团组信息查询失败!"));
  7422. }
  7423. //文件名
  7424. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7425. //获取模板
  7426. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7427. //载入模板
  7428. Document doc = new Document(tmppath);
  7429. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7430. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7431. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7432. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7433. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7434. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7435. if (AParameter == null)
  7436. {
  7437. return Ok(JsonView(false, "系数不存在!"));
  7438. }
  7439. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7440. , TzAirDesc, TzZCost;
  7441. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7442. = TzAirDesc = TzZCost = string.Empty;
  7443. TzNumber = AParameter.CostTypenumber.ToString();
  7444. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7445. CarGuides1 = dto.CarGuides1;
  7446. Meal = dto.Meal;
  7447. SubsidizedMeals = dto.SubsidizedMeals;
  7448. NightRepair = dto.NightRepair;
  7449. AttractionsTickets = dto.AttractionsTickets;
  7450. MiscellaneousFees = dto.MiscellaneousFees;
  7451. ATip = dto.ATip;
  7452. TzHotelDesc = "";
  7453. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7454. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7455. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7456. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7457. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7458. TzAirDesc = "";
  7459. TzZCost = dto.TzZCost;
  7460. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7461. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7462. var index = 1;
  7463. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7464. foreach (var item in TzHotelDescArr)
  7465. {
  7466. if (AinfoArr != null)
  7467. {
  7468. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7469. if (Ainfo != null)
  7470. {
  7471. if (int.Parse(Ainfo.rs) <= 0)
  7472. {
  7473. continue;
  7474. }
  7475. var hotelText = string.Empty;
  7476. switch (item)
  7477. {
  7478. case "SGR":
  7479. hotelText = "单人间";
  7480. break;
  7481. case "JSES":
  7482. hotelText = "小套房";
  7483. break;
  7484. case "SUITE":
  7485. hotelText = "套房";
  7486. break;
  7487. case "TBR":
  7488. hotelText = "双人间";
  7489. break;
  7490. }
  7491. if (item != "TBR")
  7492. {
  7493. 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";
  7494. }
  7495. else
  7496. {
  7497. 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";
  7498. }
  7499. index++;
  7500. }
  7501. }
  7502. }
  7503. index = 1;
  7504. foreach (var item in TzAirDescArr)
  7505. {
  7506. if (AinfoArr != null)
  7507. {
  7508. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7509. if (Ainfo != null)
  7510. {
  7511. if (int.Parse(Ainfo.rs) <= 0)
  7512. {
  7513. continue;
  7514. }
  7515. 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";
  7516. index++;
  7517. }
  7518. }
  7519. }
  7520. if (dto.costType == "B")
  7521. {
  7522. if (BParameter == null)
  7523. {
  7524. return Ok(JsonView(false, "B段系数不存在!"));
  7525. }
  7526. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7527. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7528. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7529. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7530. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7531. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7532. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7533. foreach (var item in TzHotelDescArr)
  7534. {
  7535. if (AinfoArr != null)
  7536. {
  7537. TzHotelDesc += "B段信息 \r\n";
  7538. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7539. if (Ainfo != null)
  7540. {
  7541. if (int.Parse(Ainfo.rs) <= 0)
  7542. {
  7543. continue;
  7544. }
  7545. var hotelText = string.Empty;
  7546. switch (item)
  7547. {
  7548. case "SGR":
  7549. hotelText = "单人间";
  7550. break;
  7551. case "JSES":
  7552. hotelText = "小套房";
  7553. break;
  7554. case "SUITE":
  7555. hotelText = "套房";
  7556. break;
  7557. case "TBR":
  7558. hotelText = "双人间";
  7559. break;
  7560. }
  7561. if (item != "TBR")
  7562. {
  7563. 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";
  7564. }
  7565. else
  7566. {
  7567. 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";
  7568. }
  7569. index++;
  7570. }
  7571. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7572. }
  7573. }
  7574. index = 1;
  7575. foreach (var item in TzAirDescArr)
  7576. {
  7577. if (AinfoArr != null)
  7578. {
  7579. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7580. if (Ainfo != null)
  7581. {
  7582. if (int.Parse(Ainfo.rs) <= 0)
  7583. {
  7584. continue;
  7585. }
  7586. 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";
  7587. index++;
  7588. }
  7589. }
  7590. }
  7591. }
  7592. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7593. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7594. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7595. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7596. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7597. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7598. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7599. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7600. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7601. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7602. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7603. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7604. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7605. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7606. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7607. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7608. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7609. DickeyValue.Add("TzZCost", TzZCost);
  7610. foreach (var key in DickeyValue.Keys)
  7611. {
  7612. if (doc.Range.Bookmarks[key] != null)
  7613. {
  7614. Bookmark mark = doc.Range.Bookmarks[key];
  7615. mark.Text = DickeyValue[key];
  7616. }
  7617. }
  7618. byte[] bytes = null;
  7619. string strFileName = di.TeamName + "-客户报价.doc";
  7620. using (MemoryStream stream = new MemoryStream())
  7621. {
  7622. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7623. bytes = stream.ToArray();
  7624. }
  7625. return Ok(JsonView(true, "", new
  7626. {
  7627. Data = bytes,
  7628. strFileName,
  7629. }));
  7630. }
  7631. /// <summary>
  7632. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7633. /// </summary>
  7634. /// <param name="dto"></param>
  7635. /// <returns></returns>
  7636. [HttpPost]
  7637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7638. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7639. {
  7640. try
  7641. {
  7642. #region 参数验证
  7643. if (dto.DiId < 0)
  7644. {
  7645. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7646. }
  7647. List<int> cTableIds = new List<int>() {
  7648. 76 ,//酒店预订
  7649. 77 ,//行程
  7650. 79 ,//车/导游地接
  7651. 80 ,//签证
  7652. 81 ,//邀请/公务活
  7653. 82 ,//团组客户保险
  7654. 85 ,//机票预订
  7655. 98 ,//其他款项
  7656. 285 ,//收款退还
  7657. 751 ,//酒店早餐
  7658. 1015 // 超支费用
  7659. };
  7660. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7661. {
  7662. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7663. }
  7664. #endregion
  7665. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7666. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7667. if (_GroupCostParameters.Count <= 0)
  7668. {
  7669. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7670. }
  7671. if (_GroupCostParameters[0].IsShare == 0)
  7672. {
  7673. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7674. }
  7675. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7676. //处理date为空问题
  7677. if (_GroupCosts.Count > 0)
  7678. {
  7679. for (int i = 0; i < _GroupCosts.Count; i++)
  7680. {
  7681. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7682. {
  7683. if (i > 0)
  7684. {
  7685. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7686. }
  7687. }
  7688. }
  7689. }
  7690. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7691. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7692. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7693. string currCode = "";
  7694. #region currCode 验证
  7695. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7696. if (isInt)
  7697. {
  7698. var currData = currDatas.Find(it => it.Id == intCurrency);
  7699. if (currData != null)
  7700. {
  7701. currCode = currData.Name;
  7702. }
  7703. }
  7704. else
  7705. {
  7706. currCode = _GroupCostParameters[0].Currency.Trim();
  7707. }
  7708. #endregion
  7709. //op,酒店单段模式存储
  7710. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7711. {
  7712. CurrencyCode = currCode,
  7713. Rate = _GroupCostParameters[0].Rate,
  7714. CostType = _GroupCostParameters[0].CostType,
  7715. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7716. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7717. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7718. };
  7719. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7720. if (_GroupCostParameters.Count == 2)
  7721. {
  7722. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7723. }
  7724. foreach (var item in _GroupCostParameters)
  7725. {
  7726. decimal _rate = 1;
  7727. decimal _rate1 = item.Rate;
  7728. decimal _scale = 1;
  7729. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7730. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7731. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7732. //if (userInfo != null)
  7733. //{
  7734. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7735. // {
  7736. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7737. // {
  7738. // _scale = 1.00M;
  7739. // }
  7740. // }
  7741. //}
  7742. #endregion
  7743. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7744. {
  7745. CurrencyCode = currCode,
  7746. Rate = _rate1,
  7747. CostType = item.CostType,
  7748. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7749. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7750. CostTypeNumber = item.CostTypenumber
  7751. };
  7752. if (_GroupCostParameters.Count > 1)
  7753. {
  7754. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7755. }
  7756. else
  7757. {
  7758. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7759. }
  7760. if (dto.CTable == 79)//
  7761. {
  7762. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7763. modulePromptInfo.TotalCost = item.DJCB;
  7764. }
  7765. List<string> costTypes = new List<string>() { "A", "B" };
  7766. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7767. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7768. if (_GroupCostsDuplicates.Count() == 1)
  7769. {
  7770. _GroupCostsTypeData = _GroupCosts;
  7771. }
  7772. else
  7773. {
  7774. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7775. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7776. }
  7777. /*
  7778. * 76 酒店预订
  7779. * 77 行程
  7780. * 79 车/导游地接
  7781. * 80 签证
  7782. * 81 邀请/公务活动
  7783. * 82 团组客户保险
  7784. * 85 机票预订
  7785. * 98 其他款项
  7786. * 285 收款退还
  7787. * 751 酒店早餐
  7788. * 1015 超支费用
  7789. */
  7790. switch (dto.CTable)
  7791. {
  7792. case 76: // 酒店预订
  7793. _ModuleSubPromptInfo.AddRange(
  7794. _GroupCostsTypeData.Select(it => new
  7795. {
  7796. it.DAY,
  7797. it.Date,
  7798. it.ACCON,
  7799. it.ITIN,
  7800. it.SGR,
  7801. it.TBR,
  7802. it.JS_ES,
  7803. it.Suite
  7804. })
  7805. );
  7806. break;
  7807. case 79: // 车/导游地接
  7808. _ModuleSubPromptInfo.AddRange(
  7809. _GroupCostsTypeData.Select(it => new
  7810. {
  7811. Date = it.Date, //日期
  7812. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  7813. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  7814. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  7815. TicketFee = it.EF * _rate * _scale, //门票费
  7816. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  7817. AirportTransferFee = 0.00M,
  7818. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  7819. TravelSupplies = it.TE * _rate * _scale, //出行物资
  7820. LeadersFee = it.TLF * _rate * _scale, //领队费
  7821. CarFee1 = it.CarCost * _rate * _scale,
  7822. CarType = it.CarType, //车型
  7823. SpentCash = it.PC * _rate * _scale, //零用金
  7824. })
  7825. );
  7826. break;
  7827. case 85: // 机票
  7828. List<dynamic> datas = new List<dynamic>();
  7829. datas.Add(
  7830. new
  7831. {
  7832. AirType = "经济舱",
  7833. AirNum = item.JJCRS,
  7834. AirDRCB = item.JJCCB,
  7835. AirZCB = (item.JJCRS * item.JJCCB)
  7836. }
  7837. );
  7838. datas.Add(
  7839. new
  7840. {
  7841. AirType = "公务舱",
  7842. AirNum = item.GWCRS,
  7843. AirDRCB = item.GWCCB,
  7844. AirZCB = (item.GWCRS * item.GWCCB)
  7845. }
  7846. );
  7847. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7848. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  7849. modulePromptInfo.Data = new {
  7850. airFeeData = datas,
  7851. airInitData = initDatas
  7852. };
  7853. _ModulePromptInfos.Add(modulePromptInfo);
  7854. break;
  7855. default:
  7856. break;
  7857. }
  7858. }
  7859. if (dto.CTable != 85)
  7860. {
  7861. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  7862. _ModulePromptInfos.Add(_ModulePromptInfo);
  7863. }
  7864. _view.ModulePromptInfos = _ModulePromptInfos;
  7865. return Ok(JsonView(true, "操作成功!", _view));
  7866. }
  7867. catch (Exception ex)
  7868. {
  7869. return Ok(JsonView(false, ex.Message));
  7870. }
  7871. }
  7872. /// <summary>
  7873. /// 根据黑屏代码重新生成行程
  7874. /// </summary>
  7875. /// <param name="dto"></param>
  7876. /// <returns></returns>
  7877. [HttpPost]
  7878. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  7879. {
  7880. var jw = JsonView(false);
  7881. var Create = _GroupCostRepository.
  7882. CreateGroupCostByBlackCode(dto.Diid);
  7883. jw.Msg = Create.Msg;
  7884. if (Create.Code == 0)
  7885. {
  7886. jw.Code = 200;
  7887. jw.Data = new
  7888. {
  7889. groupCost = Create.Data,
  7890. blackCodeIsTrue = true
  7891. };
  7892. }
  7893. else
  7894. {
  7895. jw.Code = 400;
  7896. jw.Data = new
  7897. {
  7898. groupCost = Create.Data,
  7899. blackCodeIsTrue = false,
  7900. };
  7901. }
  7902. return Ok(jw);
  7903. }
  7904. /// <summary>
  7905. /// 成本获取OP历史车费用
  7906. /// </summary>
  7907. /// <param name="dto"></param>
  7908. /// <returns></returns>
  7909. [HttpPost]
  7910. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  7911. {
  7912. var jw = JsonView(false);
  7913. try
  7914. {
  7915. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  7916. //获取现有所有车的数据
  7917. if (!dto.Param.IsNullOrWhiteSpace())
  7918. {
  7919. string sql = $@"
  7920. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  7921. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  7922. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  7923. 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
  7924. AND gctggr.ServiceEndTime is not NULL
  7925. ORDER by gctggrc.id DESC
  7926. ";
  7927. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  7928. var numeberResult = await Task.Run(() =>
  7929. {
  7930. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  7931. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  7932. return numberArr;
  7933. });
  7934. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  7935. foreach (var item in numeberResult)
  7936. {
  7937. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  7938. {
  7939. Country = "数据异常!",
  7940. City = string.Empty,
  7941. };
  7942. item.Area = find.Country + " " + find.City;
  7943. }
  7944. dbResult.AddRange(numeberResult);
  7945. if (dto.Param.Contains("、"))
  7946. {
  7947. var sp = dto.Param.Split("、");
  7948. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  7949. .Where(x =>
  7950. {
  7951. return System.Array.Exists(sp, e =>
  7952. {
  7953. bool where = false;
  7954. if (x.Area != null)
  7955. {
  7956. where = x.Area.Contains(e);
  7957. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  7958. {
  7959. return false;
  7960. }
  7961. }
  7962. if (x.PriceName != null && !where)
  7963. {
  7964. where = x.PriceName.Contains(e);
  7965. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  7966. {
  7967. return false;
  7968. }
  7969. }
  7970. return where;
  7971. });
  7972. }).ToList();
  7973. }
  7974. else
  7975. {
  7976. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  7977. .Where(x =>
  7978. {
  7979. bool where = false;
  7980. if (x.Area != null)
  7981. {
  7982. where = x.Area.Contains(dto.Param);
  7983. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  7984. {
  7985. return false;
  7986. }
  7987. }
  7988. if (x.PriceName != null && !where)
  7989. {
  7990. where = x.PriceName.Contains(dto.Param);
  7991. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  7992. {
  7993. return false;
  7994. }
  7995. }
  7996. return where;
  7997. }
  7998. )
  7999. .ToList();
  8000. }
  8001. }
  8002. var view = dbResult.Select(x => {
  8003. decimal dp = 0.00M;
  8004. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8005. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8006. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8007. {
  8008. if (startB && endB)
  8009. {
  8010. var timesp = endD.Subtract(startD);
  8011. if ((timesp.Days + 1) != 0)
  8012. {
  8013. dp = x.Price / (timesp.Days + 1);
  8014. }
  8015. }
  8016. }
  8017. else
  8018. {
  8019. dp = x.Price;
  8020. }
  8021. return new
  8022. {
  8023. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8024. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8025. x.Area,
  8026. x.id,
  8027. price = x.Price.ToString("F2"),
  8028. x.PriceName,
  8029. x.PriceContent,
  8030. x.TeamName,
  8031. x.DatePrice,
  8032. dayPrice = dp.ToString("F2"),
  8033. };
  8034. }).OrderByDescending(x => x.id).ToList();
  8035. jw = JsonView(true, "获取成功!", view);
  8036. }
  8037. catch (Exception e)
  8038. {
  8039. jw = JsonView(false, e.Message);
  8040. }
  8041. return Ok(jw);
  8042. }
  8043. #endregion
  8044. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8045. /// <summary>
  8046. /// 酒店预订
  8047. /// 酒店费用列表 根据团组Id查询
  8048. /// </summary>
  8049. /// <param name="_dto"></param>
  8050. /// <returns></returns>
  8051. [HttpPost]
  8052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8053. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8054. {
  8055. #region 参数验证
  8056. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8057. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8058. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8059. #region 团组操作权限验证 76 酒店预定模块
  8060. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8061. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8062. #endregion
  8063. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8064. #region 页面操作权限验证
  8065. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8066. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8067. #endregion
  8068. #endregion
  8069. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8070. }
  8071. /// <summary>
  8072. /// 酒店预订
  8073. /// 基础数据
  8074. /// </summary>
  8075. /// <param name="_dto"></param>
  8076. /// <returns></returns>
  8077. [HttpPost]
  8078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8079. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8080. {
  8081. #region 参数验证
  8082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8083. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8084. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8086. #region 页面操作权限验证
  8087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8088. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8089. #endregion
  8090. #region 团组操作权限验证 76 酒店预定模块
  8091. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8092. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8093. #endregion
  8094. #endregion
  8095. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8096. }
  8097. /// <summary>
  8098. /// 酒店预订
  8099. /// 创建 入住卷号码
  8100. /// </summary>
  8101. /// <param name="_dto"></param>
  8102. /// <returns></returns>
  8103. [HttpPost]
  8104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8105. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8106. {
  8107. try
  8108. {
  8109. #region 参数验证
  8110. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8111. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8112. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8113. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8114. #region 页面操作权限验证
  8115. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8116. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8117. #endregion
  8118. #region 团组操作权限验证 76 酒店预定模块
  8119. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8120. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8121. #endregion
  8122. #endregion
  8123. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8124. if (data.Code != 0)
  8125. {
  8126. return Ok(JsonView(false, data.Msg));
  8127. }
  8128. return Ok(JsonView(true, data.Msg, data.Data));
  8129. }
  8130. catch (Exception ex)
  8131. {
  8132. return Ok(JsonView(false, ex.Message));
  8133. }
  8134. }
  8135. /// <summary>
  8136. /// 酒店预订
  8137. /// 详情
  8138. /// </summary>
  8139. /// <param name="_dto"></param>
  8140. /// <returns></returns>
  8141. [HttpPost]
  8142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8143. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8144. {
  8145. #region 参数验证
  8146. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8147. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8148. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8149. #region 团组操作权限验证 76 酒店预定模块
  8150. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8151. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8152. #endregion
  8153. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8154. #region 页面操作权限验证
  8155. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8156. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8157. #endregion
  8158. #endregion
  8159. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8160. }
  8161. /// <summary>
  8162. /// 酒店预订
  8163. /// Add Or Edit
  8164. /// </summary>
  8165. /// <param name="_dto"></param>
  8166. /// <returns></returns>
  8167. [HttpPost]
  8168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8169. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8170. {
  8171. #region 参数验证
  8172. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8173. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8174. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8175. #region 团组操作权限验证 76 酒店预定模块
  8176. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8177. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8178. #endregion
  8179. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8180. #region 页面操作权限验证
  8181. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8182. if (_dto.Id == 0) // Add
  8183. {
  8184. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8185. }
  8186. else if (_dto.Id > 1) // Edit
  8187. {
  8188. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8189. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8190. #endregion
  8191. #endregion
  8192. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8193. if (_view.Code != 200)
  8194. {
  8195. return Ok(_view);
  8196. }
  8197. #region 应用推送
  8198. try
  8199. {
  8200. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8201. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8202. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8203. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8204. //自动审核
  8205. await _feeAuditRep.FeeAutomaticAudit(1,_dto.DiId,hotelId);
  8206. }
  8207. catch (Exception ex)
  8208. {
  8209. }
  8210. #endregion
  8211. return Ok(_view);
  8212. }
  8213. /// <summary>
  8214. /// 酒店预订
  8215. /// Del
  8216. /// </summary>
  8217. /// <param name="_dto"></param>
  8218. /// <returns></returns>
  8219. [HttpPost]
  8220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8221. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8222. {
  8223. #region 参数验证
  8224. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8225. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8226. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8227. #region 团组操作权限验证 76 酒店预定模块
  8228. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8229. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8230. #endregion
  8231. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8232. #region 页面操作权限验证
  8233. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8234. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8235. #endregion
  8236. #endregion
  8237. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8238. }
  8239. /// <summary>
  8240. /// 酒店预订
  8241. /// 生成VOUCHER
  8242. /// 2024.05.06 之前版本
  8243. /// </summary>
  8244. /// <param name="_dto"></param>
  8245. /// <returns></returns>
  8246. [HttpPost]
  8247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8248. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8249. {
  8250. try
  8251. {
  8252. #region 参数验证
  8253. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8254. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8255. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8256. #region 团组操作权限验证 76 酒店预定模块
  8257. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8258. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8259. #endregion
  8260. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8261. #region 页面操作权限验证
  8262. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8263. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8264. #endregion
  8265. #endregion
  8266. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8267. //判断数据是否完整
  8268. if (hr != null)
  8269. {
  8270. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8271. {
  8272. string strFileName = "HotelStatement/";
  8273. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8274. if (dele != null)
  8275. strFileName += dele.TourCode;
  8276. //载入模板
  8277. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8278. Document doc = new Document(sss);
  8279. DocumentBuilder builder = new DocumentBuilder(doc);
  8280. #region 替换Word模板书签内容
  8281. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8282. //入住卷预定号码
  8283. if (doc.Range.Bookmarks["VNO"] != null)
  8284. {
  8285. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8286. mark.Text = hr.CheckNumber;
  8287. }
  8288. //酒店时间
  8289. if (doc.Range.Bookmarks["Date"] != null)
  8290. {
  8291. Bookmark mark = doc.Range.Bookmarks["Date"];
  8292. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8293. }
  8294. //团号
  8295. if (doc.Range.Bookmarks["TNo"] != null)
  8296. {
  8297. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8298. mark.Text = dele.TourCode;
  8299. }
  8300. //预定号码
  8301. if (doc.Range.Bookmarks["BookingId"] != null)
  8302. {
  8303. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8304. mark.Text = hr.ReservationsNo;
  8305. }
  8306. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8307. {
  8308. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8309. mark.Text = hr.DetermineNo;
  8310. }
  8311. //酒店城市
  8312. if (doc.Range.Bookmarks["City"] != null)
  8313. {
  8314. Bookmark mark = doc.Range.Bookmarks["City"];
  8315. mark.Text = hr.City;
  8316. }
  8317. //酒店名称
  8318. if (doc.Range.Bookmarks["HName"] != null)
  8319. {
  8320. Bookmark mark = doc.Range.Bookmarks["HName"];
  8321. mark.Text = hr.HotelName;
  8322. }
  8323. //酒店地址
  8324. if (doc.Range.Bookmarks["Address"] != null)
  8325. {
  8326. Bookmark mark = doc.Range.Bookmarks["Address"];
  8327. mark.Text = hr.HotelAddress;
  8328. }
  8329. //酒店电话
  8330. if (doc.Range.Bookmarks["Tel"] != null)
  8331. {
  8332. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8333. mark.Text = hr.HotelTel;
  8334. }
  8335. //酒店传真
  8336. if (doc.Range.Bookmarks["Fax"] != null)
  8337. {
  8338. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8339. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8340. {
  8341. mark.Text = hr.HotelFax;
  8342. }
  8343. }
  8344. //入住时间
  8345. if (doc.Range.Bookmarks["CIn"] != null)
  8346. {
  8347. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8348. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8349. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8350. }
  8351. //退房时间
  8352. if (doc.Range.Bookmarks["COut"] != null)
  8353. {
  8354. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8355. Bookmark mark = doc.Range.Bookmarks["COut"];
  8356. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8357. }
  8358. //客户名称
  8359. if (doc.Range.Bookmarks["GName"] != null)
  8360. {
  8361. string guestName = "";
  8362. string[] clients = new string[] { };
  8363. if (hr.GuestName.Contains(","))
  8364. {
  8365. clients = hr.GuestName.Split(",");
  8366. }
  8367. else
  8368. {
  8369. clients = new string[] { hr.GuestName };
  8370. }
  8371. List<int> clientIds_int = new List<int>();
  8372. if (clients.Length > 0)
  8373. {
  8374. foreach (var item in clients)
  8375. {
  8376. if (item.IsNumeric())
  8377. {
  8378. clientIds_int.Add(int.Parse(item));
  8379. }
  8380. }
  8381. }
  8382. if (clientIds_int.Count > 0)
  8383. {
  8384. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8385. foreach (var client in _clientDatas)
  8386. {
  8387. //男
  8388. if (client.Sex == 0) guestName += $"Mr.";
  8389. //女
  8390. else if (client.Sex == 1) guestName += $"Ms.";
  8391. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8392. {
  8393. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8394. }
  8395. //guestName += $"{client.Pinyin},";
  8396. }
  8397. if (guestName.Length > 0)
  8398. {
  8399. guestName = guestName.Substring(0, guestName.Length - 1);
  8400. }
  8401. }
  8402. else
  8403. {
  8404. guestName = hr.GuestName;
  8405. }
  8406. Bookmark mark = doc.Range.Bookmarks["GName"];
  8407. mark.Text = guestName;
  8408. }
  8409. //房间介绍
  8410. if (doc.Range.Bookmarks["ROOM"] != null)
  8411. {
  8412. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8413. mark.Text = hr.RoomExplanation;
  8414. }
  8415. //报价描述
  8416. if (doc.Range.Bookmarks["NOTE"] != null)
  8417. {
  8418. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8419. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8420. if (ss != null)
  8421. mark.Text = ss.Name;
  8422. }
  8423. //入住时间
  8424. if (doc.Range.Bookmarks["CheckIn"] != null)
  8425. {
  8426. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8427. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8428. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8429. }
  8430. //退房时间
  8431. if (doc.Range.Bookmarks["CheckOut"] != null)
  8432. {
  8433. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8434. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8435. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8436. }
  8437. //日期
  8438. if (doc.Range.Bookmarks["DT"] != null)
  8439. {
  8440. Bookmark mark = doc.Range.Bookmarks["DT"];
  8441. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8442. }
  8443. //名称
  8444. if (doc.Range.Bookmarks["VName"] != null)
  8445. {
  8446. Bookmark mark = doc.Range.Bookmarks["VName"];
  8447. mark.Text = hr.HotelName;
  8448. }
  8449. //号码
  8450. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8451. {
  8452. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8453. mark.Text = hr.CheckNumber;
  8454. }
  8455. #endregion
  8456. strFileName += "VOUCHER.doc";
  8457. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8458. doc.Save(fileDir);
  8459. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8460. return Ok(JsonView(true, "操作成功!", Url));
  8461. }
  8462. else
  8463. {
  8464. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8465. }
  8466. }
  8467. else
  8468. {
  8469. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8470. }
  8471. }
  8472. catch (Exception ex)
  8473. {
  8474. return Ok(JsonView(false, ex.Message));
  8475. }
  8476. }
  8477. /// <summary>
  8478. /// 酒店预订
  8479. /// 生成VOUCHER
  8480. /// 2024.05.06 之后版本
  8481. /// </summary>
  8482. /// <param name="_dto"></param>
  8483. /// <returns></returns>
  8484. [HttpPost]
  8485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8486. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8487. {
  8488. #region 参数验证
  8489. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8490. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8491. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8492. #region 团组操作权限验证 76 酒店预定模块
  8493. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8494. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8495. #endregion
  8496. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8497. #region 页面操作权限验证
  8498. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8499. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8500. #endregion
  8501. #endregion
  8502. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8503. //判断数据是否完整
  8504. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8505. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8506. string strFileName = "HotelStatement/";
  8507. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8508. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8509. #region 数据处理
  8510. List<int> guestIds = new List<int>();
  8511. int index = 0;
  8512. foreach (var item in hrDtas)
  8513. {
  8514. if (item.GuestName.Contains(","))
  8515. {
  8516. string[] guestIdArr = item.GuestName.Split(',');
  8517. foreach (var guestIdStr in guestIdArr)
  8518. {
  8519. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8520. if (guestBool)
  8521. {
  8522. guestIds.Add(guestId);
  8523. }
  8524. }
  8525. }
  8526. else guestNames += item.GuestName;
  8527. var voucherInfo = new HotelVoucherInfoView()
  8528. {
  8529. HotelName = item.HotelName,
  8530. CheckInDate = item.CheckInDate,
  8531. CheckOutDate = item.CheckOutDate,
  8532. ConfirmationNumber = item.DetermineNo.Trim(),
  8533. RoomType = item.RoomExplanation
  8534. };
  8535. vouchers.Add(voucherInfo);
  8536. }
  8537. if (guestIds.Count > 0)
  8538. {
  8539. guestIds = guestIds.Distinct().ToList();
  8540. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8541. if (guestDatas.Count > 0)
  8542. {
  8543. guestNames = "";
  8544. foreach (var guest in guestDatas)
  8545. {
  8546. string guestName = "";
  8547. if (guest.Sex == 0) guestName += @"MR.";
  8548. else if (guest.Sex == 1) guestName += @"MS.";
  8549. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8550. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8551. guestNames += @$"{guestName.Trim()}、";
  8552. }
  8553. if (guestNames.Length > 0)
  8554. {
  8555. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8556. }
  8557. }
  8558. }
  8559. #endregion
  8560. //载入模板
  8561. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8562. Document doc = new Document(sss);
  8563. DocumentBuilder builder = new DocumentBuilder(doc);
  8564. if (doc.Range.Bookmarks["GuestName"] != null)
  8565. {
  8566. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8567. mark.Text = guestNames;
  8568. }
  8569. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8570. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8571. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8572. for (int i = 1; i <= vouchers.Count; i++)
  8573. {
  8574. HotelVoucherInfoView hviv = vouchers[i - 1];
  8575. builder.MoveToCell(0, i, 0, 0);
  8576. builder.Write(hviv.HotelName);
  8577. builder.MoveToCell(0, i, 1, 0);
  8578. builder.Write(hviv.CheckInDate);
  8579. builder.MoveToCell(0, i, 2, 0);
  8580. builder.Write(hviv.CheckOutDate);
  8581. builder.MoveToCell(0, i, 3, 0);
  8582. builder.Write(hviv.RoomType);
  8583. builder.MoveToCell(0, i, 4, 0);
  8584. builder.Write(hviv.ConfirmationNumber);
  8585. }
  8586. //删除多余行
  8587. int currRowIndex = vouchers.Count + 1;
  8588. int delRows = 21 - currRowIndex;
  8589. if (delRows > 0)
  8590. {
  8591. for (int i = 0; i < delRows; i++)
  8592. {
  8593. table.Rows.RemoveAt(currRowIndex);
  8594. //cultivateRowIndex++;
  8595. }
  8596. }
  8597. strFileName += "VOUCHER.docx";
  8598. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8599. doc.Save(fileDir);
  8600. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8601. return Ok(JsonView(true, "操作成功!", Url));
  8602. }
  8603. /// <summary>
  8604. /// 酒店预订
  8605. /// 生成 预定成本 Excel
  8606. /// </summary>
  8607. /// <param name="_dto"></param>
  8608. /// <returns></returns>
  8609. [HttpPost]
  8610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8611. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8612. {
  8613. #region 参数验证
  8614. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8615. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8616. if (!vadalitorRes.IsValid)
  8617. {
  8618. var errors = new StringBuilder();
  8619. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8620. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8621. }
  8622. #region 团组操作权限验证 76 酒店预定模块
  8623. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8624. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8625. #endregion
  8626. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8627. #region 页面操作权限验证
  8628. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8629. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8630. #endregion
  8631. #endregion
  8632. decimal _rate = 1.00M;
  8633. string _currency = "";
  8634. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8635. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8636. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8637. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8638. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8639. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8640. {
  8641. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8642. }
  8643. _currency = _GroupCostParameter.Currency;
  8644. bool isIntType = int.TryParse(_currency, out int currId);
  8645. if (isIntType)
  8646. {
  8647. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8648. }
  8649. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8650. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8651. if (currInfo == null)
  8652. {
  8653. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8654. }
  8655. if (!_currency.ToUpper().Equals("CNY"))
  8656. {
  8657. _rate = _GroupCostParameter.Rate;
  8658. }
  8659. _rate = currInfo.Rate;
  8660. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8661. string strFileName = "HotelStatement/";
  8662. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8663. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8664. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8665. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8666. #region 数据处理
  8667. foreach (var item in hrDtas)
  8668. {
  8669. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8670. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8671. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8672. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8673. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8674. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8675. string singleRoomFeeStr = string.Empty,
  8676. doubleRoomFeeStr = string.Empty,
  8677. suiteRoomFeeStr = string.Empty,
  8678. otherRoomFeeStr = string.Empty,
  8679. payMoneyStr = string.Empty,
  8680. cardPriceStr = string.Empty;
  8681. if (roomCurr.Equals(_currency))
  8682. {
  8683. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8684. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8685. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8686. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8687. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8688. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8689. }
  8690. else
  8691. {
  8692. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8693. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8694. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8695. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8696. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8697. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8698. }
  8699. string breakfastPriceStr = string.Empty,
  8700. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8701. governmentRentStr = string.Empty,
  8702. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8703. cityTaxStrStr = string.Empty,
  8704. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8705. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8706. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8707. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8708. pcfds.Add(new HotelReservations_PCFD_View()
  8709. {
  8710. City = item.City,
  8711. HotelName = item.HotelName,
  8712. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8713. // SingleRoomCount = item.SingleRoomCount,
  8714. SingleRoomPrice = singleRoomFeeStr,
  8715. // DoubleRoomCount = item.DoubleRoomCount,
  8716. DoubleRoomPrice = doubleRoomFeeStr,
  8717. //SuiteRoomCount = item.SuiteRoomCount,
  8718. SuiteRoomPrice = suiteRoomFeeStr,
  8719. OtherRoomPrice = otherRoomFeeStr,
  8720. //OtherRoomCount = item.OtherRoomCount,
  8721. BreakfastPrice = breakfastPriceStr,
  8722. GovernmentRent = governmentRentStr,
  8723. CityTax = cityTaxStrStr,
  8724. RoomExplanation = item.RoomExplanation,
  8725. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8726. PayTime = roomInfo.ConsumptionDate,
  8727. BankNo = roomInfo.BankNo,
  8728. PayMoney = payMoneyStr,
  8729. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8730. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8731. CardPrice = cardPriceStr,
  8732. Remark = ccpInfo.Remark
  8733. });
  8734. }
  8735. #endregion
  8736. //载入模板
  8737. WorkbookDesigner designer = new WorkbookDesigner();
  8738. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8739. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8740. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8741. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8742. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8743. designer.SetDataSource("Opertor", userInfo.CnName);
  8744. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8745. dt.TableName = "ViewMyHotelReservations";
  8746. designer.SetDataSource(dt);
  8747. designer.Process();
  8748. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8749. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8750. designer.Workbook.Save(serverPath);
  8751. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8752. #region 删除指定行
  8753. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8754. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8755. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8756. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8757. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8758. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8759. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8760. cssIndex = dt.Columns["CityTax"].Ordinal,
  8761. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8762. remarkIndex = dt.Columns["Remark"].Ordinal;
  8763. //删除指定列
  8764. foreach (DataRow item in dt.Rows)
  8765. {
  8766. string singleStr = item["SingleRoomPrice"].ToString();
  8767. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8768. if (containsDigitButNotZero1) singleDel = false;
  8769. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8770. string doubleStr = item["DoubleRoomPrice"].ToString();
  8771. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8772. if (containsDigitButNotZero2) doubleDel = false;
  8773. string suiteStr = item["SuiteRoomPrice"].ToString();
  8774. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8775. if (containsDigitButNotZero3) suiteDel = false;
  8776. string otherStr = item["OtherRoomPrice"].ToString();
  8777. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8778. if (containsDigitButNotZero4) otherDel = false;
  8779. string zcStr = item["BreakfastPrice"].ToString();
  8780. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8781. if (containsDigitButNotZero5) zcDel = false;
  8782. string dsStr = item["GovernmentRent"].ToString();
  8783. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8784. if (containsDigitButNotZero6) dsDel = false;
  8785. string cssStr = item["CityTax"].ToString();
  8786. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8787. if (containsDigitButNotZero7) cssDel = false;
  8788. string cpStr = item["ConsumptionPatterns"].ToString();
  8789. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8790. string remarkStr = item["Remark"].ToString();
  8791. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8792. }
  8793. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8794. DeleteColumn(serverPath, cpIndex, cpDel);
  8795. DeleteColumn(serverPath, dsIndex, dsDel);
  8796. DeleteColumn(serverPath, cssIndex, cssDel);
  8797. DeleteColumn(serverPath, zcIndex, zcDel);
  8798. DeleteColumn(serverPath, otherIndex, otherDel);
  8799. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8800. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8801. DeleteColumn(serverPath, singleIndex, singleDel);
  8802. #endregion
  8803. //只保留第一个表格
  8804. DeleteSheet(serverPath);
  8805. return Ok(JsonView(true, "操作成功", url = rst));
  8806. }
  8807. /// <summary>
  8808. /// 删除指定列
  8809. /// </summary>
  8810. /// <param name="file"></param>
  8811. /// <param name="columnIndex"></param>
  8812. /// <param name="isDel"></param>
  8813. private void DeleteColumn(string file, int columnIndex, bool isDel)
  8814. {
  8815. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8816. //wb.Save(file);
  8817. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  8818. if (sheet1 != null)
  8819. {
  8820. if (isDel)
  8821. {
  8822. Cells cells = sheet1.Cells;
  8823. cells.DeleteColumn(columnIndex);
  8824. }
  8825. }
  8826. wb.Save(file);
  8827. }
  8828. /// <summary>
  8829. /// 删除sheet
  8830. /// </summary>
  8831. /// <param name="file"></param>
  8832. /// <param name="sheetName"></param>
  8833. private void DeleteSheet(string file, string sheetName = "")
  8834. {
  8835. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8836. //wb.Save(file);
  8837. List<string> sheets = new List<string>();
  8838. foreach (var item in wb.Worksheets)
  8839. {
  8840. sheets.Add(item.Name);
  8841. }
  8842. if (sheets.Count > 0)
  8843. {
  8844. sheets.RemoveAt(0);//不删除第一个sheet
  8845. foreach (var item in sheets)
  8846. {
  8847. wb.Worksheets.RemoveAt(item);
  8848. }
  8849. }
  8850. wb.Save(file);
  8851. }
  8852. /// <summary>
  8853. /// 酒店预订
  8854. /// 确认单
  8855. /// </summary>
  8856. /// <param name="_dto"></param>
  8857. /// <returns></returns>
  8858. [HttpPost]
  8859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8860. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  8861. {
  8862. try
  8863. {
  8864. #region 参数验证
  8865. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8866. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8867. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8868. #region 团组操作权限验证 76 酒店预定模块
  8869. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8870. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8871. #endregion
  8872. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8873. #region 页面操作权限验证
  8874. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8875. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8876. #endregion
  8877. #endregion
  8878. //团组信息
  8879. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  8880. //酒店数据
  8881. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  8882. if (listhoteldata.Count < 0)
  8883. {
  8884. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  8885. }
  8886. //利datatable存储
  8887. DataTable dt = new DataTable();
  8888. dt.Columns.Add("CheckInDate", typeof(string));
  8889. dt.Columns.Add("City", typeof(string));
  8890. dt.Columns.Add("Hotel", typeof(string));
  8891. dt.Columns.Add("Room", typeof(string));
  8892. for (int i = 0; i < listhoteldata.Count; i++)
  8893. {
  8894. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  8895. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  8896. while (dayStart < dayEnd)
  8897. {
  8898. string temp = "";
  8899. DataRow row = dt.NewRow();
  8900. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  8901. row["City"] = listhoteldata[i].City;
  8902. row["Hotel"] = listhoteldata[i].HotelName;
  8903. if (listhoteldata[i].SingleRoomCount > 0)
  8904. {
  8905. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  8906. }
  8907. if (listhoteldata[i].DoubleRoomCount > 0)
  8908. {
  8909. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  8910. }
  8911. if (listhoteldata[i].SuiteRoomCount > 0)
  8912. {
  8913. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  8914. }
  8915. if (listhoteldata[i].OtherRoomCount > 0)
  8916. {
  8917. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  8918. }
  8919. row["Room"] = temp;
  8920. dt.Rows.Add(row);
  8921. dayStart = dayStart.AddDays(1);
  8922. }
  8923. }
  8924. Dictionary<string, string> dic = new Dictionary<string, string>();
  8925. dic.Add("Dele", di.TeamName);
  8926. dic.Add("City", di.VisitCountry);
  8927. //模板路径
  8928. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  8929. //载入模板
  8930. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  8931. DocumentBuilder builder = new DocumentBuilder(doc);
  8932. foreach (var key in dic.Keys)
  8933. {
  8934. builder.MoveToBookmark(key);
  8935. builder.Write(dic[key]);
  8936. }
  8937. //获取word里所有表格
  8938. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8939. //获取所填表格的序数
  8940. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8941. var rowStart = tableOne.Rows[0]; //获取第1行
  8942. //循环赋值
  8943. for (int i = 0; i < dt.Rows.Count; i++)
  8944. {
  8945. builder.MoveToCell(0, i + 1, 0, 0);
  8946. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  8947. builder.MoveToCell(0, i + 1, 1, 0);
  8948. builder.Write(dt.Rows[i]["City"].ToString());
  8949. builder.MoveToCell(0, i + 1, 2, 0);
  8950. builder.Write(dt.Rows[i]["Hotel"].ToString());
  8951. builder.MoveToCell(0, i + 1, 3, 0);
  8952. builder.Write(dt.Rows[i]["Room"].ToString());
  8953. }
  8954. //删除多余行
  8955. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  8956. {
  8957. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  8958. }
  8959. string strFileName = di.TeamName + "酒店确认单.doc";
  8960. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  8961. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  8962. return Ok(JsonView(true, "成功", url));
  8963. }
  8964. catch (Exception ex)
  8965. {
  8966. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  8967. }
  8968. }
  8969. #endregion
  8970. #region 团组状态
  8971. /// <summary>
  8972. /// 团组状态列表 Page
  8973. /// </summary>
  8974. /// <param name="dto">团组列表请求dto</param>
  8975. /// <returns></returns>
  8976. [HttpPost]
  8977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8978. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  8979. {
  8980. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  8981. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  8982. {
  8983. string sqlWhere = string.Empty;
  8984. if (dto.IsSure == 0) //未完成
  8985. {
  8986. sqlWhere += string.Format(@" And IsSure = 0");
  8987. }
  8988. else if (dto.IsSure == 1) //已完成
  8989. {
  8990. sqlWhere += string.Format(@" And IsSure = 1");
  8991. }
  8992. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  8993. {
  8994. string tj = dto.SearchCriteria;
  8995. 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}%')",
  8996. tj, tj, tj, tj, tj);
  8997. }
  8998. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  8999. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9000. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9001. From (
  9002. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9003. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9004. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9005. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9006. From Grp_DelegationInfo gdi
  9007. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9008. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9009. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9010. Where gdi.IsDel = 0 {0}
  9011. ) temp ", sqlWhere);
  9012. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9013. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9014. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9015. }
  9016. else
  9017. {
  9018. return Ok(JsonView(false, "查询失败"));
  9019. }
  9020. }
  9021. /// <summary>
  9022. /// 团组状态
  9023. /// 设置操作完成
  9024. /// </summary>
  9025. /// <param name="dto">团组列表请求dto</param>
  9026. /// <returns></returns>
  9027. [HttpPost]
  9028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9029. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9030. {
  9031. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9032. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9033. {
  9034. Id = dto.Id,
  9035. IsSure = 1
  9036. };
  9037. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9038. .UpdateColumns(it => new { it.IsSure })
  9039. .WhereColumns(it => new { it.Id })
  9040. .ExecuteCommandAsync();
  9041. if (result > 0)
  9042. {
  9043. return Ok(JsonView(true, "操作完成!"));
  9044. }
  9045. return Ok(JsonView(false, "操作失败!"));
  9046. }
  9047. #endregion
  9048. #region 保险费用录入
  9049. /// <summary>
  9050. /// 根据团组Id查询保险费用列表
  9051. /// </summary>
  9052. /// <param name="dto"></param>
  9053. /// <returns></returns>
  9054. [HttpPost]
  9055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9056. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9057. {
  9058. try
  9059. {
  9060. Result groupData = await _customersRep.CustomersByDiId(dto);
  9061. if (groupData.Code != 0)
  9062. {
  9063. return Ok(JsonView(false, groupData.Msg));
  9064. }
  9065. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9066. }
  9067. catch (Exception ex)
  9068. {
  9069. return Ok(JsonView(false, ex.Message));
  9070. }
  9071. }
  9072. /// <summary>
  9073. /// 根据保险费用Id查询保险费用详细
  9074. /// </summary>
  9075. /// <param name="dto"></param>
  9076. /// <returns></returns>
  9077. [HttpPost]
  9078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9079. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9080. {
  9081. try
  9082. {
  9083. Result groupData = await _customersRep.CustomersById(dto);
  9084. if (groupData.Code != 0)
  9085. {
  9086. return Ok(JsonView(false, groupData.Msg));
  9087. }
  9088. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9089. }
  9090. catch (Exception ex)
  9091. {
  9092. return Ok(JsonView(false, ex.Message));
  9093. }
  9094. }
  9095. /// <summary>
  9096. /// 保险费用录入页面初始化绑定
  9097. /// </summary>
  9098. /// <param name="dto"></param>
  9099. /// <returns></returns>
  9100. [HttpPost]
  9101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9102. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9103. {
  9104. try
  9105. {
  9106. Result groupData = await _customersRep.CustomersInitialize(dto);
  9107. if (groupData.Code != 0)
  9108. {
  9109. return Ok(JsonView(false, groupData.Msg));
  9110. }
  9111. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9112. }
  9113. catch (Exception ex)
  9114. {
  9115. return Ok(JsonView(false, ex.Message));
  9116. }
  9117. }
  9118. /// <summary>
  9119. /// 保险费用操作(Status:1.新增,2.修改)
  9120. /// </summary>
  9121. /// <param name="dto"></param>
  9122. /// <returns></returns>
  9123. [HttpPost]
  9124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9125. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9126. {
  9127. try
  9128. {
  9129. Result groupData = await _customersRep.OpCustomers(dto);
  9130. if (groupData.Code != 0)
  9131. {
  9132. return Ok(JsonView(false, groupData.Msg));
  9133. }
  9134. #region 应用推送
  9135. try
  9136. {
  9137. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9138. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9139. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9140. }
  9141. catch (Exception ex)
  9142. {
  9143. }
  9144. #endregion
  9145. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9146. }
  9147. catch (Exception ex)
  9148. {
  9149. return Ok(JsonView(false, ex.Message));
  9150. }
  9151. }
  9152. /// <summary>
  9153. /// 保险文件上传
  9154. /// </summary>
  9155. /// <param name="file"></param>
  9156. /// <returns></returns>
  9157. [HttpPost]
  9158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9159. public async Task<IActionResult> UploadCus(IFormFile file)
  9160. {
  9161. try
  9162. {
  9163. if (file != null)
  9164. {
  9165. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9166. //文件名称
  9167. string projectFileName = file.FileName;
  9168. //上传的文件的路径
  9169. string filePath = "";
  9170. if (!Directory.Exists(fileDir))
  9171. {
  9172. Directory.CreateDirectory(fileDir);
  9173. }
  9174. //上传的文件的路径
  9175. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9176. using (FileStream fs = System.IO.File.Create(filePath))
  9177. {
  9178. file.CopyTo(fs);
  9179. fs.Flush();
  9180. }
  9181. return Ok(JsonView(true, "上传成功!", projectFileName));
  9182. }
  9183. else
  9184. {
  9185. return Ok(JsonView(false, "上传失败!"));
  9186. }
  9187. }
  9188. catch (Exception ex)
  9189. {
  9190. return Ok(JsonView(false, "程序错误!"));
  9191. throw;
  9192. }
  9193. }
  9194. /// <summary>
  9195. /// 保险删除指定文件
  9196. /// </summary>
  9197. /// <param name="dto"></param>
  9198. /// <returns></returns>
  9199. [HttpPost]
  9200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9201. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9202. {
  9203. try
  9204. {
  9205. string filePath = "";
  9206. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9207. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9208. //int id = 0;
  9209. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9210. // 删除该文件
  9211. try
  9212. {
  9213. System.IO.File.Delete(filePath);
  9214. 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()
  9215. {
  9216. Attachment = "",
  9217. }).ExecuteCommandAsync();
  9218. if (result != 0)
  9219. {
  9220. return Ok(JsonView(true, "成功!"));
  9221. }
  9222. else
  9223. {
  9224. return Ok(JsonView(false, "失败!"));
  9225. }
  9226. }
  9227. catch (Exception)
  9228. {
  9229. 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()
  9230. {
  9231. Attachment = "",
  9232. }).ExecuteCommandAsync();
  9233. if (result != 0)
  9234. {
  9235. return Ok(JsonView(true, "成功!"));
  9236. }
  9237. else
  9238. {
  9239. return Ok(JsonView(false, "失败!"));
  9240. }
  9241. }
  9242. }
  9243. catch (Exception ex)
  9244. {
  9245. return Ok(JsonView(false, "程序错误!"));
  9246. throw;
  9247. }
  9248. }
  9249. /// <summary>
  9250. /// 保险费用操作(删除)
  9251. /// </summary>
  9252. /// <param name="dto"></param>
  9253. /// <returns></returns>
  9254. [HttpPost]
  9255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9256. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9257. {
  9258. try
  9259. {
  9260. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9261. if (!res)
  9262. {
  9263. return Ok(JsonView(false, "删除失败"));
  9264. }
  9265. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9266. {
  9267. IsDel = 1,
  9268. DeleteUserId = dto.DeleteUserId,
  9269. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9270. }).ExecuteCommandAsync();
  9271. return Ok(JsonView(true, "删除成功!"));
  9272. }
  9273. catch (Exception ex)
  9274. {
  9275. return Ok(JsonView(false, "程序错误!"));
  9276. throw;
  9277. }
  9278. }
  9279. #endregion
  9280. #region 接团客户名单 PageId 104
  9281. /// <summary>
  9282. /// 接团客户名单
  9283. /// 迁移数据(慎用!)
  9284. /// </summary>
  9285. /// <param name="dto"></param>
  9286. /// <returns></returns>
  9287. [HttpPost]
  9288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9289. public async Task<IActionResult> PostTourClientListChange()
  9290. {
  9291. try
  9292. {
  9293. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9294. //var groupClinetData1
  9295. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9296. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9297. int updateCount = 0;
  9298. if (oldOAClientList.Count > 0)
  9299. {
  9300. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9301. _sqlSugar.BeginTran();
  9302. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9303. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9304. foreach (var item in oldOAClientList)
  9305. {
  9306. int comId = 0;
  9307. string format = "yyyy-MM-dd HH:mm:ss";
  9308. string data11 = "1990-01-01 00:00";
  9309. var data1 = IsValidDate(item.OPdate, format);
  9310. if (data1) data11 = item.OPdate;
  9311. //客户公司验证
  9312. if (!string.IsNullOrEmpty(item.Company))
  9313. {
  9314. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9315. if (clientComInfo == null) // add
  9316. {
  9317. var addInfo = new Crm_CustomerCompany()
  9318. {
  9319. CompanyAbbreviation = "",
  9320. CompanyFullName = item.Company,
  9321. Address = "",
  9322. PostCodes = "",
  9323. LastedOpUserId = item.OPer,
  9324. LastedOpDt = Convert.ToDateTime(data11),
  9325. CreateUserId = item.OPer,
  9326. CreateTime = Convert.ToDateTime(data11),
  9327. IsDel = 0
  9328. };
  9329. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9330. if (comId1 > 0) comId = comId1;
  9331. }
  9332. else comId = clientComInfo.Id;
  9333. }
  9334. //客户人员验证
  9335. int clientId = 0;
  9336. string name = item.LastName + item.Name;
  9337. if (!string.IsNullOrEmpty(name))
  9338. {
  9339. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9340. if (clientInfo == null)
  9341. {
  9342. DateTime? dateTime = null;
  9343. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9344. if (isDt) dateTime = birthDayDt;
  9345. var addInfo1 = new Crm_DeleClient()
  9346. {
  9347. CrmCompanyId = comId,
  9348. DiId = -1,
  9349. LastName = item.LastName,
  9350. FirstName = item.Name,
  9351. OldName = "",
  9352. Pinyin = item.Pinyin,
  9353. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9354. Marriage = 0,
  9355. Phone = item.Phone,
  9356. Job = item.Job,
  9357. BirthDay = dateTime
  9358. };
  9359. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9360. if (clientId1 > 0) clientId = clientId1;
  9361. }
  9362. else clientId = clientInfo.Id;
  9363. }
  9364. if (clientId < 1)
  9365. {
  9366. continue;
  9367. }
  9368. int airType = 0;
  9369. if (item.AirType == "超经舱") airType = 459;
  9370. else if (item.AirType == "公务舱") airType = 458;
  9371. else if (item.AirType == "经济舱") airType = 460;
  9372. else if (item.AirType == "其他") airType = 565;
  9373. else if (item.AirType == "头等舱") airType = 457;
  9374. var _TourClientListEntity = new Grp_TourClientList()
  9375. {
  9376. DiId = item.Diid,
  9377. ClientId = clientId,
  9378. CreateUserId = item.OPer,
  9379. CreateTime = Convert.ToDateTime(data11),
  9380. Remark = item.Remark,
  9381. IsDel = item.Isdel,
  9382. ShippingSpaceTypeId = airType,
  9383. ShippingSpaceSpecialNeeds = item.AirRemark,
  9384. HotelSpecialNeeds = item.RoomType
  9385. };
  9386. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9387. if (_TourClientList > 0)
  9388. {
  9389. updateCount++;
  9390. }
  9391. }
  9392. _sqlSugar.CommitTran();
  9393. }
  9394. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9395. }
  9396. catch (Exception ex)
  9397. {
  9398. _sqlSugar.RollbackTran();
  9399. return Ok(JsonView(false, ex.Message));
  9400. }
  9401. return Ok(JsonView(true));
  9402. }
  9403. private bool IsValidDate(string dateString, string format)
  9404. {
  9405. DateTime dateValue;
  9406. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9407. return valid;
  9408. }
  9409. /// <summary>
  9410. /// 接团客户名单
  9411. /// 根据团组Id查询List
  9412. /// </summary>
  9413. /// <param name="dto"></param>
  9414. /// <returns></returns>
  9415. [HttpPost]
  9416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9417. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9418. {
  9419. #region 参数验证
  9420. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9421. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9422. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9423. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9424. #region 页面操作权限验证
  9425. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9426. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9427. #endregion
  9428. #endregion
  9429. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9430. if (viewData.Code != 0)
  9431. {
  9432. return Ok(JsonView(false, viewData.Msg));
  9433. }
  9434. return Ok(JsonView(viewData.Data));
  9435. }
  9436. /// <summary>
  9437. /// 接团客户名单
  9438. /// 基础数据 Init
  9439. /// </summary>
  9440. /// <param name="_dto"></param>
  9441. /// <returns></returns>
  9442. [HttpPost]
  9443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9444. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9445. {
  9446. #region 参数验证
  9447. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9448. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9449. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9450. #region 页面操作权限验证
  9451. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9452. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9453. #endregion
  9454. #endregion
  9455. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9456. if (viewData.Code != 0)
  9457. {
  9458. return Ok(JsonView(false, viewData.Msg));
  9459. }
  9460. return Ok(JsonView(viewData.Data));
  9461. }
  9462. /// <summary>
  9463. /// 接团客户名单
  9464. /// 根据 Id查询 Details
  9465. /// </summary>
  9466. /// <param name="_dto"></param>
  9467. /// <returns></returns>
  9468. [HttpPost]
  9469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9470. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9471. {
  9472. #region 参数验证
  9473. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9474. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9475. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9476. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9477. #region 页面操作权限验证
  9478. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9479. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9480. #endregion
  9481. #endregion
  9482. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9483. if (viewData.Code != 0)
  9484. {
  9485. return Ok(JsonView(false, viewData.Msg));
  9486. }
  9487. return Ok(JsonView(viewData.Data));
  9488. }
  9489. /// <summary>
  9490. /// 接团客户名单
  9491. /// Add Or Edit
  9492. /// </summary>
  9493. /// <param name="_dto"></param>
  9494. /// <returns></returns>
  9495. [HttpPost]
  9496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9497. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9498. {
  9499. #region 参数验证
  9500. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9501. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9502. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9503. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9504. #region 页面操作权限验证
  9505. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9506. if (_dto.Id == 0) //添加
  9507. {
  9508. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9509. }
  9510. else if (_dto.Id >= 0) //修改
  9511. {
  9512. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9513. }
  9514. #endregion
  9515. #endregion
  9516. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9517. if (viewData.Code != 0)
  9518. {
  9519. return Ok(JsonView(false, viewData.Msg));
  9520. }
  9521. return Ok(JsonView(true));
  9522. }
  9523. /// <summary>
  9524. /// 接团客户名单
  9525. /// AddMultiple(添加多个)
  9526. /// </summary>
  9527. /// <param name="_dto"></param>
  9528. /// <returns></returns>
  9529. [HttpPost]
  9530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9531. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9532. {
  9533. #region 参数验证
  9534. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9535. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9536. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9537. #region 页面操作权限验证
  9538. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9539. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9540. #endregion
  9541. #endregion
  9542. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9543. if (viewData.Code != 0)
  9544. {
  9545. return Ok(JsonView(false, viewData.Msg));
  9546. }
  9547. return Ok(JsonView(true));
  9548. }
  9549. /// <summary>
  9550. /// 接团客户名单
  9551. /// Del
  9552. /// </summary>
  9553. /// <param name="_dto"></param>
  9554. /// <returns></returns>
  9555. [HttpPost]
  9556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9557. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9558. {
  9559. #region 参数验证
  9560. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9561. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9562. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9563. #region 页面操作权限验证
  9564. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9565. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9566. #endregion
  9567. #endregion
  9568. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9569. if (viewData.Code != 0)
  9570. {
  9571. return Ok(JsonView(false, viewData.Msg));
  9572. }
  9573. return Ok(JsonView(true));
  9574. }
  9575. /// <summary>
  9576. /// 接团客户名单
  9577. /// 文件下载 客户名单
  9578. /// </summary>
  9579. /// <param name="_dto"></param>
  9580. /// <returns></returns>
  9581. [HttpPost]
  9582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9583. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9584. {
  9585. #region 参数验证
  9586. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9587. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9588. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9589. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9590. #region 页面操作权限验证
  9591. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9592. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9593. #endregion
  9594. #endregion
  9595. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9596. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9597. From Grp_TourClientList tcl
  9598. Left Join
  9599. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9600. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9601. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9602. From Crm_DeleClient dc
  9603. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9604. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9605. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9606. Where dc.IsDel = 0) temp
  9607. On temp.DcId =tcl.ClientId
  9608. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9609. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9610. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9611. //载入模板
  9612. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9613. if (_dto.Language == 1)
  9614. {
  9615. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9616. }
  9617. //载入模板
  9618. var doc = new Document(tempPath);
  9619. DocumentBuilder builder = new DocumentBuilder(doc);
  9620. //获取word里所有表格
  9621. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9622. //获取所填表格的序数
  9623. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9624. var rowStart = tableOne.Rows[0]; //获取第1行
  9625. if (_dto.Language == 0)
  9626. {
  9627. //循环赋值
  9628. for (int i = 0; i < DcList.Count; i++)
  9629. {
  9630. builder.MoveToCell(0, i + 1, 0, 0);
  9631. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9632. builder.MoveToCell(0, i + 1, 1, 0);
  9633. int sex = DcList[i].Sex;
  9634. string sexStr = string.Empty;
  9635. if (sex == 0) sexStr = "男";
  9636. else if (sex == 1) sexStr = "女";
  9637. else sexStr = "未设置";
  9638. builder.Write(sexStr);
  9639. builder.MoveToCell(0, i + 1, 2, 0);
  9640. string birthDay = DcList[i].BirthDay;
  9641. string birthDayStr = string.Empty;
  9642. if (!string.IsNullOrEmpty(birthDay))
  9643. {
  9644. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9645. }
  9646. builder.Write(birthDayStr);
  9647. builder.MoveToCell(0, i + 1, 3, 0);
  9648. string company = "";
  9649. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9650. {
  9651. company = DcList[i].CompanyFullName.ToString();
  9652. }
  9653. builder.Write(company);
  9654. builder.MoveToCell(0, i + 1, 4, 0);
  9655. builder.Write(DcList[i].Job);
  9656. }
  9657. }
  9658. else if (_dto.Language == 1)
  9659. {
  9660. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9661. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9662. //循环赋值
  9663. for (int i = 0; i < DcList.Count; i++)
  9664. {
  9665. string PYName = "";
  9666. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9667. {
  9668. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9669. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9670. PYName = PY_First + " " + PY_Last;
  9671. }
  9672. else
  9673. {
  9674. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9675. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9676. PYName = PY_First + " " + PY_Last;
  9677. }
  9678. builder.MoveToCell(0, i + 1, 0, 0);
  9679. builder.Write(PYName);
  9680. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9681. builder.MoveToCell(0, i + 1, 1, 0);
  9682. builder.Write(sex);
  9683. DateTime birthDt;
  9684. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9685. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  9686. builder.MoveToCell(0, i + 1, 2, 0);
  9687. builder.Write(birthday);
  9688. string company = "";
  9689. try
  9690. {
  9691. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9692. {
  9693. //查询对照表
  9694. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9695. if (tempCec != null)
  9696. {
  9697. company = tempCec.enName;
  9698. }
  9699. //翻译
  9700. else
  9701. {
  9702. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  9703. }
  9704. }
  9705. }
  9706. catch (Exception)
  9707. {
  9708. }
  9709. builder.MoveToCell(0, i + 1, 3, 0);
  9710. builder.Write(company);
  9711. string job = "";
  9712. try
  9713. {
  9714. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9715. {
  9716. //查询对照表
  9717. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9718. if (tempPec != null)
  9719. {
  9720. job = tempPec.enName;
  9721. }
  9722. //翻译
  9723. else
  9724. {
  9725. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  9726. }
  9727. }
  9728. }
  9729. catch (Exception ex)
  9730. {
  9731. }
  9732. builder.MoveToCell(0, i + 1, 4, 0);
  9733. builder.Write(job);
  9734. }
  9735. }
  9736. //删除多余行
  9737. while (tableOne.Rows.Count > DcList.Count + 1)
  9738. {
  9739. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9740. }
  9741. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9742. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9743. doc.Save(fileDir);
  9744. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9745. return Ok(JsonView(true, "操作成功!", Url));
  9746. }
  9747. #endregion
  9748. #region 团组倒推表
  9749. /// <summary>
  9750. /// 倒推表基础数据
  9751. /// Init
  9752. /// </summary>
  9753. /// <param name="dto"></param>
  9754. /// <returns></returns>
  9755. [HttpPost]
  9756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9757. public async Task<IActionResult> PostInvertedListInit()
  9758. {
  9759. var viewData = await _invertedListRep._Init();
  9760. if (viewData.Code != 0)
  9761. {
  9762. return Ok(JsonView(false, viewData.Msg));
  9763. }
  9764. return Ok(JsonView(viewData.Data));
  9765. }
  9766. /// <summary>
  9767. /// 倒推表
  9768. /// Info
  9769. /// </summary>
  9770. /// <param name="dto"></param>
  9771. /// <returns></returns>
  9772. [HttpPost]
  9773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9774. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  9775. {
  9776. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  9777. if (viewData.Code != 0)
  9778. {
  9779. return Ok(JsonView(false, viewData.Msg));
  9780. }
  9781. return Ok(JsonView(viewData.Data));
  9782. }
  9783. /// <summary>
  9784. /// 倒推表
  9785. /// Create
  9786. /// </summary>
  9787. /// <param name="dto"></param>
  9788. /// <returns></returns>
  9789. [HttpPost]
  9790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9791. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  9792. {
  9793. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  9794. if (viewData.Code != 0)
  9795. {
  9796. return Ok(JsonView(false, viewData.Msg));
  9797. }
  9798. return Ok(JsonView(viewData.Data));
  9799. }
  9800. /// <summary>
  9801. /// 倒推表
  9802. /// Update
  9803. /// </summary>
  9804. /// <param name="dto"></param>
  9805. /// <returns></returns>
  9806. [HttpPost]
  9807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9808. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  9809. {
  9810. var viewData = await _invertedListRep._Update(dto);
  9811. if (viewData.Code != 0)
  9812. {
  9813. return Ok(JsonView(false, viewData.Msg));
  9814. }
  9815. return Ok(JsonView(viewData.Data));
  9816. }
  9817. /// <summary>
  9818. /// 倒推表
  9819. /// File Download
  9820. /// </summary>
  9821. /// <param name="dto"></param>
  9822. /// <returns></returns>
  9823. [HttpPost]
  9824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9825. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  9826. {
  9827. var info2 = await _invertedListRep._Info(1, dto.DiId);
  9828. if (info2.Code != 0)
  9829. {
  9830. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  9831. }
  9832. var info1 = info2.Data as InvertedListInfoView;
  9833. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  9834. string teamName = "";
  9835. if (info != null) teamName = info.TeamName;
  9836. //载入模板
  9837. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  9838. DocumentBuilder builder = new DocumentBuilder(doc);
  9839. //利用键值对存放数据
  9840. Dictionary<string, string> dic = new Dictionary<string, string>();
  9841. dic.Add("TeamName", teamName);
  9842. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  9843. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  9844. dic.Add("BPRemark", info1.ApprovalDataRemark);
  9845. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  9846. dic.Add("SQRemark", info1.ApprovalRemark);
  9847. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  9848. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  9849. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  9850. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  9851. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  9852. dic.Add("QZRemark", info1.VisaInformationRemark);
  9853. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  9854. dic.Add("SQQZRemark", info1.SendVisaRemark);
  9855. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  9856. dic.Add("CQRemark", info1.IssueVisaRemark);
  9857. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  9858. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  9859. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  9860. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  9861. #region 填充word模板书签内容
  9862. foreach (var key in dic.Keys)
  9863. {
  9864. builder.MoveToBookmark(key);
  9865. builder.Write(dic[key]);
  9866. }
  9867. #endregion
  9868. var fileDir = AppSettingsHelper.Get("WordBasePath");
  9869. string fileName = $"{teamName}团出行准备流程表.doc";
  9870. string filePath = fileDir + $@"InvertedList/{fileName}";
  9871. doc.Save(filePath);
  9872. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  9873. return Ok(JsonView(true, "操作成功!", Url));
  9874. }
  9875. #endregion
  9876. #region 三公签证费用(签证费、代办费)
  9877. /// <summary>
  9878. /// 三公签证费用(签证费、代办费)
  9879. /// List
  9880. /// </summary>
  9881. /// <returns></returns>
  9882. [HttpPost]
  9883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9884. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  9885. {
  9886. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  9887. if (_view.Code != 0)
  9888. {
  9889. return Ok(JsonView(false, _view.Msg));
  9890. }
  9891. return Ok(JsonView(true, "操作成功!", _view.Data));
  9892. }
  9893. /// <summary>
  9894. /// 三公签证费用(签证费、代办费)
  9895. /// Add Or Update
  9896. /// </summary>
  9897. /// <returns></returns>
  9898. [HttpPost]
  9899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9900. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  9901. {
  9902. var _view = await _visaFeeInfoRep._Update(_dto);
  9903. if (_view.Code != 0)
  9904. {
  9905. return Ok(JsonView(false, _view.Msg));
  9906. }
  9907. return Ok(JsonView(true, _view.Msg));
  9908. }
  9909. #endregion
  9910. #region 酒店询价
  9911. /// <summary>
  9912. /// 酒店询价
  9913. /// Init
  9914. /// </summary>
  9915. /// <param name="dto"></param>
  9916. /// <returns></returns>
  9917. [HttpPost]
  9918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9919. public async Task<IActionResult> PostHotelInquiryInit()
  9920. {
  9921. var res = await _hotelInquiryRep._Init();
  9922. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9923. return Ok(JsonView(true, res.Msg, res.Data));
  9924. }
  9925. /// <summary>
  9926. /// 酒店询价
  9927. /// page Item
  9928. /// </summary>
  9929. /// <param name="_dto"></param>
  9930. /// <returns></returns>
  9931. [HttpPost]
  9932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9933. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  9934. {
  9935. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  9936. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9937. var view = res.Data as PageDataViewBase;
  9938. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  9939. }
  9940. /// <summary>
  9941. /// 酒店询价
  9942. /// info
  9943. /// </summary>
  9944. /// <param name="_dto"></param>
  9945. /// <returns></returns>
  9946. [HttpPost]
  9947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9948. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  9949. {
  9950. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  9951. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9952. return Ok(JsonView(true, res.Msg, res.Data));
  9953. }
  9954. /// <summary>
  9955. /// 酒店询价
  9956. /// Add Or Edit
  9957. /// </summary>
  9958. /// <param name="_dto"></param>
  9959. /// <returns></returns>
  9960. [HttpPost]
  9961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9962. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  9963. {
  9964. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  9965. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9966. return Ok(JsonView(true, res.Msg, res.Data));
  9967. }
  9968. /// <summary>
  9969. /// 酒店询价
  9970. /// Del
  9971. /// </summary>
  9972. /// <param name="_dto"></param>
  9973. /// <returns></returns>
  9974. [HttpPost]
  9975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9976. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  9977. {
  9978. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  9979. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9980. return Ok(JsonView(true, res.Msg, res.Data));
  9981. }
  9982. #endregion
  9983. #region 下载匹配op行程单
  9984. /// <summary>
  9985. /// 匹配op行程单
  9986. /// Init
  9987. /// </summary>
  9988. /// <param name="dto">团组列表请求dto</param>
  9989. /// <returns></returns>
  9990. [HttpPost]
  9991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9992. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  9993. {
  9994. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  9995. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9996. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  9997. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  9998. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  9999. .Where(it => it.IsDel == 0)
  10000. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10001. .OrderByDescending(it => it.CreateUserId)
  10002. .ToList();
  10003. if (groupInfos.Count < 1) return Ok(JsonView(false,"暂无和你相关的团组信息!"));
  10004. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10005. var diids = groupInfos.Select(it => it.Id).ToList();
  10006. List<string> countrys = new List<string>();
  10007. foreach (var item in country)
  10008. {
  10009. var data = _groupRepository.FormartTeamName(item);
  10010. var dataArray = _groupRepository.GroupSplitCountry(data);
  10011. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10012. }
  10013. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10014. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10015. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10016. foreach (var item in areaItem)
  10017. {
  10018. string areaStr = item.Value;
  10019. if (!string.IsNullOrEmpty(areaStr))
  10020. {
  10021. string[] str1 = areaStr.Split("-");
  10022. if (str1.Length > 0)
  10023. {
  10024. areaArray.AddRange(str1);
  10025. }
  10026. }
  10027. }
  10028. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10029. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10030. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10031. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10032. .ToList();
  10033. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10034. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10035. .Where(it => countriesIds.Contains(it.Id))
  10036. .Select(it => new { it.Id, Name = it.Name_CN })
  10037. .ToList();
  10038. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName) )
  10039. .Select(it => it.TeamName).ToList();
  10040. stopwatch.Stop();
  10041. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = cityDatas }));
  10042. }
  10043. ///// <summary>
  10044. ///// 匹配op行程单
  10045. ///// Init 查询区域数据
  10046. ///// </summary>
  10047. ///// <param name="dto">团组列表请求dto</param>
  10048. ///// <returns></returns>
  10049. //[HttpPost]
  10050. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10051. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10052. //{
  10053. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10054. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10055. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10056. // if (string.IsNullOrEmpty(countriesDataStr))
  10057. // {
  10058. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10059. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10060. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10061. // }
  10062. // else
  10063. // {
  10064. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10065. // }
  10066. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10067. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10068. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10069. // List<dynamic> childList = new List<dynamic>();
  10070. // int parentId = dto.CountriesId;
  10071. // if (provinceData.Count > 1)
  10072. // {
  10073. // foreach (var item1 in provinceData)
  10074. // {
  10075. // List<dynamic> childList1 = new List<dynamic>();
  10076. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10077. // foreach (var item2 in citiesData1)
  10078. // {
  10079. // List<dynamic> childList2 = new List<dynamic>();
  10080. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10081. // foreach (var item3 in countiesData1)
  10082. // {
  10083. // childList2.Add(new
  10084. // {
  10085. // id = item3.Id,
  10086. // parentId = item2.Id,
  10087. // level = "district",
  10088. // name = item3.Name_CN,
  10089. // });
  10090. // }
  10091. // childList1.Add(new
  10092. // {
  10093. // id = item2.Id,
  10094. // parentId = item1.Id,
  10095. // level = "city",
  10096. // name = item2.Name_CN,
  10097. // childList = childList2
  10098. // });
  10099. // }
  10100. // childList.Add(new
  10101. // {
  10102. // id = item1.Id,
  10103. // parentId = parentId,
  10104. // level = "province",
  10105. // name = item1.Name_CN,
  10106. // childList = childList1
  10107. // });
  10108. // }
  10109. // //城市
  10110. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10111. // foreach (var item2 in citiesData2)
  10112. // {
  10113. // List<dynamic> childList22 = new List<dynamic>();
  10114. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10115. // foreach (var item3 in countiesData1)
  10116. // {
  10117. // childList22.Add(new
  10118. // {
  10119. // id = item3.Id,
  10120. // parentId = item2.Id,
  10121. // level = "district",
  10122. // name = item3.Name_CN,
  10123. // });
  10124. // }
  10125. // childList.Add(new
  10126. // {
  10127. // id = item2.Id,
  10128. // parentId = parentId,
  10129. // level = "city",
  10130. // name = item2.Name_CN,
  10131. // childList = childList22
  10132. // });
  10133. // }
  10134. // }
  10135. // else
  10136. // {
  10137. // foreach (var item2 in citiesData)
  10138. // {
  10139. // string cname = item2.Name_CN;
  10140. // List<dynamic> childList1 = new List<dynamic>();
  10141. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10142. // foreach (var item3 in countiesData1)
  10143. // {
  10144. // childList1.Add(new
  10145. // {
  10146. // Id = item3.Id,
  10147. // parentId = item2.Id,
  10148. // level = "district",
  10149. // name = item3.Name_CN
  10150. // });
  10151. // }
  10152. // childList.Add(new
  10153. // {
  10154. // id = item2.Id,
  10155. // parentId = parentId,
  10156. // level = "city",
  10157. // name = item2.Name_CN,
  10158. // childList = childList1
  10159. // });
  10160. // }
  10161. // }
  10162. // stopwatch.Stop();
  10163. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10164. //}
  10165. /// <summary>
  10166. /// 匹配op行程单
  10167. /// 接团信息列表 Page
  10168. /// </summary>
  10169. /// <param name="dto">团组列表请求dto</param>
  10170. /// <returns></returns>
  10171. [HttpPost]
  10172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10173. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10174. {
  10175. var swatch = new Stopwatch();
  10176. swatch.Start();
  10177. #region 参数验证
  10178. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10179. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10180. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10181. #region 页面操作权限验证
  10182. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10183. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10184. #endregion
  10185. #endregion
  10186. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10187. {
  10188. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10189. string sqlWhere = "";
  10190. if (!string.IsNullOrEmpty(dto.Country))
  10191. {
  10192. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10193. }
  10194. if (!string.IsNullOrEmpty(dto.Area))
  10195. {
  10196. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10197. }
  10198. if (!string.IsNullOrEmpty(dto.TeamName))
  10199. {
  10200. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10201. }
  10202. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10203. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10204. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10205. swatch.Stop();
  10206. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10207. }
  10208. else
  10209. {
  10210. return Ok(JsonView(false, "查询失败"));
  10211. }
  10212. }
  10213. /// <summary>
  10214. /// 匹配op行程单
  10215. /// 行程单下载
  10216. /// </summary>
  10217. /// <param name="dto">团组列表请求dto</param>
  10218. /// <returns></returns>
  10219. [HttpPost]
  10220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10221. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10222. {
  10223. #region 参数验证
  10224. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10225. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10226. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10227. #region 页面操作权限验证
  10228. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10229. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10230. #endregion
  10231. #endregion
  10232. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10233. {
  10234. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10235. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10236. }
  10237. else
  10238. {
  10239. return Ok(JsonView(false, "下载失败!"));
  10240. }
  10241. }
  10242. #endregion
  10243. #region 国家信息 数据 注释
  10244. //[HttpPost]
  10245. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10246. //{
  10247. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10248. // foreach (var item in dto)
  10249. // {
  10250. // infos.Add(new Grp_GroupsTaskAssignment()
  10251. // {
  10252. // DIId = item,
  10253. // CTId = 82,
  10254. // UId = 248,
  10255. // IsEnable = 1,
  10256. // CreateUserId = 233,
  10257. // CreateTime = DateTime.Now,
  10258. // IsDel = 0
  10259. // });
  10260. // infos.Add(new Grp_GroupsTaskAssignment()
  10261. // {
  10262. // DIId = item,
  10263. // CTId = 82,
  10264. // UId = 286,
  10265. // IsEnable = 1,
  10266. // CreateUserId = 233,
  10267. // CreateTime = DateTime.Now,
  10268. // IsDel = 0
  10269. // });
  10270. // }
  10271. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10272. // return Ok("操作成功");
  10273. //}
  10274. //public class paramJsonDto
  10275. //{
  10276. // public List<CountriesInfo> str { get; set; }
  10277. //}
  10278. //[HttpPost]
  10279. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10280. //{
  10281. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10282. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10283. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10284. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10285. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10286. // _sqlSugar.BeginTran();
  10287. // int countitiesIndex = 0;
  10288. // foreach (var item in dto.str)
  10289. // {
  10290. // dynamic data = item.c;
  10291. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10292. // if (data != null)
  10293. // {
  10294. // countitiesIndex++;
  10295. // foreach (var item1 in data)
  10296. // {
  10297. // string cnname = item1.cn;
  10298. // string enname = item1.en;
  10299. // Sys_Cities provinceInfo = new Sys_Cities()
  10300. // {
  10301. // CountriesId = countriesId,
  10302. // Name_CN = cnname,
  10303. // Name_EN = enname,
  10304. // ParentId = 0,
  10305. // IsCapital = 1,
  10306. // CreateUserId = 208,
  10307. // CreateTime = DateTime.Now,
  10308. // IsDel = 0
  10309. // };
  10310. // if (item1.lv == "province") //省份
  10311. // {
  10312. // provinceInfo.Level = 1;
  10313. // int provinceId = 0;
  10314. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10315. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10316. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10317. // var data1 = item1.c;
  10318. // foreach (var item2 in data1)
  10319. // {
  10320. // if (item2.lv == "city")
  10321. // {
  10322. // string citycnname = item2.cn;
  10323. // string cityenname = item2.en;
  10324. // Sys_Cities cityInfo = new Sys_Cities()
  10325. // {
  10326. // CountriesId = countriesId,
  10327. // ParentId = provinceId,
  10328. // Level = 2,
  10329. // Name_CN = citycnname,
  10330. // Name_EN = cityenname,
  10331. // IsCapital = 1,
  10332. // CreateUserId = 208,
  10333. // CreateTime = DateTime.Now,
  10334. // IsDel = 0
  10335. // };
  10336. // if (item2.c != null)
  10337. // {
  10338. // int cityId = 0;
  10339. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10340. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10341. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10342. // foreach (var item3 in item2.c)
  10343. // {
  10344. // if (item3.lv == "district")
  10345. // {
  10346. // var districtInfo = new Sys_Cities()
  10347. // {
  10348. // CountriesId = countriesId,
  10349. // Name_CN = item3.cn,
  10350. // Name_EN = item3.en,
  10351. // Level = 3,
  10352. // ParentId = cityId,
  10353. // IsCapital = 1,
  10354. // CreateUserId = 208,
  10355. // CreateTime = DateTime.Now,
  10356. // IsDel = 0
  10357. // };
  10358. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10359. // //{
  10360. // districts.Add(districtInfo);
  10361. // //}
  10362. // }
  10363. // }
  10364. // }
  10365. // else
  10366. // {
  10367. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10368. // //{
  10369. // cities.Add(cityInfo);
  10370. // //}
  10371. // }
  10372. // }
  10373. // }
  10374. // }
  10375. // else if (item1.lv == "city")//城市
  10376. // {
  10377. // provinceInfo.Level = 2;
  10378. // if (item1.c != null)
  10379. // {
  10380. // int cityId = 0;
  10381. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10382. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10383. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10384. // foreach (var item3 in item1.c)
  10385. // {
  10386. // if (item3.lv == "district")
  10387. // {
  10388. // var districtInfo = new Sys_Cities()
  10389. // {
  10390. // CountriesId = countriesId,
  10391. // Name_CN = item3.cn,
  10392. // Name_EN = item3.en,
  10393. // Level = 3,
  10394. // ParentId = cityId,
  10395. // IsCapital = 1,
  10396. // CreateUserId = 208,
  10397. // CreateTime = DateTime.Now,
  10398. // IsDel = 0
  10399. // };
  10400. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10401. // //{
  10402. // districts.Add(districtInfo);
  10403. // //}
  10404. // }
  10405. // }
  10406. // }
  10407. // else
  10408. // {
  10409. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10410. // //{
  10411. // cities.Add(provinceInfo);
  10412. // //}
  10413. // }
  10414. // }
  10415. // }
  10416. // }
  10417. // }
  10418. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10419. // cities = cities.Distinct().ToList();
  10420. // districts = districts.Distinct().ToList();
  10421. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10422. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10423. // cities.AddRange(districts);
  10424. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10425. // //_sqlSugar.RollbackTran();
  10426. // _sqlSugar.CommitTran();
  10427. // return Ok(JsonView(false, "操作成功!"));
  10428. //}
  10429. //[HttpPost]
  10430. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10431. //{
  10432. // List<CountitiesInfo> infos = dto.MyProperty;
  10433. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10434. // _sqlSugar.BeginTran();
  10435. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10436. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10437. // foreach (var item in infos)
  10438. // {
  10439. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10440. // if (countryInfo != null)
  10441. // {
  10442. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10443. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10444. // if (cityInfo1 != null)
  10445. // {
  10446. // cityInfo1.IsCapital = 0;
  10447. // cityInfos.Add(cityInfo1);
  10448. // }
  10449. // }
  10450. // }
  10451. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10452. // .UpdateColumns(it => it.IsCapital)
  10453. // .WhereColumns(it => it.Id)
  10454. // .ExecuteCommand();
  10455. // //_sqlSugar.RollbackTran();
  10456. // _sqlSugar.CommitTran();
  10457. // return Ok(JsonView(false, "操作成功!"));
  10458. //}
  10459. //public class CounrtiesDto
  10460. //{
  10461. // public List<CountitiesInfo> MyProperty { get; set; }
  10462. //}
  10463. //public class CountitiesInfo
  10464. //{
  10465. // /// <summary>
  10466. // /// 圣约翰
  10467. // /// </summary>
  10468. // public string capital_name_chinese { get; set; }
  10469. // /// <summary>
  10470. // ///
  10471. // /// </summary>
  10472. // public string capital_name { get; set; }
  10473. // /// <summary>
  10474. // ///
  10475. // /// </summary>
  10476. // public string country_type { get; set; }
  10477. // /// <summary>
  10478. // /// 安提瓜和巴布达
  10479. // /// </summary>
  10480. // public string country_name_chinese { get; set; }
  10481. // /// <summary>
  10482. // /// 安提瓜和巴布达
  10483. // /// </summary>
  10484. // public string country_name_chinese_short { get; set; }
  10485. // /// <summary>
  10486. // /// 安提瓜和巴布达
  10487. // /// </summary>
  10488. // public string country_name_chinese_UN { get; set; }
  10489. // /// <summary>
  10490. // ///
  10491. // /// </summary>
  10492. // public string country_name_english_abbreviation { get; set; }
  10493. // /// <summary>
  10494. // ///
  10495. // /// </summary>
  10496. // public string country_name_english_formal { get; set; }
  10497. // /// <summary>
  10498. // ///
  10499. // /// </summary>
  10500. // public string country_name_english_UN { get; set; }
  10501. // /// <summary>
  10502. // ///
  10503. // /// </summary>
  10504. // public string continent_name { get; set; }
  10505. // /// <summary>
  10506. // ///
  10507. // /// </summary>
  10508. // public string subregion_name { get; set; }
  10509. // /// <summary>
  10510. // ///
  10511. // /// </summary>
  10512. // public string country_code2 { get; set; }
  10513. // /// <summary>
  10514. // ///
  10515. // /// </summary>
  10516. // public string country_code3 { get; set; }
  10517. // /// <summary>
  10518. // ///
  10519. // /// </summary>
  10520. // public string phone_code { get; set; }
  10521. //}
  10522. //public class CountriesInfo : BasicInfo
  10523. //{
  10524. // public List<CitiesInfo> c { get; set; }
  10525. //}
  10526. //public class CitiesInfo : BasicInfo
  10527. //{
  10528. // public List<AreaInfo> c { get; set; }
  10529. //}
  10530. //public class AreaInfo : BasicInfo
  10531. //{
  10532. // public List<AreaInfo> c { get; set; }
  10533. //}
  10534. //public class BasicInfo
  10535. //{
  10536. // public string code { get; set; }
  10537. // public string cn { get; set; }
  10538. // public string lv { get; set; }
  10539. // public string en { get; set; }
  10540. //}
  10541. #endregion
  10542. #region 查看邀请方
  10543. /// <summary>
  10544. /// 查看邀请方
  10545. /// 邀请方信息 Init
  10546. /// </summary>
  10547. /// <param name="dto"></param>
  10548. /// <returns></returns>
  10549. [HttpPost]
  10550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10551. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10552. {
  10553. string sqlWhere = string.Empty;
  10554. if (!string.IsNullOrEmpty(dto.Search))
  10555. {
  10556. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10557. }
  10558. string sql = string.Format($@"Select
  10559. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10560. Id,
  10561. UnitName
  10562. From Res_InvitationOfficialActivityData
  10563. Where IsDel = 0
  10564. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10565. RefAsync<int> total = 0;
  10566. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10567. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10568. }
  10569. /// <summary>
  10570. /// 查看邀请方
  10571. /// 国家信息 Init
  10572. /// </summary>
  10573. /// <param name="dto"></param>
  10574. /// <returns></returns>
  10575. [HttpPost]
  10576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10577. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10578. {
  10579. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10580. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10581. var diids = groupInfos.Select(it => it.Id).ToList();
  10582. List<string> countrys = new List<string>();
  10583. foreach (var item in country)
  10584. {
  10585. var data = _groupRepository.FormartTeamName(item);
  10586. var dataArray = _groupRepository.GroupSplitCountry(data);
  10587. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10588. }
  10589. countrys = countrys.Distinct().ToList();
  10590. for (int i = 0; i < countrys.Count; i++)
  10591. {
  10592. string item = countrys[i];
  10593. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10594. {
  10595. countrys.Remove(item);
  10596. i--;
  10597. }
  10598. }
  10599. RefAsync<int> total = 0;
  10600. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10601. .Where(it => countrys.Contains(it.Name_CN))
  10602. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10603. .Select(it => new { id = it.Id, name = it.Name_CN })
  10604. .ToPageListAsync(dto.PageIndex,dto.PageSize, total);
  10605. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10606. }
  10607. /// <summary>
  10608. /// 查看邀请方
  10609. /// 城市信息 Init
  10610. /// </summary>
  10611. /// <param name="dto"></param>
  10612. /// <returns></returns>
  10613. [HttpPost]
  10614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10615. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10616. {
  10617. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10618. RefAsync<int> total = 0;
  10619. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10620. .Where(it => it.CountriesId == dto.CountiesId)
  10621. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10622. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10623. .Select(it => new { id = it.Id, name = it.Name_CN })
  10624. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10625. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10626. }
  10627. /// <summary>
  10628. /// 查看邀请方
  10629. /// 团组名称 Init
  10630. /// </summary>
  10631. /// <param name="dto"></param>
  10632. /// <returns></returns>
  10633. [HttpPost]
  10634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10635. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10636. {
  10637. var watch = new Stopwatch();
  10638. watch.Start();
  10639. RefAsync<int> total = 0;
  10640. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10641. .InnerJoin<Grp_DelegationInfo>((oa,di) => oa.DiId == di.Id)
  10642. .Where((oa, di) => oa.IsDel == 0)
  10643. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10644. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10645. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10646. .Distinct()
  10647. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10648. watch.Stop();
  10649. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10650. }
  10651. /// <summary>
  10652. /// 查看邀请方
  10653. /// 团组 & 邀请方信息
  10654. /// </summary>
  10655. /// <param name="dto"></param>
  10656. /// <returns></returns>
  10657. [HttpPost]
  10658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10659. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10660. {
  10661. var watch = new Stopwatch();
  10662. watch.Start();
  10663. RefAsync<int> total = 0;
  10664. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10665. .AS("Grp_DelegationInfo")
  10666. .Includes(x => x.InvitingInfos)
  10667. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10668. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10669. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10670. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10671. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10672. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10673. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10674. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10675. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10676. infos.ForEach(x => {
  10677. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10678. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10679. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10680. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10681. });
  10682. watch.Stop();
  10683. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10684. }
  10685. #endregion
  10686. #region 报批行程
  10687. /// <summary>
  10688. /// 报批行程初始化
  10689. /// </summary>
  10690. /// <param name="dto"></param>
  10691. /// <returns></returns>
  10692. [HttpPost]
  10693. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10694. {
  10695. const int chiNumber = 5;
  10696. var jw = JsonView(false);
  10697. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10698. var group = groupList.First();
  10699. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10700. group = groupList.First(x => x.Id == diid);
  10701. if (group == null)
  10702. {
  10703. jw.Msg = "暂无团组!";
  10704. return Ok(jw);
  10705. }
  10706. var data = new
  10707. {
  10708. groupList = groupList.Select(x => new
  10709. {
  10710. x.TeamName,
  10711. x.Id
  10712. }),
  10713. content = new ArrayList(),
  10714. groupInfo = new
  10715. {
  10716. group.VisitDays,
  10717. group.TourCode,
  10718. group.VisitPNumber,
  10719. group.TeamName,
  10720. group.Id,
  10721. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10722. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10723. },
  10724. };
  10725. var resultArr = new ArrayList();
  10726. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10727. if (content.Count == 0)
  10728. {
  10729. var stay = "-";
  10730. var cityPath = "-";
  10731. //添加城市路径以及住宿地
  10732. //黑屏代码数据
  10733. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10734. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10735. {
  10736. jw = JsonView(true, "黑屏代码有误!", data);
  10737. return Ok(jw);
  10738. }
  10739. foreach (DataRow row in dtBlack.Rows)
  10740. {
  10741. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10742. {
  10743. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  10744. return Ok(jw);
  10745. }
  10746. }
  10747. //黑屏代码获取时间区间
  10748. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  10749. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10750. _sqlSugar.BeginTran();
  10751. for (int i = 0; i < timeArr.Count; i++)
  10752. {
  10753. stay = "-";
  10754. cityPath = "-";
  10755. DateTime NewData = DateTime.Parse(timeArr[i]);
  10756. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10757. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10758. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10759. if (tbSelect.Length > 0)
  10760. {
  10761. List<string> threeCodeStr = new List<string>();
  10762. foreach (var item in tbSelect)
  10763. {
  10764. var threeCode = item["Three"].ToString() ?? "";
  10765. if (threeCode.Length == 6)
  10766. {
  10767. var start = threeCode.Substring(0, 3);
  10768. var end = threeCode.Substring(3, 3);
  10769. if (threeCodeStr.Count == 0)
  10770. {
  10771. threeCodeStr.Add(start);
  10772. threeCodeStr.Add(end);
  10773. }
  10774. else
  10775. {
  10776. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  10777. {
  10778. threeCodeStr.Add(end);
  10779. }
  10780. else {
  10781. threeCodeStr.Add(start);
  10782. threeCodeStr.Add(end);
  10783. }
  10784. }
  10785. }
  10786. }
  10787. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  10788. var last = threeCodeStr.Last();
  10789. foreach (var item in threeCodeStr)
  10790. {
  10791. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  10792. if(item.Equals(last))
  10793. {
  10794. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10795. }
  10796. }
  10797. cityPath = cityPath.Trim('-');
  10798. }
  10799. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10800. appro.Diid = diid ?? -1;
  10801. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10802. appro.Id = thisId;
  10803. appro.CreateUserId = dto.UserId;
  10804. appro.CreateTime = DateTime.Now;
  10805. content.Add(appro);
  10806. }
  10807. _sqlSugar.CommitTran();
  10808. }
  10809. foreach (var x in content)
  10810. {
  10811. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  10812. if (chiList.Count < chiNumber)
  10813. {
  10814. for (int i = chiList.Count; i < chiNumber; i++)
  10815. {
  10816. chiList.Add(new Grp_ApprovalTravelDetails());
  10817. }
  10818. }
  10819. resultArr.Add(new
  10820. {
  10821. x.Id,
  10822. x.Date,
  10823. x.Diid,
  10824. chiList = chiList.Select(x1 => new
  10825. {
  10826. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  10827. x1.Details,
  10828. x1.ParentId,
  10829. x1.Id
  10830. })
  10831. });
  10832. }
  10833. data = data with
  10834. {
  10835. content = resultArr,
  10836. };
  10837. jw = JsonView(true,"获取成功!",data);
  10838. return Ok(jw);
  10839. }
  10840. /// <summary>
  10841. /// 报批行程删除
  10842. /// </summary>
  10843. /// <param name="dto"></param>
  10844. /// <returns></returns>
  10845. [HttpPost]
  10846. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  10847. {
  10848. var jw = JsonView(false);
  10849. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  10850. if (group == null)
  10851. {
  10852. jw.Msg = "团组参数有误!";
  10853. return Ok(jw);
  10854. }
  10855. try
  10856. {
  10857. _sqlSugar.BeginTran();
  10858. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  10859. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  10860. {
  10861. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10862. DeleteUserId = dto.uesrId,
  10863. IsDel = 1
  10864. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  10865. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  10866. {
  10867. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10868. DeleteUserId = dto.uesrId,
  10869. IsDel = 1
  10870. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  10871. _sqlSugar.CommitTran();
  10872. jw = JsonView(true, "删除成功");
  10873. }
  10874. catch (Exception ex)
  10875. {
  10876. jw = JsonView(false, ex.Message);
  10877. }
  10878. return Ok(jw);
  10879. }
  10880. /// <summary>
  10881. /// 报批行程保存
  10882. /// </summary>
  10883. /// <param name="dto"></param>
  10884. /// <returns></returns>
  10885. [HttpPost]
  10886. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  10887. {
  10888. var jw = JsonView(false);
  10889. var Find = dto.Arr.Find(x => x.id == 0);
  10890. if (Find != null)
  10891. {
  10892. jw.Msg = "生成的ID为0!";
  10893. return Ok(jw);
  10894. }
  10895. foreach (var item in dto.Arr)
  10896. {
  10897. foreach (var chi in item.chiList)
  10898. {
  10899. if (chi.parentId == 0)
  10900. {
  10901. chi.parentId = item.id;
  10902. }
  10903. }
  10904. }
  10905. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  10906. _sqlSugar.BeginTran();
  10907. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  10908. {
  10909. var parentIds = dto.Arr.Select(x => x.id).ToList();
  10910. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  10911. {
  10912. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10913. DeleteUserId = dto.UserId,
  10914. IsDel = 1
  10915. }).ExecuteCommand();
  10916. }
  10917. try
  10918. {
  10919. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  10920. {
  10921. CreateTime = DateTime.Now,
  10922. CreateUserId = dto.UserId,
  10923. Details = x.details,
  10924. ParentId = x.parentId,
  10925. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  10926. Remark = "",
  10927. IsDel = 0
  10928. }).ToList()).ExecuteCommand();
  10929. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  10930. {
  10931. Id = x.id,
  10932. Details = x.details,
  10933. ParentId = x.parentId,
  10934. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  10935. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  10936. {
  10937. Details = x.Details,
  10938. ParentId = x.ParentId,
  10939. Time = x.Time
  10940. }).ExecuteCommand();
  10941. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  10942. {
  10943. Id = x.id,
  10944. Date = x.date,
  10945. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  10946. {
  10947. Date = x.Date
  10948. }).ExecuteCommand();
  10949. _sqlSugar.CommitTran();
  10950. jw = JsonView(true, "保存成功!");
  10951. }
  10952. catch (Exception ex)
  10953. {
  10954. _sqlSugar.RollbackTran();
  10955. jw = JsonView(false, "保存失败!" + ex.Message);
  10956. }
  10957. return Ok(jw);
  10958. }
  10959. /// <summary>
  10960. /// 报批行程生成
  10961. /// </summary>
  10962. /// <param name="dto"></param>
  10963. /// <returns></returns>
  10964. [HttpPost]
  10965. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  10966. {
  10967. var jw = JsonView(false);
  10968. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10969. if (group == null)
  10970. {
  10971. jw.Msg = "暂无该团组!";
  10972. return Ok(jw);
  10973. }
  10974. //黑屏代码数据
  10975. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10976. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10977. {
  10978. jw.Msg = "黑屏代码有误!";
  10979. return Ok(jw);
  10980. }
  10981. foreach (DataRow row in dtBlack.Rows)
  10982. {
  10983. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10984. {
  10985. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  10986. return Ok(jw);
  10987. }
  10988. }
  10989. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10990. var resultArr = new ArrayList();
  10991. if (officialActivitiesArr.Count == 0)
  10992. {
  10993. jw.Msg = "暂无公务出访信息!";
  10994. return Ok(jw);
  10995. }
  10996. try
  10997. {
  10998. _sqlSugar.BeginTran();
  10999. DeleteApprovalJourney(new
  11000. Domain.Dtos.Groups.DeleteApprovalJourney
  11001. {
  11002. Diid = dto.Diid,
  11003. uesrId = dto.Userid
  11004. });
  11005. var stay = "-";
  11006. var cityPath = "-";
  11007. //添加城市路径以及住宿地
  11008. //黑屏代码获取时间区间
  11009. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11010. var empty = "【未收入该三字码!请机票同事录入】";
  11011. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11012. for (int i = 0; i < timeArr.Count; i++)
  11013. {
  11014. stay = "-";
  11015. cityPath = "-";
  11016. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11017. DateTime NewData = DateTime.Parse(timeArr[i]);
  11018. 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();
  11019. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11020. if (tbSelect.Length > 0)
  11021. {
  11022. List<string> threeCodeStr = new List<string>();
  11023. bool isTrade = false;
  11024. string trip = string.Empty;
  11025. var rowLast = tbSelect.Last();
  11026. var rowFirst = tbSelect.First();
  11027. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11028. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11029. var takeOffTime = DateTime.Parse(timeArr[i]);
  11030. var fallToTime = DateTime.Parse(timeArr[i]);
  11031. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11032. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11033. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11034. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11035. foreach (var item in tbSelect)
  11036. {
  11037. var start = string.Empty;
  11038. var end = string.Empty;
  11039. var threeCode = item["Three"].ToString() ?? "";
  11040. if (threeCode.Length == 6)
  11041. {
  11042. start = threeCode.Substring(0, 3);
  11043. end = threeCode.Substring(3, 3);
  11044. if (threeCodeStr.Count == 0)
  11045. {
  11046. threeCodeStr.Add(start);
  11047. threeCodeStr.Add(end);
  11048. }
  11049. else
  11050. {
  11051. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11052. {
  11053. threeCodeStr.Add(end);
  11054. }
  11055. else
  11056. {
  11057. threeCodeStr.Add(start);
  11058. threeCodeStr.Add(end);
  11059. }
  11060. }
  11061. }
  11062. //处理机票信息
  11063. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11064. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11065. if (start_Object == null)
  11066. {
  11067. start_Object = new Res_ThreeCode()
  11068. {
  11069. AirPort = empty,
  11070. AirPort_En = empty,
  11071. City = empty,
  11072. Country = empty,
  11073. Four = empty,
  11074. Three = empty,
  11075. };
  11076. }
  11077. if (end_Object == null)
  11078. {
  11079. end_Object = new Res_ThreeCode()
  11080. {
  11081. AirPort = empty,
  11082. AirPort_En = empty,
  11083. City = empty,
  11084. Country = empty,
  11085. Four = empty,
  11086. Three = empty,
  11087. };
  11088. }
  11089. //机型判断
  11090. string airModel = item["AirModel"].ToString();
  11091. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11092. string flightTime = item["FlightTime"].ToString();
  11093. if (flightTime!.Contains(":"))
  11094. {
  11095. flightTime = flightTime.Replace(":", "小时");
  11096. flightTime += "分钟";
  11097. }
  11098. if (flightTime.Contains("H"))
  11099. {
  11100. flightTime = flightTime.Replace("H", "小时");
  11101. }
  11102. if (flightTime.Contains("M"))
  11103. {
  11104. flightTime = flightTime.Replace("M", "分钟");
  11105. }
  11106. //航班号
  11107. string flightcode = item["Fliagtcode"].ToString();
  11108. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11109. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11110. if (aircompany == null)
  11111. {
  11112. aircompany = new Res_AirCompany
  11113. {
  11114. CnName = hsEmpty,
  11115. EnName = hsEmpty,
  11116. ShortCode = hsEmpty,
  11117. };
  11118. }
  11119. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11120. trip += $" 从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n ({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11121. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11122. if (isTrade)
  11123. {
  11124. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转时间: 行李直达)";
  11125. }
  11126. else
  11127. {
  11128. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11129. }
  11130. }
  11131. chiarr.Add(new Grp_ApprovalTravelDetails
  11132. {
  11133. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11134. CreateTime = DateTime.Now,
  11135. CreateUserId = dto.Userid,
  11136. ParentId = 0,
  11137. Details = trip
  11138. }) ;
  11139. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11140. var last = threeCodeStr.Last();
  11141. foreach (var item in threeCodeStr)
  11142. {
  11143. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11144. if (item.Equals(last))
  11145. {
  11146. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11147. }
  11148. }
  11149. cityPath = cityPath.Trim('-');
  11150. }
  11151. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11152. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11153. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11154. appro.Diid = dto.Diid;
  11155. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11156. appro.Id = thisId;
  11157. appro.CreateUserId = dto.Userid;
  11158. appro.CreateTime = DateTime.Now;
  11159. foreach (var item in gwinfo)
  11160. {
  11161. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11162. chi.Details = "拜访" + item.Client;
  11163. if (string.IsNullOrWhiteSpace(item.ReqSample))
  11164. {
  11165. chi.Details += "," + item.ReqSample;
  11166. }
  11167. chi.ParentId = thisId;
  11168. chi.Time = item.Time;
  11169. chiarr.Add(chi);
  11170. }
  11171. if (chiarr.Count < 5)
  11172. {
  11173. for (int j = chiarr.Count; j < 5; j++)
  11174. {
  11175. chiarr.Add(new
  11176. Grp_ApprovalTravelDetails());
  11177. }
  11178. }
  11179. resultArr.Add(new
  11180. {
  11181. appro.Id,
  11182. appro.Date,
  11183. appro.Diid,
  11184. chiList = chiarr.Select(x1 => new
  11185. {
  11186. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11187. x1.Details,
  11188. x1.ParentId,
  11189. x1.Id
  11190. })
  11191. });
  11192. }
  11193. _sqlSugar.CommitTran();
  11194. jw = JsonView(true, "生成成功!", resultArr);
  11195. }
  11196. catch (Exception ex)
  11197. {
  11198. jw.Code = 400;
  11199. jw.Msg = "生成失败!" + ex.Message;
  11200. }
  11201. return Ok(jw);
  11202. }
  11203. /// <summary>
  11204. /// 报批行程word导出
  11205. /// </summary>
  11206. /// <param name="dto"></param>
  11207. /// <returns></returns>
  11208. [HttpPost]
  11209. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11210. {
  11211. var jw = JsonView(false);
  11212. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11213. if (group == null)
  11214. {
  11215. jw.Msg = "暂无该团组!";
  11216. return Ok(jw);
  11217. }
  11218. //模板路径
  11219. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  11220. //载入模板
  11221. Document doc = new Document(tempPath);
  11222. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11223. //获取所填表格的序数
  11224. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11225. Aspose.Words.Tables.Row titleRowClone = null;
  11226. Aspose.Words.Tables.Row CenterRowClone = null;
  11227. int index = 0;
  11228. int indexChi = 0;
  11229. int SetIndex = 0;
  11230. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11231. //获取数据,放到datatable
  11232. foreach (var item in ApprovalTravelArr)
  11233. {
  11234. if (index > 0)
  11235. {
  11236. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11237. tableOne.AppendChild(titleRowClone);
  11238. }
  11239. var textTime = item.Date;
  11240. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11241. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11242. SetIndex++;
  11243. if (ChiRep.Count > 0)
  11244. {
  11245. foreach (var itemChi in ChiRep)
  11246. {
  11247. var txtTime = itemChi.Time;
  11248. var txtDetail = itemChi.Details;
  11249. if (indexChi > 0)
  11250. {
  11251. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11252. tableOne.AppendChild(CenterRowClone);
  11253. }
  11254. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11255. {
  11256. SetCells(tableOne, doc, SetIndex, 0, "");
  11257. SetCells(tableOne, doc, SetIndex, 1, "");
  11258. indexChi++;
  11259. SetIndex++;
  11260. break;
  11261. }
  11262. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11263. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11264. indexChi++;
  11265. SetIndex++;
  11266. }
  11267. }
  11268. else
  11269. {
  11270. if (indexChi > 0)
  11271. {
  11272. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11273. tableOne.AppendChild(CenterRowClone);
  11274. }
  11275. SetCells(tableOne, doc, SetIndex, 0, "");
  11276. SetCells(tableOne, doc, SetIndex, 1, "");
  11277. indexChi++;
  11278. SetIndex++;
  11279. }
  11280. index++;
  11281. }
  11282. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11283. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11284. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11285. jw.Code = 200;
  11286. jw.Msg = "";
  11287. return Ok(jw);
  11288. }
  11289. private string intToString(int numberVal)
  11290. {
  11291. string numberval = numberVal.ToString();
  11292. Dictionary<char, string> Number = new Dictionary<char, string>();
  11293. Number.Add('1', "一");
  11294. Number.Add('2', "二");
  11295. Number.Add('3', "三");
  11296. Number.Add('4', "四");
  11297. Number.Add('5', "五");
  11298. Number.Add('6', "六");
  11299. Number.Add('7', "七");
  11300. Number.Add('8', "八");
  11301. Number.Add('9', "九");
  11302. string stringNumberVal = string.Empty;
  11303. for (int i = 0; i < numberval.Length; i++)
  11304. {
  11305. if (i == 0)
  11306. {
  11307. stringNumberVal += Number[numberval[i]];
  11308. }
  11309. else if (i >= 1)
  11310. {
  11311. if (numberval[i] == '0')
  11312. {
  11313. stringNumberVal = "十";
  11314. }
  11315. else
  11316. {
  11317. stringNumberVal += "十" + Number[numberval[i]];
  11318. }
  11319. }
  11320. }
  11321. return stringNumberVal;
  11322. }
  11323. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11324. {
  11325. //获取table中的某个单元格,从0开始
  11326. Cell lshCell = table.Rows[rows].Cells[cells];
  11327. //将单元格中的第一个段落移除
  11328. lshCell.FirstParagraph.Remove();
  11329. //新建一个段落
  11330. Paragraph p = new Paragraph(doc);
  11331. var r = new Run(doc, val);
  11332. //把设置的值赋给之前新建的段落
  11333. p.AppendChild(r);
  11334. //将此段落加到单元格内
  11335. lshCell.AppendChild(p);
  11336. }
  11337. [HttpPost]
  11338. public async Task<IActionResult> ServerHttp(string paramStr)
  11339. {
  11340. paramStr = paramStr.TrimEnd('\'');
  11341. paramStr = paramStr.TrimStart('\'');
  11342. JsonView jw = JsonView(false);
  11343. JObject param = JObject.Parse(paramStr);
  11344. if (!param.ContainsKey("url"))
  11345. {
  11346. jw.Msg = "url null";
  11347. return Ok(jw);
  11348. }
  11349. string url = param["url"]!.ToString();
  11350. var methon = "get";
  11351. Dictionary<string, string> bodyValues = null;
  11352. Dictionary<string, string> headValues = null;
  11353. if (param.ContainsKey("methon"))
  11354. {
  11355. methon = param["methon"]!.ToString();
  11356. }
  11357. if (param.ContainsKey("header"))
  11358. {
  11359. var header = param["header"]!.ToString();
  11360. JObject headerJobject = JObject.Parse(header);
  11361. headValues = new Dictionary<string, string>();
  11362. foreach (JProperty item in headerJobject.Properties())
  11363. {
  11364. var value = item.Value.ToString();
  11365. var head = item.Path;
  11366. headValues.Add(head, value);
  11367. }
  11368. }
  11369. if (param.ContainsKey("body"))
  11370. {
  11371. var body = param["body"]!.ToString();
  11372. bodyValues = new Dictionary<string, string>();
  11373. JObject bodyJobject = JObject.Parse(body);
  11374. foreach (JProperty item in bodyJobject.Properties())
  11375. {
  11376. var value = item.Value.ToString();
  11377. var head = item.Path;
  11378. bodyValues.Add(head, value);
  11379. }
  11380. }
  11381. HttpClient client = new HttpClient();
  11382. string responseString = string.Empty;
  11383. if (param.ContainsKey("isJson"))
  11384. {
  11385. }
  11386. if (headValues != null)
  11387. {
  11388. foreach (var item in headValues.Keys)
  11389. {
  11390. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11391. }
  11392. }
  11393. try
  11394. {
  11395. if (methon == "get")
  11396. {
  11397. responseString = await client.GetStringAsync(url);
  11398. }
  11399. else if (methon == "post")
  11400. {
  11401. if (bodyValues == null)
  11402. {
  11403. jw.Msg = "methon post body null";
  11404. return Ok(jw);
  11405. }
  11406. // 数据转化为 key=val 格式
  11407. var content = new FormUrlEncodedContent(bodyValues);
  11408. var response = await client.PostAsync(url, content);
  11409. // 获取数据
  11410. responseString = await response.Content.ReadAsStringAsync();
  11411. }
  11412. else
  11413. {
  11414. jw.Msg = "methon error";
  11415. }
  11416. jw = JsonView(true, "success", responseString);
  11417. }
  11418. catch (Exception ex)
  11419. {
  11420. jw.Msg = "error " + ex.Message;
  11421. jw.Data = ex.StackTrace;
  11422. }
  11423. finally
  11424. {
  11425. client.Dispose();
  11426. }
  11427. return Ok(jw);
  11428. }
  11429. #endregion
  11430. // /// <summary>
  11431. // ///
  11432. // /// </summary>
  11433. // /// <param name="_dto"></param>
  11434. // /// <returns></returns>
  11435. // [HttpPost]
  11436. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11437. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11438. // {
  11439. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11440. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11441. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11442. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11443. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11444. // dic_psg.Add("客人", 974);
  11445. // dic_psg.Add("司机", 975);
  11446. // dic_psg.Add("导游", 976);
  11447. // dic_psg.Add("公司内部人员", 977);
  11448. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11449. // foreach (var item in list_visa)
  11450. // {
  11451. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11452. // temp.Id = item.Id;
  11453. // temp.DIId = item.DIId;
  11454. // temp.VisaClient = item.VisaClient;
  11455. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11456. // temp.VisaCurrency = item.VisaCurrency;
  11457. // temp.IsThird = item.IsThird;
  11458. // if (dic_psg.ContainsKey(item.PassengerType))
  11459. // {
  11460. // temp.PassengerType = dic_psg[item.PassengerType];
  11461. // }
  11462. // else {
  11463. // temp.PassengerType = -1;
  11464. // }
  11465. // temp.VisaNumber = item.VisaNumber;
  11466. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11467. // temp.CreateUserId = item.Operators;
  11468. // DateTime dt_ct;
  11469. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11470. // if (b_ct)
  11471. // {
  11472. // temp.CreateTime = dt_ct;
  11473. // }
  11474. // else
  11475. // {
  11476. // temp.CreateTime = DateTime.Now;
  11477. // }
  11478. // temp.DeleteTime = "";
  11479. // temp.DeleteUserId = 0;
  11480. // temp.Remark = item.Remark;
  11481. // if (string.IsNullOrEmpty(temp.Remark)) {
  11482. // temp.Remark = "";
  11483. // }
  11484. // temp.IsDel = item.IsDel;
  11485. // temp.VisaDescription = item.VisaAttachment;
  11486. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11487. //([Id]
  11488. // ,[DIId]
  11489. // ,[VisaClient]
  11490. // ,[VisaPrice]
  11491. // ,[VisaCurrency]
  11492. // ,[IsThird]
  11493. // ,[PassengerType]
  11494. // ,[VisaNumber]
  11495. // ,[VisaFreeNumber]
  11496. // ,[CreateUserId]
  11497. // ,[CreateTime]
  11498. // ,[DeleteTime]
  11499. // ,[DeleteUserId]
  11500. // ,[Remark]
  11501. // ,[IsDel]
  11502. // ,[visaDescription])
  11503. // VALUES
  11504. // ({0},{1},'{2}',{3},{4}
  11505. //,{5},{6},{7},{8},{9}
  11506. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11507. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11508. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11509. //);
  11510. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11511. // }
  11512. // return Ok(JsonView(true, "操作成功!"));
  11513. // }
  11514. /// <summary>
  11515. /// 123132123
  11516. /// </summary>
  11517. /// <param name="_dto"></param>
  11518. /// <returns></returns>
  11519. [HttpPost]
  11520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11521. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11522. {
  11523. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11524. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11525. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11526. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11527. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11528. dicDetail.Add(789, 1034);
  11529. dicDetail.Add(790, 1035);
  11530. dicDetail.Add(791, 1036);
  11531. dicDetail.Add(792, 1037);
  11532. dicDetail.Add(793, 1038);
  11533. dicDetail.Add(794, 1039);
  11534. dicDetail.Add(795, 1040);
  11535. dicDetail.Add(796, 1041);
  11536. dicDetail.Add(797, 1042);
  11537. dicDetail.Add(798, 1043);
  11538. dicDetail.Add(801, 1044);
  11539. dicDetail.Add(802, 1045);
  11540. dicDetail.Add(803, 1046);
  11541. Dictionary<int, int> dic = new Dictionary<int, int>();
  11542. dic.Add(806, 1027);
  11543. dic.Add(807, 1028);
  11544. dic.Add(808, 1029);
  11545. dic.Add(809, 1030);
  11546. dic.Add(810, 1031);
  11547. dic.Add(811, 1032);
  11548. dic.Add(812, 1033);
  11549. foreach (var item in list_visa)
  11550. {
  11551. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11552. temp.Coefficient = item.coefficient;
  11553. DateTime dtCrt;
  11554. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11555. if (b1)
  11556. {
  11557. temp.CreateTime = dtCrt;
  11558. }
  11559. else
  11560. {
  11561. temp.CreateTime = DateTime.Now;
  11562. }
  11563. temp.CreateUserId = item.Operators;
  11564. temp.DeleteTime = "";
  11565. temp.DeleteUserId = 0;
  11566. temp.DiId = int.Parse(item.DIID);
  11567. temp.FilePath = item.FilePath;
  11568. temp.IsDel = item.IsDel;
  11569. temp.Price = item.Price;
  11570. temp.PriceCount = 1;
  11571. temp.PriceCurrency = item.Currency;
  11572. int detailId = 0;
  11573. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11574. {
  11575. detailId = dicDetail[item.PriceTypeDetail];
  11576. }
  11577. temp.PriceDetailType = detailId;
  11578. temp.PriceDt = DateTime.Now;
  11579. temp.PriceName = item.PriceName;
  11580. temp.PriceSum = item.Price;
  11581. int tid = 0;
  11582. if (dic.ContainsKey(item.PriceType))
  11583. {
  11584. tid = dic[item.PriceType];
  11585. }
  11586. temp.PriceType = tid;
  11587. temp.Remark = item.Remark;
  11588. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11589. }
  11590. return Ok(JsonView(true, "操作成功!"));
  11591. }
  11592. }
  11593. }