GroupsController.cs 424 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155
  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. namespace OASystem.API.Controllers
  67. {
  68. /// <summary>
  69. /// 团组相关
  70. /// </summary>
  71. //[Authorize]
  72. [Route("api/[controller]/[action]")]
  73. public class GroupsController : ControllerBase
  74. {
  75. private readonly GrpScheduleRepository _grpScheduleRep;
  76. private readonly IMapper _mapper;
  77. private readonly DelegationInfoRepository _groupRepository;
  78. private readonly TaskAssignmentRepository _taskAssignmentRep;
  79. private readonly AirTicketResRepository _airTicketResRep;
  80. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  81. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  82. private readonly DelegationEnDataRepository _delegationEnDataRep;
  83. private readonly DelegationVisaRepository _delegationVisaRep;
  84. private readonly VisaPriceRepository _visaPriceRep;
  85. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  86. private readonly HotelPriceRepository _hotelPriceRep;
  87. private readonly CustomersRepository _customersRep;
  88. private readonly MessageRepository _message;
  89. private readonly SqlSugarClient _sqlSugar;
  90. private readonly TourClientListRepository _tourClientListRep;
  91. private readonly TeamRateRepository _teamRateRep;
  92. #region 成本相关
  93. private readonly CheckBoxsRepository _checkBoxs;
  94. private readonly GroupCostRepository _GroupCostRepository;
  95. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  96. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  97. #endregion
  98. private readonly SetDataRepository _setDataRep;
  99. private string url;
  100. private string path;
  101. private readonly EnterExitCostRepository _enterExitCostRep;
  102. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  103. private readonly UsersRepository _usersRep;
  104. private readonly IJuHeApiService _juHeApi;
  105. private readonly InvertedListRepository _invertedListRep;
  106. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  107. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  108. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  109. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  110. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  111. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  112. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  113. InvertedListRepository invertedListRep)
  114. {
  115. _mapper = mapper;
  116. _grpScheduleRep = grpScheduleRep;
  117. _groupRepository = groupRepository;
  118. _taskAssignmentRep = taskAssignmentRep;
  119. _airTicketResRep = airTicketResRep;
  120. _sqlSugar = sqlSugar;
  121. url = AppSettingsHelper.Get("ExcelBaseUrl");
  122. path = AppSettingsHelper.Get("ExcelBasePath");
  123. if (!System.IO.Directory.Exists(path))
  124. {
  125. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  126. }
  127. _decreasePaymentsRep = decreasePaymentsRep;
  128. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  129. _delegationEnDataRep = delegationEnDataRep;
  130. _enterExitCostRep = enterExitCostRep;
  131. _delegationVisaRep = delegationVisaRep;
  132. _message = message;
  133. _visaPriceRep = visaPriceRep;
  134. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  135. _checkBoxs = checkBoxs;
  136. _GroupCostRepository = GroupCostRepository;
  137. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  138. _GroupCostParameterRepository = GroupCostParameterRepository;
  139. _hotelPriceRep = hotelPriceRep;
  140. _customersRep = customersRep;
  141. _setDataRep = setDataRep;
  142. _tourClientListRep = tourClientListRep;
  143. _teamRateRep = teamRateRep;
  144. _hubContext = hubContext;
  145. _usersRep = usersRep;
  146. _juHeApi = juHeApi;
  147. _invertedListRep = invertedListRep;
  148. }
  149. #region 流程管控
  150. /// <summary>
  151. /// 获取团组流程管控信息
  152. /// </summary>
  153. /// <param name="paras">参数Json字符串</param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  158. {
  159. if (string.IsNullOrEmpty(_jsonDto.Paras))
  160. {
  161. return Ok(JsonView(false, "参数为空"));
  162. }
  163. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  164. if (_ScheduleDto != null)
  165. {
  166. if (_ScheduleDto.SearchType == 2)//获取列表
  167. {
  168. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  169. return Ok(JsonView(_grpScheduleViewList));
  170. }
  171. else//获取对象
  172. {
  173. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  174. if (_grpScheduleView != null)
  175. {
  176. return Ok(JsonView(_grpScheduleView));
  177. }
  178. }
  179. }
  180. else
  181. {
  182. return Ok(JsonView(false, "参数反序列化失败"));
  183. }
  184. return Ok(JsonView(false, "暂无数据!"));
  185. }
  186. /// <summary>
  187. /// 修改团组流程管控详细表数据
  188. /// </summary>
  189. /// <param name="paras"></param>
  190. /// <returns></returns>
  191. [HttpPost]
  192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  193. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  194. {
  195. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  196. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  197. .SetColumns(it => it.Duty == _detail.Duty)
  198. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  199. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  200. .SetColumns(it => it.JobContent == _detail.JobContent)
  201. .SetColumns(it => it.Remark == _detail.Remark)
  202. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  203. .Where(s => s.Id == dto.Id)
  204. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  205. .ExecuteCommandAsync();
  206. if (result > 0)
  207. {
  208. return Ok(JsonView(true, "保存成功!"));
  209. }
  210. return Ok(JsonView(false, "保存失败!"));
  211. }
  212. /// <summary>
  213. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  214. /// </summary>
  215. /// <param name="dto"></param>
  216. /// <returns></returns>
  217. [HttpPost]
  218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  219. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  220. {
  221. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  222. _detail.IsDel = 1;
  223. _detail.DeleteUserId = dto.Duty;
  224. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  225. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  226. .SetColumns(it => it.IsDel == _detail.IsDel)
  227. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  228. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  229. .Where(it => it.Id == dto.Id)
  230. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  231. //.WhereColumns(s => s.Id == dto.Id)
  232. .ExecuteCommandAsync();
  233. if (result > 0)
  234. {
  235. return Ok(JsonView(true, "删除成功!"));
  236. }
  237. return Ok(JsonView(false, "删除失败!"));
  238. }
  239. /// <summary>
  240. /// 增加团组流程管控详细表数据
  241. /// </summary>
  242. /// <param name="dto"></param>
  243. /// <returns></returns>
  244. [HttpPost]
  245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  246. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  247. {
  248. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  249. if (DateTime.Now < _detail.ExpectBeginDt)
  250. {
  251. _detail.StepStatus = 0;
  252. }
  253. else
  254. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  255. _detail.StepStatus = 1;
  256. }
  257. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  258. if (result > 0)
  259. {
  260. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  261. return Ok(JsonView(true, "添加成功!", _result));
  262. }
  263. return Ok(JsonView(false, "添加失败!"));
  264. }
  265. #endregion
  266. #region 团组基本信息
  267. /// <summary>
  268. /// 接团信息列表
  269. /// </summary>
  270. /// <param name="dto">团组列表请求dto</param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  275. {
  276. var groupData = await _groupRepository.GetGroupList(dto);
  277. if (groupData.Code != 0)
  278. {
  279. return Ok(JsonView(false, groupData.Msg));
  280. }
  281. return Ok(JsonView(groupData.Data));
  282. }
  283. /// <summary>
  284. /// 接团信息列表 Page
  285. /// </summary>
  286. /// <param name="dto">团组列表请求dto</param>
  287. /// <returns></returns>
  288. [HttpPost]
  289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  290. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  291. {
  292. #region 参数验证
  293. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  294. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  295. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  296. #region 页面操作权限验证
  297. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  298. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  299. #endregion
  300. #endregion
  301. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  302. {
  303. string sqlWhere = string.Empty;
  304. if (dto.IsSure == 0) //未完成
  305. {
  306. sqlWhere += string.Format(@" And IsSure = 0");
  307. }
  308. else if (dto.IsSure == 1) //已完成
  309. {
  310. sqlWhere += string.Format(@" And IsSure = 1");
  311. }
  312. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  313. {
  314. string tj = dto.SearchCriteria;
  315. 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}%')",
  316. tj, tj, tj, tj, tj);
  317. }
  318. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  319. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  320. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  321. JietuanOperator,IsSure,CreateTime
  322. From (
  323. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  324. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  325. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  326. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  327. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  328. From Grp_DelegationInfo gdi
  329. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  330. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  331. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  332. Where gdi.IsDel = 0 {0}
  333. ) temp", sqlWhere);
  334. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  335. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  336. #region 处理所属部门
  337. /*
  338. * 1.sq 和 gyy 等显示 市场部
  339. * 2.王鸽和主管及张总还有管理员号统一国交部
  340. * 2-1. 4 管理员 ,21 张海麟
  341. */
  342. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  343. List<int> userIds1 = new List<int>() { 4, 21 };
  344. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  345. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  346. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  347. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  348. .ToList();
  349. foreach (var item in _DelegationList)
  350. {
  351. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  352. }
  353. #endregion
  354. var _view = new
  355. {
  356. PageFuncAuth = pageFunAuthView,
  357. Data = _DelegationList
  358. };
  359. return Ok(JsonView(true, "查询成功!", _view, total));
  360. }
  361. else
  362. {
  363. return Ok(JsonView(false, "查询失败"));
  364. }
  365. }
  366. /// <summary>
  367. /// 团组列表
  368. /// </summary>
  369. /// <returns></returns>
  370. [HttpPost]
  371. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  372. {
  373. #region 参数验证
  374. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  375. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  376. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  377. #region 页面操作权限验证
  378. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  379. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  380. #endregion
  381. #endregion
  382. if (dto.PortType != 1 && dto.PortType != 2)
  383. {
  384. return Ok(JsonView(false, "查询失败!"));
  385. }
  386. string orderbyStr = "order by gdi.CreateTime Desc";
  387. string sqlWhere = string.Empty;
  388. if (dto.IsSure == 0) //未完成
  389. {
  390. sqlWhere += string.Format(@" And IsSure = 0");
  391. }
  392. else if (dto.IsSure == 1) //已完成
  393. {
  394. sqlWhere += string.Format(@" And IsSure = 1");
  395. }
  396. //团组类型
  397. if (dto.TeamDid > 0)
  398. {
  399. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  400. }
  401. //团组名称
  402. if (!string.IsNullOrEmpty(dto.TeamName))
  403. {
  404. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  405. }
  406. //客户名称
  407. if (!string.IsNullOrEmpty(dto.ClientName))
  408. {
  409. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  410. }
  411. //客户单位
  412. if (!string.IsNullOrEmpty(dto.ClientUnit))
  413. {
  414. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  415. }
  416. //出访时间
  417. if (!string.IsNullOrEmpty(dto.visitDataTime))
  418. {
  419. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  420. orderbyStr = "order by gdi.VisitDate";
  421. }
  422. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  423. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  424. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  425. JietuanOperator,IsSure,CreateTime
  426. From (
  427. Select row_number() over({0}) as Row_Number,
  428. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  429. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  430. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  431. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  432. From Grp_DelegationInfo gdi
  433. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  434. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  435. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  436. Where gdi.IsDel = 0 {1}
  437. ) temp ", orderbyStr, sqlWhere);
  438. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  439. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  440. #region 处理所属部门
  441. /*
  442. * 1.sq 和 gyy 等显示 市场部
  443. * 2.王鸽和主管及张总还有管理员号统一国交部
  444. * 2-1. 4 管理员 ,21 张海麟
  445. */
  446. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  447. List<int> userIds1 = new List<int>() { 4, 21 };
  448. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  449. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  450. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  451. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  452. .ToList();
  453. foreach (var item in _DelegationList)
  454. {
  455. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  456. }
  457. #endregion
  458. var _view = new
  459. {
  460. PageFuncAuth = pageFunAuthView,
  461. Data = _DelegationList
  462. };
  463. return Ok(JsonView(true, "查询成功!", _view, total));
  464. }
  465. /// <summary>
  466. /// 接团信息详情
  467. /// </summary>
  468. /// <param name="dto">团组info请求dto</param>
  469. /// <returns></returns>
  470. [HttpPost]
  471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  472. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  473. {
  474. var groupData = await _groupRepository.GetGroupInfo(dto);
  475. if (groupData.Code != 0)
  476. {
  477. return Ok(JsonView(false, groupData.Msg));
  478. }
  479. return Ok(JsonView(groupData.Data));
  480. }
  481. /// <summary>
  482. /// 接团信息 编辑添加
  483. /// 基础信息数据源
  484. /// </summary>
  485. /// <param name="dto"></param>
  486. /// <returns></returns>
  487. [HttpPost]
  488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  489. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  490. {
  491. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  492. if (groupData.Code != 0)
  493. {
  494. return Ok(JsonView(false, groupData.Msg));
  495. }
  496. return Ok(JsonView(groupData.Data));
  497. }
  498. /// <summary>
  499. /// 接团信息 操作(增改)
  500. /// </summary>
  501. /// <param name="dto"></param>
  502. /// <returns></returns>
  503. [HttpPost]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  506. {
  507. try
  508. {
  509. var groupData = await _groupRepository.GroupOperation(dto);
  510. if (groupData.Code != 0)
  511. {
  512. return Ok(JsonView(false, groupData.Msg));
  513. }
  514. int diId = 0;
  515. //添加时 默认加入团组汇率
  516. if (dto.Status == 1) //添加
  517. {
  518. diId = groupData.Data;
  519. //添加默认币种
  520. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  521. //默认分配权限
  522. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  523. //消息提示 王鸽 主管号
  524. List<int> _managerIds = new List<int>() { 22, 32 };
  525. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  526. if (userIds.Count > 0)
  527. {
  528. userIds.Add(208);
  529. //创建团组管控
  530. GroupStepForDelegation.CreateWorkStep(diId);
  531. //发送消息
  532. string groupName = dto.TeamName;
  533. string createGroupUser = string.Empty;
  534. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  535. if (userInfo != null) createGroupUser = userInfo.CnName;
  536. string title = $"系统通知";
  537. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  538. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  539. }
  540. //默认创建倒推表
  541. await _invertedListRep._Create(dto.UserId, diId);
  542. }
  543. else if (dto.Status == 2)
  544. {
  545. diId = dto.Id;
  546. }
  547. return Ok(JsonView(true, "操作成功!", diId));
  548. }
  549. catch (Exception ex)
  550. {
  551. Logs("[response]" + JsonConvert.SerializeObject(dto));
  552. Logs(ex.Message);
  553. return Ok(JsonView(false, ex.Message));
  554. }
  555. }
  556. /// <summary>
  557. /// 接团流程操作(增改)
  558. /// 安卓端使用 建团时添加客户名单
  559. /// </summary>
  560. /// <param name="dto"></param>
  561. /// <returns></returns>
  562. [HttpPost]
  563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  564. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  565. {
  566. try
  567. {
  568. #region 参数验证
  569. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  570. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  571. #region 页面操作权限验证
  572. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  573. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  574. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  575. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  576. #endregion
  577. #endregion
  578. _sqlSugar.BeginTran();
  579. var _dto = new GroupOperationDto();
  580. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  581. var groupData = await _groupRepository.GroupOperation(_dto);
  582. if (groupData.Code != 0)
  583. {
  584. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  585. }
  586. int diId = 0;
  587. //添加时 默认加入团组汇率
  588. if (dto.Status == 1) //添加
  589. {
  590. diId = groupData.Data;
  591. //添加默认币种
  592. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  593. //默认分配权限
  594. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  595. //消息提示 王鸽 主管号
  596. List<int> _managerIds = new List<int>() { 22, 32 };
  597. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  598. if (userIds.Count > 0)
  599. {
  600. userIds.Add(208);
  601. //创建团组管控
  602. GroupStepForDelegation.CreateWorkStep(diId);
  603. //发送消息
  604. string groupName = dto.TeamName;
  605. string createGroupUser = string.Empty;
  606. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  607. if (userInfo != null) createGroupUser = userInfo.CnName;
  608. string title = $"系统通知";
  609. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  610. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  611. }
  612. }
  613. if (dto.Status == 2)
  614. {
  615. diId = dto.Id;
  616. if (diId == 0)
  617. {
  618. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  619. }
  620. }
  621. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  622. if (viewData.Code != 0)
  623. {
  624. _sqlSugar.RollbackTran();
  625. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  626. }
  627. _sqlSugar.CommitTran();
  628. return Ok(JsonView(true, "添加成功"));
  629. }
  630. catch (Exception ex)
  631. {
  632. _sqlSugar.RollbackTran();
  633. return Ok(JsonView(false, ex.Message));
  634. }
  635. }
  636. /// <summary>
  637. /// 接团信息 操作(删除)
  638. /// </summary>
  639. /// <param name="dto"></param>
  640. /// <returns></returns>
  641. [HttpPost]
  642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  643. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  644. {
  645. try
  646. {
  647. var groupData = await _groupRepository.GroupDel(dto);
  648. if (groupData.Code != 0)
  649. {
  650. return Ok(JsonView(false, groupData.Msg));
  651. }
  652. return Ok(JsonView(true));
  653. }
  654. catch (Exception ex)
  655. {
  656. Logs("[response]" + JsonConvert.SerializeObject(dto));
  657. Logs(ex.Message);
  658. return Ok(JsonView(false, ex.Message));
  659. }
  660. }
  661. /// <summary>
  662. /// 获取团组销售报价号
  663. /// 团组添加时 使用
  664. /// </summary>
  665. /// <returns></returns>
  666. [HttpPost]
  667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  668. public async Task<IActionResult> GetGroupSalesQuoteNo()
  669. {
  670. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  671. if (groupData.Code != 0)
  672. {
  673. return Ok(JsonView(false, groupData.Msg));
  674. }
  675. object salesQuoteNo = new
  676. {
  677. SalesQuoteNo = groupData.Data
  678. };
  679. return Ok(JsonView(salesQuoteNo));
  680. }
  681. /// <summary>
  682. /// 设置确认出团
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  689. {
  690. var groupData = await _groupRepository.ConfirmationGroup(dto);
  691. if (groupData.Code != 0)
  692. {
  693. return Ok(JsonView(false, groupData.Msg));
  694. }
  695. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  696. return Ok(JsonView(true, "操作成功!", groupData.Data));
  697. }
  698. /// <summary>
  699. /// 获取团组名称data And 签证国别Data
  700. /// </summary>
  701. /// <param name="dto"></param>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  706. {
  707. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. return Ok(JsonView(groupData.Data));
  713. }
  714. /// <summary>
  715. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  716. /// </summary>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  721. {
  722. try
  723. {
  724. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  725. if (groupData.Code != 0)
  726. {
  727. return Ok(JsonView(false, groupData.Msg));
  728. }
  729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  730. }
  731. catch (Exception ex)
  732. {
  733. return Ok(JsonView(false, "程序错误!"));
  734. throw;
  735. }
  736. }
  737. #endregion
  738. #region 团组&签证
  739. /// <summary>
  740. /// 根据团组Id获取签证客户信息List
  741. /// </summary>
  742. /// <param name="dto">请求dto</param>
  743. /// <returns></returns>
  744. [HttpPost]
  745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  746. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  747. {
  748. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  749. if (groupData.Code != 0)
  750. {
  751. return Ok(JsonView(false, groupData.Msg));
  752. }
  753. return Ok(JsonView(groupData.Data));
  754. }
  755. /// <summary>
  756. /// IOS获取团组签证拍照上传进度01(团组列表)
  757. /// </summary>
  758. /// <param name="dto">请求dto</param>
  759. /// <returns></returns>
  760. [HttpPost]
  761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  762. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  763. {
  764. if (dto == null)
  765. {
  766. return Ok(JsonView(false, "参数为空"));
  767. }
  768. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  769. return Ok(JsonView(visaList));
  770. }
  771. /// <summary>
  772. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  773. /// </summary>
  774. /// <returns></returns>
  775. [HttpPost]
  776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  777. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  778. {
  779. if (dto == null)
  780. {
  781. return Ok(JsonView(false, "请求错误:"));
  782. }
  783. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  784. return Ok(JsonView(list));
  785. }
  786. /// <summary>
  787. /// IOS获取团组签证拍照上传进度03(相册)
  788. /// </summary>
  789. /// <returns></returns>
  790. [HttpPost]
  791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  792. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  793. {
  794. if (dto == null)
  795. {
  796. return Ok(JsonView(false, "请求错误:"));
  797. }
  798. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  799. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  800. list.ForEach(s => s.url = url);
  801. return Ok(JsonView(list));
  802. }
  803. /// <summary>
  804. /// IOS获取团组签证拍照上传进度04(图片上传)
  805. /// </summary>
  806. /// <param name="dto"></param>
  807. /// <returns></returns>
  808. [HttpPost]
  809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  810. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  811. {
  812. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  813. //if (!string.IsNullOrEmpty(result))
  814. //{
  815. //}
  816. //else {
  817. // return Ok(JsonView(false, "上传失败"));
  818. //}
  819. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  820. int sucNum = 0;
  821. try
  822. {
  823. foreach (var item in dto.base64DataList)
  824. {
  825. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  826. string result = decodeBase64ToImage(item, imageName);
  827. if (!string.IsNullOrEmpty(result))
  828. {
  829. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  830. pic.CreateUserId = dto.CreateUserId;
  831. pic.PicName = imageName;
  832. pic.PicPath = result;
  833. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  834. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  835. if (insertResult > 0)
  836. {
  837. sucNum++;
  838. }
  839. }
  840. }
  841. }
  842. catch (Exception ex)
  843. {
  844. return Ok(JsonView(false, ex.Message));
  845. }
  846. string msg = string.Format(@"成功上传{0}张", sucNum);
  847. return Ok(JsonView(true, msg));
  848. }
  849. private string decodeBase64ToImage(string base64DataURL, string imgName)
  850. {
  851. string filename = "";//声明一个string类型的相对路径
  852. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  853. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  854. try//会有异常抛出,try,catch一下
  855. {
  856. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  857. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  858. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  859. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  860. //文件名称
  861. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  862. //上传的文件的路径
  863. string filePath = "";
  864. if (!Directory.Exists(fileDir))
  865. {
  866. Directory.CreateDirectory(fileDir);
  867. }
  868. //上传的文件的路径
  869. filePath = fileDir + filename;
  870. //string url = HttpRuntime.AppDomainAppPath.ToString();
  871. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  872. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  873. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  874. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  875. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  876. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  877. ms.Close();//关闭当前流,并释放所有与之关联的资源
  878. bitmap.Dispose();
  879. }
  880. catch (Exception e)
  881. {
  882. string massage = e.Message;
  883. Logs("IOS图片上传Error:" + massage);
  884. //filename = e.Message;
  885. }
  886. return filename;//返回相对路径
  887. }
  888. /// <summary>
  889. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  890. /// </summary>
  891. /// <param name="dto"></param>
  892. /// <returns></returns>
  893. [HttpPost]
  894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  895. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  896. {
  897. if (dto == null)
  898. {
  899. return Ok(JsonView(false, "请求错误:"));
  900. }
  901. string msg = "参数错误";
  902. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  903. {
  904. try
  905. {
  906. //_delegationVisaRep.BeginTran();
  907. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  908. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  909. .Where(s => s.Id == dto.visaProgressCustomerId)
  910. .ExecuteCommandAsync();
  911. if (updCount > 0 && dto.publishCode == 1)
  912. {
  913. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  914. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  915. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  916. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  917. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  918. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  919. if (groupData == null)
  920. {
  921. _delegationVisaRep.RollbackTran();
  922. }
  923. string title = string.Format(@"[签证进度更新]");
  924. string content = string.Format(@"测试文本");
  925. bool rst = await _message.AddMsg(new MessageDto()
  926. {
  927. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  928. IssuerId = dto.publisher,
  929. Title = title,
  930. Content = content,
  931. ReleaseTime = DateTime.Now,
  932. UIdList = new List<int> {
  933. 234
  934. }
  935. });
  936. if (rst)
  937. {
  938. return Ok(JsonView(true, "发送通知成功"));
  939. }
  940. }
  941. //_delegationVisaRep.CommitTran();
  942. }
  943. catch (Exception)
  944. {
  945. //_delegationVisaRep.RollbackTran();
  946. }
  947. }
  948. return Ok(JsonView(true, msg));
  949. }
  950. #endregion
  951. #region 团组任务分配
  952. /// <summary>
  953. /// 团组任务分配初始化
  954. /// </summary>
  955. /// <param name="dto"></param>
  956. /// <returns></returns>
  957. [HttpPost]
  958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  959. public async Task<IActionResult> GetTaskAssignmen()
  960. {
  961. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  962. if (groupData.Code != 0)
  963. {
  964. return Ok(JsonView(false, groupData.Msg));
  965. }
  966. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  967. }
  968. /// <summary>
  969. /// 团组任务分配查询
  970. /// </summary>
  971. /// <param name="dto"></param>
  972. /// <returns></returns>
  973. [HttpPost]
  974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  975. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  976. {
  977. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  983. }
  984. /// <summary>
  985. /// 团组任务分配操作
  986. /// </summary>
  987. /// <param name="dto"></param>
  988. /// <returns></returns>
  989. [HttpPost]
  990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  991. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  992. {
  993. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  994. if (groupData.Code != 0)
  995. {
  996. return Ok(JsonView(false, groupData.Msg));
  997. }
  998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  999. }
  1000. #endregion
  1001. #region 团组费用审核
  1002. /// <summary>
  1003. /// 费用审核
  1004. /// 团组列表 Page
  1005. /// </summary>
  1006. /// <param name="_dto">团组列表请求dto</param>
  1007. /// <returns></returns>
  1008. [HttpPost]
  1009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1010. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1011. {
  1012. #region 参数验证
  1013. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1014. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1015. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1016. #region 页面操作权限验证
  1017. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1018. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1019. #endregion
  1020. #endregion
  1021. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1022. {
  1023. string sqlWhere = string.Empty;
  1024. if (_dto.IsSure == 0) //未完成
  1025. {
  1026. sqlWhere += string.Format(@" And IsSure = 0");
  1027. }
  1028. else if (_dto.IsSure == 1) //已完成
  1029. {
  1030. sqlWhere += string.Format(@" And IsSure = 1");
  1031. }
  1032. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1033. {
  1034. string tj = _dto.SearchCriteria;
  1035. 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}%')",
  1036. tj, tj, tj, tj, tj);
  1037. }
  1038. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1039. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1040. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1041. From (
  1042. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1043. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1044. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1045. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1046. From Grp_DelegationInfo gdi
  1047. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1048. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1049. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1050. Where gdi.IsDel = 0 {0}
  1051. ) temp ", sqlWhere);
  1052. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1053. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1054. var _view = new
  1055. {
  1056. PageFuncAuth = pageFunAuthView,
  1057. Data = _DelegationList
  1058. };
  1059. return Ok(JsonView(true, "查询成功!", _view, total));
  1060. }
  1061. else
  1062. {
  1063. return Ok(JsonView(false, "查询失败"));
  1064. }
  1065. }
  1066. /// <summary>
  1067. /// 获取团组费用审核
  1068. /// </summary>
  1069. /// <param name="paras">参数Json字符串</param>
  1070. /// <returns></returns>
  1071. [HttpPost]
  1072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1073. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1074. {
  1075. try
  1076. {
  1077. #region 参数验证
  1078. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1079. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1080. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1082. #region 页面操作权限验证
  1083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1084. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1085. #endregion
  1086. #endregion
  1087. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1088. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1089. #region 费用清单
  1090. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1091. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1092. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1093. List<Grp_CreditCardPayment> entityList = _groupRepository
  1094. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1095. .Where(exp.ToExpression())
  1096. .ToList();
  1097. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1098. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1099. /*
  1100. * 76://酒店预订
  1101. */
  1102. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1103. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1104. .ToListAsync();
  1105. /*
  1106. * 79://车/导游地接
  1107. */
  1108. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1109. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1110. .ToListAsync();
  1111. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1112. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1113. .ToListAsync();
  1114. /*
  1115. * 80: //签证
  1116. */
  1117. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1118. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1119. .ToListAsync();
  1120. /*
  1121. *81: //邀请/公务活动
  1122. */
  1123. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1124. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1125. .ToListAsync();
  1126. /*
  1127. * 82: //团组客户保险
  1128. */
  1129. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1130. /*
  1131. * Lable = 85 机票预订
  1132. */
  1133. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1134. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1135. .ToListAsync();
  1136. /*
  1137. * 85 机票预定
  1138. */
  1139. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1140. /*
  1141. * 98 其他款项
  1142. */
  1143. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1144. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1145. .ToListAsync();
  1146. /*
  1147. * 285:收款退还
  1148. */
  1149. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1150. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1151. .ToListAsync();
  1152. /*
  1153. * 1015: //超支费用
  1154. */
  1155. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1156. /*
  1157. * 币种信息
  1158. */
  1159. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1160. /*
  1161. * 车/导游地接 费用类型
  1162. */
  1163. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1164. /*
  1165. * 用户信息
  1166. */
  1167. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1168. /*
  1169. * 费用模块
  1170. */
  1171. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1172. string priceModule = string.Empty;
  1173. if (sdPriceName != null)
  1174. {
  1175. priceModule = sdPriceName.Name;
  1176. }
  1177. /*
  1178. * 处理详情数据
  1179. */
  1180. foreach (var entity in entityList)
  1181. {
  1182. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1183. _detail.Id = entity.Id;
  1184. _detail.PriceName = priceModule;
  1185. /*
  1186. * 应付款金额
  1187. */
  1188. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1189. string PaymentCurrency_WaitPay = "Unknown";
  1190. string hotelCurrncyCode = "Unknown";
  1191. string hotelCurrncyName = "Unknown";
  1192. if (sdPaymentCurrency_WaitPay != null)
  1193. {
  1194. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1195. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1196. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1197. if (hotelCurrncyCode.Equals("CNY"))
  1198. {
  1199. entity.DayRate = 1.0000M;
  1200. }
  1201. }
  1202. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1203. /*
  1204. * 此次付款金额
  1205. */
  1206. decimal CurrPayStr = 0;
  1207. if (entity.PayPercentage == 0)
  1208. {
  1209. if (entity.PayThenMoney != 0)
  1210. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1211. }
  1212. else
  1213. {
  1214. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1215. }
  1216. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1217. /*
  1218. * 剩余尾款
  1219. */
  1220. decimal BalanceStr = 0;
  1221. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1222. BalanceStr = 0;
  1223. else
  1224. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1225. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1226. /*
  1227. * Bus名称
  1228. */
  1229. _detail.BusName = "待增加";
  1230. /*
  1231. *费用所属
  1232. */
  1233. switch (entity.CTable)
  1234. {
  1235. case 76://酒店预订
  1236. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1237. if (hotelReservations != null)
  1238. {
  1239. string GovernmentRentCode = "", GovernmentRentName = "", CityTaxCode = "", CityTaxName = "", BreakfastCode = "", BreakfastName = "";
  1240. Sys_SetData sdPaymentCurrency_GovernmentRent = currencyItems.Where(s => s.Id == hotelReservations.GovernmentRentCurrency).FirstOrDefault();
  1241. if (sdPaymentCurrency_GovernmentRent != null)
  1242. {
  1243. GovernmentRentCode = sdPaymentCurrency_GovernmentRent.Name;
  1244. GovernmentRentName = sdPaymentCurrency_GovernmentRent.Remark;
  1245. }
  1246. Sys_SetData sdPaymentCurrency_CityTax = currencyItems.Where(s => s.Id == hotelReservations.CityTaxCurrency).FirstOrDefault();
  1247. if (sdPaymentCurrency_CityTax != null)
  1248. {
  1249. CityTaxCode = sdPaymentCurrency_CityTax.Name;
  1250. CityTaxName = sdPaymentCurrency_CityTax.Remark;
  1251. }
  1252. Sys_SetData sdPaymentCurrency_Breakfast = currencyItems.Where(s => s.Id == hotelReservations.BreakfastCurrency).FirstOrDefault();
  1253. if (sdPaymentCurrency_Breakfast != null)
  1254. {
  1255. BreakfastCode = sdPaymentCurrency_Breakfast.Name;
  1256. BreakfastName = sdPaymentCurrency_Breakfast.Remark;
  1257. }
  1258. string isoppayStr = hotelReservations.Isoppay == 0 ? "是" : "否";
  1259. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1260. $"房间说明: {hotelReservations.Remark} <br/>" +
  1261. $"地税: {hotelReservations.GovernmentRent.ToString("#0.00")} {GovernmentRentCode} ({GovernmentRentName})<br/>" +
  1262. $"城市税: {hotelReservations.CityTax.ToString("#0.00")} {CityTaxCode} ({CityTaxName})<br/>" +
  1263. $"酒店早餐: {hotelReservations.BreakfastPrice.ToString("#0.00")} {BreakfastCode} ({BreakfastName})<br/>" +
  1264. $"酒店早餐是否由地接代付: {isoppayStr}";
  1265. _detail.PriceNameContent = hotelReservations.HotelName;
  1266. }
  1267. break;
  1268. case 79://车/导游地接
  1269. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1270. if (touristGuideGroundReservations != null)
  1271. {
  1272. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1273. {
  1274. _detail.BusName = touristGuideGroundReservations.BusName;
  1275. }
  1276. _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1277. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1278. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1279. string priceMsg = string.Empty;
  1280. foreach (var item in touristGuideGroundReservationsContents)
  1281. {
  1282. string typeName = "Unknown";
  1283. string carCurrencyCode = "Unknown";
  1284. string carCurrencyName = "Unknown";
  1285. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1286. if (carTypeData != null) typeName = carTypeData.Name;
  1287. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1288. if (currencyData != null) {
  1289. carCurrencyCode = currencyData.Name;
  1290. carCurrencyName = currencyData.Remark;
  1291. }
  1292. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1293. "明细:" + item.PriceContent + "<br/>" +
  1294. "备注:" + item.Remark + "<br/><br/>";
  1295. }
  1296. _detail.PriceMsgContent = priceMsg;
  1297. }
  1298. break;
  1299. case 80: //签证
  1300. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1301. if (visaInfo != null)
  1302. {
  1303. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1304. _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
  1305. }
  1306. break;
  1307. case 81: //邀请/公务活动
  1308. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1309. if (_ioa != null)
  1310. {
  1311. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1312. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1313. sendCurrName = "Unknown", //快递费用币种 Name
  1314. sendCurrCode = "Unknown", //快递费用币种 Code
  1315. eventsCurrName = "Unknown", //公务活动费币种 Name
  1316. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1317. translateCurrName = "Unknown", //公务翻译费 Name
  1318. translateCurrCode = "Unknown"; //公务翻译费 Code
  1319. #region 处理费用币种
  1320. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1321. if (inviteCurrData != null)
  1322. {
  1323. inviteCurrName = inviteCurrData.Remark;
  1324. inviteCurrCode = inviteCurrData.Name;
  1325. }
  1326. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1327. if (sendCurrData != null)
  1328. {
  1329. sendCurrName = sendCurrData.Remark;
  1330. sendCurrCode = sendCurrData.Name;
  1331. }
  1332. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1333. if (eventsCurrData != null)
  1334. {
  1335. eventsCurrName = eventsCurrData.Remark;
  1336. eventsCurrCode = eventsCurrData.Name;
  1337. }
  1338. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1339. if (translateCurrData != null)
  1340. {
  1341. translateCurrName = translateCurrData.Remark;
  1342. translateCurrCode = translateCurrData.Name;
  1343. }
  1344. #endregion
  1345. _detail.PriceNameContent = _ioa.InviterArea;
  1346. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1347. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1348. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1349. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1350. $@"备注:" + _ioa.Remark + "<br/>";
  1351. }
  1352. break;
  1353. case 82: //团组客户保险
  1354. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1355. if (customers != null)
  1356. {
  1357. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1358. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1359. }
  1360. break;
  1361. case 85: //机票预订
  1362. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1363. if (jpRes != null)
  1364. {
  1365. string FlightsDescription = jpRes.FlightsDescription;
  1366. string PriceDescription = jpRes.PriceDescription;
  1367. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1368. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1369. }
  1370. break;
  1371. case 98://其他款项
  1372. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1373. if (gdpRes != null)
  1374. {
  1375. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1376. _detail.PriceNameContent = gdpRes.PriceName;
  1377. }
  1378. break;
  1379. case 285://收款退还
  1380. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1381. if (refundAndOtherMoney != null)
  1382. {
  1383. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1384. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1385. }
  1386. break;
  1387. case 751://酒店早餐
  1388. break;
  1389. case 1015://超支费用
  1390. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1391. if (groupExtraCost != null) {
  1392. _detail.PriceNameContent = groupExtraCost.PriceName;
  1393. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1394. }
  1395. break;
  1396. default:
  1397. break;
  1398. }
  1399. /*
  1400. * 申请人
  1401. */
  1402. string operatorName = " - ";
  1403. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1404. if (_opUser != null)
  1405. {
  1406. operatorName = _opUser.CnName;
  1407. }
  1408. _detail.OperatorName = operatorName;
  1409. /*
  1410. * 审核人
  1411. */
  1412. string auditOperatorName = "Unknown";
  1413. if (entity.AuditGMOperate == 0)
  1414. auditOperatorName = " - ";
  1415. else if (entity.AuditGMOperate == 4)
  1416. auditOperatorName = "自动审核";
  1417. else
  1418. {
  1419. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1420. if (_adUser != null)
  1421. {
  1422. auditOperatorName = _adUser.CnName;
  1423. }
  1424. }
  1425. _detail.AuditOperatorName = auditOperatorName;
  1426. /*
  1427. * 超预算比例
  1428. */
  1429. string overBudgetStr = "";
  1430. if (entity.ExceedBudget == -1)
  1431. overBudgetStr = sdPriceName.Name + "尚无预算";
  1432. else if (entity.ExceedBudget == 0)
  1433. overBudgetStr = "未超预算";
  1434. else
  1435. overBudgetStr = entity.ExceedBudget.ToString("P");
  1436. _detail.OverBudget = overBudgetStr;
  1437. /*
  1438. * 费用总计
  1439. */
  1440. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1441. {
  1442. CurrencyId = entity.PaymentCurrency,
  1443. CurrencyName = PaymentCurrency_WaitPay,
  1444. AmountPayable = entity.PayMoney,
  1445. ThisPayment = CurrPayStr,
  1446. BalancePayment = BalanceStr,
  1447. AuditedFunds = CurrPayStr
  1448. });
  1449. _detail.IsAuditGM = entity.IsAuditGM;
  1450. detailList.Add(_detail);
  1451. }
  1452. #endregion
  1453. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1454. /*
  1455. * 下方描述处理
  1456. */
  1457. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1458. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1459. if (ccpCurrencyPrice != null)
  1460. {
  1461. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1462. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1463. }
  1464. else
  1465. {
  1466. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1467. }
  1468. string amountPayableStr = string.Format(@"应付款总金额: ");
  1469. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1470. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1471. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1472. foreach (var item in nonDuplicat)
  1473. {
  1474. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1475. if (strs.Count > 0)
  1476. {
  1477. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1478. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1479. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1480. //单独处理此次付款金额
  1481. if (item.CurrencyId == 836) //人民币
  1482. {
  1483. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1484. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1485. }
  1486. else
  1487. {
  1488. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1489. }
  1490. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1491. //单独处理已审核费用
  1492. if (item.CurrencyId == 836) //人民币
  1493. {
  1494. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1495. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1496. }
  1497. else
  1498. {
  1499. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1500. }
  1501. }
  1502. }
  1503. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1504. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1505. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1506. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1507. var _view1 = new
  1508. {
  1509. PageFuncAuth = pageFunAuthView,
  1510. Data = _view
  1511. };
  1512. return Ok(JsonView(_view1));
  1513. }
  1514. catch (Exception ex)
  1515. {
  1516. return Ok(JsonView(false, ex.Message));
  1517. }
  1518. }
  1519. /// <summary>
  1520. /// 费用审核
  1521. /// 修改团组费用审核状态
  1522. /// </summary>
  1523. /// <param name="_dto">参数Json字符串</param>
  1524. /// <returns></returns>
  1525. [HttpPost]
  1526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1527. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1528. {
  1529. #region 参数验证
  1530. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1531. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1532. #endregion
  1533. #region 页面操作权限验证
  1534. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1535. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1536. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1537. #endregion
  1538. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1539. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1540. DateTime dtNow = DateTime.Now;
  1541. _groupRepository.BeginTran();
  1542. int rst = 0;
  1543. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1544. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1545. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1546. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1547. List<dynamic> msgDatas = new List<dynamic>();
  1548. foreach (var item in idList)
  1549. {
  1550. int CreditId = int.Parse(item);
  1551. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1552. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1553. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1554. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1555. .Where(s => s.Id == CreditId)
  1556. .ExecuteCommandAsync();
  1557. if (result < 1)
  1558. {
  1559. rst = -1;
  1560. _groupRepository.RollbackTran();
  1561. return Ok(JsonView(false, "操作失败并回滚!"));
  1562. }
  1563. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1564. if (creditData != null)
  1565. {
  1566. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1567. string groupNameStr = string.Empty;
  1568. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1569. if (groupData != null) groupNameStr = groupData.TeamName;
  1570. string creditTypeStr = string.Empty;
  1571. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1572. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1573. string creditCurrency = string.Empty;
  1574. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1575. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1576. if (creditCurrency.Equals("CNY"))
  1577. {
  1578. creditData.DayRate = 1.0000M;
  1579. }
  1580. if (creditData.PayPercentage == 0.00M)
  1581. {
  1582. creditData.PayPercentage = 100M;
  1583. }
  1584. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1585. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1586. string msgContent = "";
  1587. if (creditCurrency.Equals("CNY"))
  1588. {
  1589. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1590. }
  1591. else
  1592. {
  1593. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1594. }
  1595. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1596. }
  1597. }
  1598. if (rst == 0)
  1599. {
  1600. _groupRepository.CommitTran();
  1601. foreach (var item in msgDatas)
  1602. {
  1603. //发送消息
  1604. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1605. }
  1606. return Ok(JsonView(true, "操作成功!"));
  1607. }
  1608. return Ok(JsonView(false, "操作失败!"));
  1609. }
  1610. #endregion
  1611. #region 机票费用录入
  1612. /// <summary>
  1613. /// 机票录入当前登录人可操作团组
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1620. {
  1621. try
  1622. {
  1623. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1624. if (groupData.Code != 0)
  1625. {
  1626. return Ok(JsonView(false, groupData.Msg));
  1627. }
  1628. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1629. }
  1630. catch (Exception ex)
  1631. {
  1632. return Ok(JsonView(false, "程序错误!"));
  1633. throw;
  1634. }
  1635. }
  1636. /// <summary>
  1637. /// 机票费用录入列表
  1638. /// </summary>
  1639. /// <param name="dto"></param>
  1640. /// <returns></returns>
  1641. [HttpPost]
  1642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1643. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1644. {
  1645. try
  1646. {
  1647. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1648. if (groupData.Code != 0)
  1649. {
  1650. return Ok(JsonView(false, groupData.Msg));
  1651. }
  1652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. return Ok(JsonView(false, "程序错误!"));
  1657. throw;
  1658. }
  1659. }
  1660. /// <summary>
  1661. /// 根据id查询费用录入信息
  1662. /// </summary>
  1663. /// <param name="dto"></param>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1668. {
  1669. try
  1670. {
  1671. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1672. if (groupData.Code != 0)
  1673. {
  1674. return Ok(JsonView(false, groupData.Msg));
  1675. }
  1676. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1677. }
  1678. catch (Exception ex)
  1679. {
  1680. return Ok(JsonView(false, "程序错误!"));
  1681. throw;
  1682. }
  1683. }
  1684. /// <summary>
  1685. /// 机票费用录入操作(Status:1.新增,2.修改)
  1686. /// </summary>
  1687. /// <param name="dto"></param>
  1688. /// <returns></returns>
  1689. [HttpPost]
  1690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1691. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1692. {
  1693. try
  1694. {
  1695. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1696. if (groupData.Code != 0)
  1697. {
  1698. return Ok(JsonView(false, groupData.Msg));
  1699. }
  1700. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1701. }
  1702. catch (Exception ex)
  1703. {
  1704. return Ok(JsonView(false, "程序错误!"));
  1705. throw;
  1706. }
  1707. }
  1708. /// <summary>
  1709. /// 根据舱位类型查询接团客户名单信息
  1710. /// </summary>
  1711. /// <param name="dto"></param>
  1712. /// <returns></returns>
  1713. [HttpPost]
  1714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1715. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1716. {
  1717. try
  1718. {
  1719. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1720. if (crm_Groups.Count != 0)
  1721. {
  1722. List<dynamic> Customer = new List<dynamic>();
  1723. foreach (var item in crm_Groups)
  1724. {
  1725. var data = new
  1726. {
  1727. Id = item.Id,
  1728. Pinyin = item.Pinyin,
  1729. Name = item.LastName + item.FirstName
  1730. };
  1731. Customer.Add(data);
  1732. }
  1733. return Ok(JsonView(true, "查询成功!", Customer));
  1734. }
  1735. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1736. }
  1737. catch (Exception ex)
  1738. {
  1739. return Ok(JsonView(false, "程序错误!"));
  1740. throw;
  1741. }
  1742. }
  1743. /// <summary>
  1744. /// 根据团号获取客户信息
  1745. /// </summary>
  1746. /// <param name="dto"></param>
  1747. /// <returns></returns>
  1748. [HttpPost]
  1749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1750. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1751. {
  1752. var jw = JsonView(false);
  1753. if (dto.DIID < 1)
  1754. {
  1755. jw.Msg += "请输入正确的diid";
  1756. return Ok(jw);
  1757. }
  1758. var arr = getSimplClientList(dto.DIID);
  1759. jw = JsonView(true, "获取成功!", arr);
  1760. return Ok(jw);
  1761. }
  1762. private List<SimplClientInfo> getSimplClientList(int diId) {
  1763. 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);
  1764. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1765. return arr;
  1766. }
  1767. private string getClientNameStr(List<SimplClientInfo> list, string origin) {
  1768. string result = origin;
  1769. if (Regex.Match(origin, @"\d+,?").Value.Length > 0) {
  1770. string[] temparr = origin.Split(',');
  1771. string fistrStr = temparr[0];
  1772. int count = temparr.Count();
  1773. int tempId;
  1774. bool success = int.TryParse(fistrStr, out tempId);
  1775. if (success) {
  1776. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1777. if (tempInfo != null) {
  1778. if (count > 1)
  1779. {
  1780. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1781. }
  1782. else {
  1783. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1784. }
  1785. }
  1786. }
  1787. }
  1788. return result;
  1789. }
  1790. /// <summary>
  1791. /// 机票费用录入,删除
  1792. /// </summary>
  1793. /// <param name="dto"></param>
  1794. /// <returns></returns>
  1795. [HttpPost]
  1796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1797. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1798. {
  1799. try
  1800. {
  1801. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1802. if (res)
  1803. {
  1804. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1805. {
  1806. IsDel = 1,
  1807. DeleteUserId = dto.DeleteUserId,
  1808. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1809. }).ExecuteCommandAsync();
  1810. return Ok(JsonView(true, "删除成功!"));
  1811. }
  1812. return Ok(JsonView(false, "删除失败!"));
  1813. }
  1814. catch (Exception ex)
  1815. {
  1816. return Ok(JsonView(false, "程序错误!"));
  1817. throw;
  1818. }
  1819. }
  1820. /// <summary>
  1821. /// 导出机票录入报表
  1822. /// </summary>
  1823. /// <param name="dto"></param>
  1824. /// <returns></returns>
  1825. [HttpPost]
  1826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1827. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1828. {
  1829. try
  1830. {
  1831. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1832. if (groupData.Code != 0)
  1833. {
  1834. return Ok(JsonView(false, groupData.Msg));
  1835. }
  1836. else
  1837. {
  1838. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1839. if (AirTicketReservations.Count != 0)
  1840. {
  1841. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1842. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1843. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1844. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1845. WorkbookDesigner designer = new WorkbookDesigner();
  1846. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1847. decimal countCost = 0;
  1848. foreach (var item in AirTicketReservations)
  1849. {
  1850. if (item.BankType == "其他")
  1851. {
  1852. item.BankNo = "--";
  1853. }
  1854. else
  1855. {
  1856. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  1857. }
  1858. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1859. item.Price = System.Decimal.Round(item.Price, 2);
  1860. countCost += Convert.ToDecimal(item.Price);
  1861. }
  1862. designer.SetDataSource("Export", AirTicketReservations);
  1863. designer.SetDataSource("ExportDiCode", diCode);
  1864. designer.SetDataSource("ExportDiName", diName);
  1865. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1866. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1867. designer.Process();
  1868. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  1869. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1870. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1871. return Ok(JsonView(true, "成功", url = rst));
  1872. }
  1873. else
  1874. {
  1875. return Ok(JsonView(false, "暂无数据!"));
  1876. }
  1877. }
  1878. }
  1879. catch (Exception ex)
  1880. {
  1881. return Ok(JsonView(false, "程序错误!"));
  1882. throw;
  1883. }
  1884. }
  1885. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1886. /// <summary>
  1887. /// 行程单导出
  1888. /// </summary>
  1889. /// <param name="dto"></param>
  1890. /// <returns></returns>
  1891. [HttpPost]
  1892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1893. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1894. {
  1895. try
  1896. {
  1897. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1898. if (groupData.Code != 0)
  1899. {
  1900. return Ok(JsonView(false, groupData.Msg));
  1901. }
  1902. else
  1903. {
  1904. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1905. if (dto.Language == "CN")
  1906. {
  1907. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1908. DocumentBuilder builder = new DocumentBuilder(doc);
  1909. int tableIndex = 0;//表格索引
  1910. //得到文档中的第一个表格
  1911. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1912. foreach (var item in _AirTicketReservations)
  1913. {
  1914. #region 处理固定数据
  1915. string[] FlightsCode = item.FlightsCode.Split('/');
  1916. if (FlightsCode.Length != 0)
  1917. {
  1918. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1919. if (_AirCompany != null)
  1920. {
  1921. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1922. }
  1923. else
  1924. {
  1925. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1926. }
  1927. }
  1928. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1929. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1930. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1931. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1932. string name = "";
  1933. foreach (string clientName in nameArray)
  1934. {
  1935. if (!name.Contains(clientName))
  1936. {
  1937. name += clientName + ",";
  1938. }
  1939. }
  1940. if (!string.IsNullOrWhiteSpace(name))
  1941. {
  1942. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1943. }
  1944. else
  1945. {
  1946. table.Range.Bookmarks["ClientName"].Text = "--";
  1947. }
  1948. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1949. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1950. table.Range.Bookmarks["JointTicket"].Text = "--";
  1951. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1952. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1953. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1954. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1955. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1956. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1957. #endregion
  1958. #region 循环数据处理
  1959. List<AirInfo> airs = new List<AirInfo>();
  1960. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1961. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1962. for (int i = 0; i < FlightsCode.Length; i++)
  1963. {
  1964. AirInfo air = new AirInfo();
  1965. string[] tempstr = DayArray[i]
  1966. .Replace("\r\n", string.Empty)
  1967. .Replace("\\r\\n", string.Empty)
  1968. .TrimStart().TrimEnd()
  1969. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1970. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1971. string starCity = "";
  1972. if (star_Three != null)
  1973. {
  1974. starCity = star_Three.AirPort;
  1975. }
  1976. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1977. string EndCity = "";
  1978. if (End_Three != null)
  1979. {
  1980. EndCity = End_Three.AirPort;
  1981. }
  1982. air.Destination = starCity + "/" + EndCity;
  1983. air.Flight = FlightsCode[i];
  1984. air.SeatingClass = item.CTypeName;
  1985. string dateTime = tempstr[2];
  1986. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1987. air.FlightDate = DateTemp;
  1988. air.DepartureTime = tempstr[5];
  1989. air.LandingTime = tempstr[6];
  1990. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1991. air.TicketStatus = "--";
  1992. air.Luggage = "--";
  1993. air.DepartureTerminal = "--";
  1994. air.LandingTerminal = "--";
  1995. airs.Add(air);
  1996. }
  1997. int row = 13;
  1998. for (int i = 0; i < airs.Count; i++)
  1999. {
  2000. if (airs.Count > 2)
  2001. {
  2002. for (int j = 0; j < airs.Count - 2; j++)
  2003. {
  2004. var CopyRow = table.Rows[12].Clone(true);
  2005. table.Rows.Add(CopyRow);
  2006. }
  2007. }
  2008. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2009. int index = 0;
  2010. foreach (PropertyInfo property in properties)
  2011. {
  2012. string value = property.GetValue(airs[i]).ToString();
  2013. Cell ishcel0 = table.Rows[row].Cells[index];
  2014. Paragraph p = new Paragraph(doc);
  2015. string s = value;
  2016. p.AppendChild(new Run(doc, s));
  2017. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2018. ishcel0.AppendChild(p);
  2019. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2020. index++;
  2021. }
  2022. row++;
  2023. }
  2024. #endregion
  2025. Paragraph lastParagraph = new Paragraph(doc);
  2026. //第一个表格末尾加段落
  2027. table.ParentNode.InsertAfter(lastParagraph, table);
  2028. //复制第一个表格
  2029. Table cloneTable = (Table)table.Clone(true);
  2030. //在文档末尾段落后面加入复制的表格
  2031. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2032. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2033. {
  2034. int rownewsIndex = 13;
  2035. for (int i = 0; i < 2; i++)
  2036. {
  2037. var CopyRow = table.Rows[12].Clone(true);
  2038. table.Rows.RemoveAt(13);
  2039. table.Rows.Add(CopyRow);
  2040. rownewsIndex++;
  2041. }
  2042. }
  2043. else
  2044. {
  2045. table.Rows.RemoveAt(12);
  2046. }
  2047. cloneTable.Rows.RemoveAt(12);
  2048. }
  2049. if (_AirTicketReservations.Count != 0)
  2050. {
  2051. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2052. if (FlightsCode.Length != 0)
  2053. {
  2054. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2055. if (_AirCompany != null)
  2056. {
  2057. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2058. }
  2059. else
  2060. {
  2061. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2062. }
  2063. }
  2064. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2065. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2066. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2067. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2068. string name = "";
  2069. foreach (string clientName in nameArray)
  2070. {
  2071. if (!name.Contains(clientName))
  2072. {
  2073. name += clientName + ",";
  2074. }
  2075. }
  2076. if (!string.IsNullOrWhiteSpace(name))
  2077. {
  2078. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2079. }
  2080. else
  2081. {
  2082. table.Range.Bookmarks["ClientName"].Text = "--";
  2083. }
  2084. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2085. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2086. table.Range.Bookmarks["JointTicket"].Text = "--";
  2087. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2088. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2089. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2090. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2091. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2092. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2093. }
  2094. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2095. //保存合并后的文档
  2096. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2097. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2098. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2099. return Ok(JsonView(true, "成功!", rst));
  2100. }
  2101. else
  2102. {
  2103. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2104. DocumentBuilder builder = new DocumentBuilder(doc);
  2105. int tableIndex = 0;//表格索引
  2106. //得到文档中的第一个表格
  2107. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2108. List<string> texts = new List<string>();
  2109. foreach (var item in _AirTicketReservations)
  2110. {
  2111. string[] FlightsCode = item.FlightsCode.Split('/');
  2112. if (FlightsCode.Length != 0)
  2113. {
  2114. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2115. if (_AirCompany != null)
  2116. {
  2117. if (!transDic.ContainsKey(_AirCompany.CnName))
  2118. {
  2119. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2120. }
  2121. }
  2122. else
  2123. {
  2124. if (!transDic.ContainsKey("--"))
  2125. {
  2126. transDic.Add("--", "--");
  2127. }
  2128. }
  2129. }
  2130. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2131. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2132. string name = "";
  2133. foreach (string clientName in nameArray)
  2134. {
  2135. name += clientName + ",";
  2136. }
  2137. if (!texts.Contains(name))
  2138. {
  2139. texts.Add(name);
  2140. }
  2141. List<AirInfo> airs = new List<AirInfo>();
  2142. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2143. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2144. for (int i = 0; i < FlightsCode.Length; i++)
  2145. {
  2146. AirInfo air = new AirInfo();
  2147. string[] tempstr = DayArray[i]
  2148. .Replace("\r\n", string.Empty)
  2149. .Replace("\\r\\n", string.Empty)
  2150. .TrimStart().TrimEnd()
  2151. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2152. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2153. if (star_Three != null)
  2154. {
  2155. if (!transDic.ContainsKey(star_Three.AirPort))
  2156. {
  2157. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2158. }
  2159. }
  2160. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2161. if (End_Three != null)
  2162. {
  2163. if (!transDic.ContainsKey(End_Three.AirPort))
  2164. {
  2165. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2166. }
  2167. }
  2168. if (!texts.Contains(item.CTypeName))
  2169. {
  2170. texts.Add(item.CTypeName);
  2171. }
  2172. }
  2173. }
  2174. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2175. if (transData.Count > 0)
  2176. {
  2177. foreach (TranslateResult item in transData)
  2178. {
  2179. if (!transDic.ContainsKey(item.Query))
  2180. {
  2181. transDic.Add(item.Query, item.Translation);
  2182. }
  2183. }
  2184. }
  2185. foreach (var item in _AirTicketReservations)
  2186. {
  2187. #region 处理固定数据
  2188. string[] FlightsCode = item.FlightsCode.Split('/');
  2189. if (FlightsCode.Length != 0)
  2190. {
  2191. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2192. if (_AirCompany != null)
  2193. {
  2194. string str = "--";
  2195. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2196. if (!string.IsNullOrEmpty(translateResult))
  2197. {
  2198. str = translateResult;
  2199. str = _airTicketResRep.Processing(str);
  2200. }
  2201. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2202. }
  2203. else
  2204. {
  2205. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2206. }
  2207. }
  2208. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2209. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2210. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2211. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2212. string names = "";
  2213. foreach (string clientName in nameArray)
  2214. {
  2215. names += clientName + ",";
  2216. }
  2217. if (!string.IsNullOrWhiteSpace(names))
  2218. {
  2219. string str = "--";
  2220. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2221. if (!string.IsNullOrEmpty(translateResult))
  2222. {
  2223. str = translateResult;
  2224. str = _airTicketResRep.Processing(str);
  2225. }
  2226. table.Range.Bookmarks["ClientName"].Text = str;
  2227. }
  2228. else
  2229. {
  2230. table.Range.Bookmarks["ClientName"].Text = "--";
  2231. }
  2232. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2233. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2234. table.Range.Bookmarks["JointTicket"].Text = "--";
  2235. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2236. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2237. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2238. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2239. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2240. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2241. #endregion
  2242. #region 循环数据处理
  2243. List<AirInfo> airs = new List<AirInfo>();
  2244. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2245. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2246. for (int i = 0; i < FlightsCode.Length; i++)
  2247. {
  2248. AirInfo air = new AirInfo();
  2249. string[] tempstr = DayArray[i]
  2250. .Replace("\r\n", string.Empty)
  2251. .Replace("\\r\\n", string.Empty)
  2252. .TrimStart().TrimEnd()
  2253. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2254. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2255. string starCity = "";
  2256. if (star_Three != null)
  2257. {
  2258. string str2 = "--";
  2259. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2260. if (!string.IsNullOrEmpty(translateResult2))
  2261. {
  2262. str2 = translateResult2;
  2263. str2 = _airTicketResRep.Processing(str2);
  2264. }
  2265. starCity = str2;
  2266. }
  2267. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2268. string EndCity = "";
  2269. if (End_Three != null)
  2270. {
  2271. string str1 = "--";
  2272. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2273. if (!string.IsNullOrEmpty(translateResult1))
  2274. {
  2275. str1 = translateResult1;
  2276. str1 = _airTicketResRep.Processing(str1);
  2277. }
  2278. EndCity = str1;
  2279. }
  2280. air.Destination = starCity + "/" + EndCity;
  2281. air.Flight = FlightsCode[i];
  2282. string str = "--";
  2283. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2284. if (!string.IsNullOrEmpty(translateResult))
  2285. {
  2286. str = translateResult;
  2287. str = _airTicketResRep.Processing(str);
  2288. }
  2289. air.SeatingClass = str;
  2290. string dateTime = tempstr[2];
  2291. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2292. air.FlightDate = DateTemp;
  2293. air.DepartureTime = tempstr[5];
  2294. air.LandingTime = tempstr[6];
  2295. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2296. air.TicketStatus = "--";
  2297. air.Luggage = "--";
  2298. air.DepartureTerminal = "--";
  2299. air.LandingTerminal = "--";
  2300. airs.Add(air);
  2301. }
  2302. int row = 13;
  2303. for (int i = 0; i < airs.Count; i++)
  2304. {
  2305. if (airs.Count > 2)
  2306. {
  2307. for (int j = 0; j < airs.Count - 2; j++)
  2308. {
  2309. var CopyRow = table.Rows[12].Clone(true);
  2310. table.Rows.Add(CopyRow);
  2311. }
  2312. }
  2313. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2314. int index = 0;
  2315. foreach (PropertyInfo property in properties)
  2316. {
  2317. string value = property.GetValue(airs[i]).ToString();
  2318. Cell ishcel0 = table.Rows[row].Cells[index];
  2319. Paragraph p = new Paragraph(doc);
  2320. string s = value;
  2321. p.AppendChild(new Run(doc, s));
  2322. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2323. ishcel0.AppendChild(p);
  2324. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2325. //ishcel0.CellFormat.VerticalAlignment=
  2326. index++;
  2327. }
  2328. row++;
  2329. }
  2330. #endregion
  2331. Paragraph lastParagraph = new Paragraph(doc);
  2332. //第一个表格末尾加段落
  2333. table.ParentNode.InsertAfter(lastParagraph, table);
  2334. //复制第一个表格
  2335. Table cloneTable = (Table)table.Clone(true);
  2336. //在文档末尾段落后面加入复制的表格
  2337. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2338. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2339. {
  2340. int rownewsIndex = 13;
  2341. for (int i = 0; i < 2; i++)
  2342. {
  2343. var CopyRow = table.Rows[12].Clone(true);
  2344. table.Rows.RemoveAt(13);
  2345. table.Rows.Add(CopyRow);
  2346. rownewsIndex++;
  2347. }
  2348. }
  2349. else
  2350. {
  2351. table.Rows.RemoveAt(12);
  2352. }
  2353. cloneTable.Rows.RemoveAt(12);
  2354. }
  2355. if (_AirTicketReservations.Count != 0)
  2356. {
  2357. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2358. if (FlightsCode.Length != 0)
  2359. {
  2360. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2361. if (_AirCompany != null)
  2362. {
  2363. string str = "--";
  2364. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2365. if (!string.IsNullOrEmpty(translateResult))
  2366. {
  2367. str = translateResult;
  2368. str = _airTicketResRep.Processing(str);
  2369. }
  2370. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2371. }
  2372. else
  2373. {
  2374. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2375. }
  2376. }
  2377. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2378. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2379. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2380. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2381. string names = "";
  2382. foreach (string clientName in nameArray)
  2383. {
  2384. names += clientName + ",";
  2385. }
  2386. if (!string.IsNullOrWhiteSpace(names))
  2387. {
  2388. string str = "--";
  2389. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2390. if (!string.IsNullOrEmpty(translateResult))
  2391. {
  2392. str = translateResult;
  2393. str = _airTicketResRep.Processing(str);
  2394. }
  2395. table.Range.Bookmarks["ClientName"].Text = str;
  2396. }
  2397. else
  2398. {
  2399. table.Range.Bookmarks["ClientName"].Text = "--";
  2400. }
  2401. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2402. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2403. table.Range.Bookmarks["JointTicket"].Text = "--";
  2404. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2405. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2406. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2407. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2408. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2409. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2410. }
  2411. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2412. //保存合并后的文档
  2413. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2414. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2415. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2416. return Ok(JsonView(true, "成功!", rst));
  2417. }
  2418. }
  2419. }
  2420. catch (Exception ex)
  2421. {
  2422. return Ok(JsonView(false, "程序错误!"));
  2423. throw;
  2424. }
  2425. }
  2426. #endregion
  2427. #region 团组增减款项 --> 其他款项
  2428. /// <summary>
  2429. /// 团组增减款项下拉框绑定
  2430. /// </summary>
  2431. /// <param name="dto"></param>
  2432. /// <returns></returns>
  2433. [HttpPost]
  2434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2435. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2436. {
  2437. try
  2438. {
  2439. #region 参数验证
  2440. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2441. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2442. #endregion
  2443. //var groupData = await GeneralMethod.PostOperationAuthReturnGroupInfosAsync(dto.UserId, dto.CTId);
  2444. ////支付方式
  2445. //List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2446. //List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2447. //var data = new
  2448. //{
  2449. // Payment = _Payment,
  2450. // GroupName = groupData,
  2451. //};
  2452. var res = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  2453. if (res.Code != 0)
  2454. {
  2455. return Ok(JsonView(false, res.Msg));
  2456. }
  2457. return Ok(JsonView(true, "操作成功!", res.Data));
  2458. }
  2459. catch (Exception ex)
  2460. {
  2461. return Ok(JsonView(false, ex.Message));
  2462. }
  2463. }
  2464. /// <summary>
  2465. /// 根据团组Id查询团组增减款项
  2466. /// </summary>
  2467. /// <param name="dto"></param>
  2468. /// <returns></returns>
  2469. [HttpPost]
  2470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2471. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2472. {
  2473. try
  2474. {
  2475. #region 参数验证
  2476. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2477. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2478. #endregion
  2479. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  2480. if (groupData.Code != 0)
  2481. {
  2482. return Ok(JsonView(false, groupData.Msg));
  2483. }
  2484. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2485. }
  2486. catch (Exception ex)
  2487. {
  2488. return Ok(JsonView(false, "程序错误!"));
  2489. }
  2490. }
  2491. /// <summary>
  2492. /// 团组增减款项操作(Status:1.新增,2.修改)
  2493. /// </summary>
  2494. /// <param name="dto"></param>
  2495. /// <returns></returns>
  2496. [HttpPost]
  2497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2498. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2499. {
  2500. try
  2501. {
  2502. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2503. if (groupData.Code != 0)
  2504. {
  2505. return Ok(JsonView(false, groupData.Msg));
  2506. }
  2507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2508. }
  2509. catch (Exception ex)
  2510. {
  2511. return Ok(JsonView(false, "程序错误!"));
  2512. throw;
  2513. }
  2514. }
  2515. /// <summary>
  2516. /// 团组增减款项操作 删除
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2523. {
  2524. try
  2525. {
  2526. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  2527. if (!res)
  2528. {
  2529. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  2530. {
  2531. IsDel = 1,
  2532. DeleteUserId = dto.DeleteUserId,
  2533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2534. }).ExecuteCommandAsync();
  2535. return Ok(JsonView(false, "删除失败"));
  2536. }
  2537. return Ok(JsonView(true, "删除成功!"));
  2538. }
  2539. catch (Exception ex)
  2540. {
  2541. return Ok(JsonView(false, "程序错误!"));
  2542. throw;
  2543. }
  2544. }
  2545. /// <summary>
  2546. /// 根据团组增减款项Id查询
  2547. /// </summary>
  2548. /// <param name="dto"></param>
  2549. /// <returns></returns>
  2550. [HttpPost]
  2551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2552. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2553. {
  2554. try
  2555. {
  2556. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  2557. if (groupData.Code != 0)
  2558. {
  2559. return Ok(JsonView(false, groupData.Msg));
  2560. }
  2561. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2562. }
  2563. catch (Exception ex)
  2564. {
  2565. return Ok(JsonView(false, "程序错误!"));
  2566. throw;
  2567. }
  2568. }
  2569. #endregion
  2570. #region 文件上传、删除
  2571. /// <summary>
  2572. /// region 文件上传 可以带参数
  2573. /// </summary>
  2574. /// <param name="file"></param>
  2575. /// <returns></returns>
  2576. [HttpPost]
  2577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2578. public async Task<IActionResult> UploadProject(IFormFile file)
  2579. {
  2580. try
  2581. {
  2582. var TypeName = Request.Headers["TypeName"].ToString();
  2583. if (file != null)
  2584. {
  2585. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2586. //文件名称
  2587. string projectFileName = file.FileName;
  2588. //上传的文件的路径
  2589. string filePath = "";
  2590. if (TypeName == "A")//A代表团组增减款项
  2591. {
  2592. if (!Directory.Exists(fileDir))
  2593. {
  2594. Directory.CreateDirectory(fileDir);
  2595. }
  2596. //上传的文件的路径
  2597. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2598. }
  2599. else if (TypeName == "B")//B代表商邀相关文件
  2600. {
  2601. if (!Directory.Exists(fileDir))
  2602. {
  2603. Directory.CreateDirectory(fileDir);
  2604. }
  2605. //上传的文件的路径
  2606. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2607. }
  2608. using (FileStream fs = System.IO.File.Create(filePath))
  2609. {
  2610. file.CopyTo(fs);
  2611. fs.Flush();
  2612. }
  2613. return Ok(JsonView(true, "上传成功!", projectFileName));
  2614. }
  2615. else
  2616. {
  2617. return Ok(JsonView(false, "上传失败!"));
  2618. }
  2619. }
  2620. catch (Exception ex)
  2621. {
  2622. return Ok(JsonView(false, "程序错误!"));
  2623. throw;
  2624. }
  2625. }
  2626. /// <summary>
  2627. /// 删除指定文件
  2628. /// </summary>
  2629. /// <param name="dto"></param>
  2630. /// <returns></returns>
  2631. [HttpPost]
  2632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2633. public async Task<IActionResult> DelFile(DelFileDto dto)
  2634. {
  2635. try
  2636. {
  2637. var TypeName = Request.Headers["TypeName"].ToString();
  2638. string filePath = "";
  2639. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2640. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2641. int id = 0;
  2642. if (TypeName == "A")
  2643. {
  2644. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2645. // 删除该文件
  2646. System.IO.File.Delete(filePath);
  2647. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2648. }
  2649. else if (TypeName == "B")
  2650. {
  2651. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2652. // 删除该文件
  2653. System.IO.File.Delete(filePath);
  2654. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2655. }
  2656. if (id != 0)
  2657. {
  2658. return Ok(JsonView(true, "成功!"));
  2659. }
  2660. else
  2661. {
  2662. return Ok(JsonView(false, "失败!"));
  2663. }
  2664. }
  2665. catch (Exception ex)
  2666. {
  2667. return Ok(JsonView(false, "程序错误!"));
  2668. throw;
  2669. }
  2670. }
  2671. #endregion
  2672. #region 商邀费用录入
  2673. /// <summary>
  2674. /// 根据团组Id查询商邀费用列表
  2675. /// </summary>
  2676. /// <param name="dto"></param>
  2677. /// <returns></returns>
  2678. [HttpPost]
  2679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2680. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2681. {
  2682. try
  2683. {
  2684. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2685. if (groupData.Code != 0)
  2686. {
  2687. return Ok(JsonView(false, groupData.Msg));
  2688. }
  2689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2690. }
  2691. catch (Exception ex)
  2692. {
  2693. return Ok(JsonView(false, "程序错误!"));
  2694. throw;
  2695. }
  2696. }
  2697. //
  2698. /// <summary>
  2699. /// 商邀费用 Info Page 基础数据源
  2700. /// </summary>
  2701. /// <param name="dto"></param>
  2702. /// <returns></returns>
  2703. [HttpPost]
  2704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2705. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2706. {
  2707. try
  2708. {
  2709. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2710. if (groupData.Code != 0)
  2711. {
  2712. return Ok(JsonView(false, groupData.Msg));
  2713. }
  2714. return Ok(JsonView(true, "操作成功", groupData.Data));
  2715. }
  2716. catch (Exception ex)
  2717. {
  2718. return Ok(JsonView(false, ex.Message));
  2719. throw;
  2720. }
  2721. }
  2722. /// <summary>
  2723. /// 根据商邀费用ID查询C表和商邀费用数据
  2724. /// </summary>
  2725. /// <param name="dto"></param>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2730. {
  2731. try
  2732. {
  2733. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2734. if (groupData.Code != 0)
  2735. {
  2736. return Ok(JsonView(false, groupData.Msg));
  2737. }
  2738. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2739. }
  2740. catch (Exception ex)
  2741. {
  2742. return Ok(JsonView(false, ex.Message));
  2743. throw;
  2744. }
  2745. }
  2746. /// <summary>
  2747. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2748. /// </summary>
  2749. /// <param name="dto"></param>
  2750. /// <returns></returns>
  2751. [HttpPost]
  2752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2753. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2754. {
  2755. try
  2756. {
  2757. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto,_setDataRep.PostCurrencyByDiid);
  2758. if (groupData.Code != 0)
  2759. {
  2760. return Ok(JsonView(false, groupData.Msg));
  2761. }
  2762. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2763. }
  2764. catch (Exception ex)
  2765. {
  2766. return Ok(JsonView(false, "程序错误!"));
  2767. throw;
  2768. }
  2769. }
  2770. /// <summary>
  2771. /// 商邀删除
  2772. /// </summary>
  2773. /// <param name="dto"></param>
  2774. /// <returns></returns>
  2775. [HttpPost]
  2776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2777. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2778. {
  2779. try
  2780. {
  2781. _sqlSugar.BeginTran();
  2782. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2783. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2784. {
  2785. IsDel = 1,
  2786. DeleteUserId = dto.DeleteUserId,
  2787. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2788. })
  2789. .Where(it => it.Id == dto.Id)
  2790. .ExecuteCommand();
  2791. if (res1 > 0)
  2792. {
  2793. int _diId = 0;
  2794. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2795. if (_ioaInfo!=null)
  2796. {
  2797. _diId = _ioaInfo.DiId;
  2798. }
  2799. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2800. .SetColumns(a => new Grp_CreditCardPayment()
  2801. {
  2802. IsDel = 1,
  2803. DeleteUserId = dto.DeleteUserId,
  2804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2805. })
  2806. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81 )
  2807. .ExecuteCommand();
  2808. if (res2 > 0)
  2809. {
  2810. _sqlSugar.CommitTran();
  2811. return Ok(JsonView(true, "删除成功!"));
  2812. }
  2813. }
  2814. _sqlSugar.RollbackTran();
  2815. return Ok(JsonView(false, "删除失败"));
  2816. }
  2817. catch (Exception ex)
  2818. {
  2819. _sqlSugar.RollbackTran();
  2820. return Ok(JsonView(false, ex.Message));
  2821. }
  2822. }
  2823. #endregion
  2824. #region 团组英文资料
  2825. /// <summary>
  2826. /// 查询团组英文所有资料
  2827. /// </summary>
  2828. /// <param name="dto"></param>
  2829. /// <returns></returns>
  2830. [HttpPost]
  2831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2832. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2833. {
  2834. try
  2835. {
  2836. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2837. if (groupData.Code != 0)
  2838. {
  2839. return Ok(JsonView(false, groupData.Msg));
  2840. }
  2841. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2842. }
  2843. catch (Exception ex)
  2844. {
  2845. return Ok(JsonView(false, "程序错误!"));
  2846. throw;
  2847. }
  2848. }
  2849. /// <summary>
  2850. /// 团组英文资料操作(Status:1.新增,2.修改)
  2851. /// </summary>
  2852. /// <param name="dto"></param>
  2853. /// <returns></returns>
  2854. [HttpPost]
  2855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2856. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2857. {
  2858. try
  2859. {
  2860. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2861. if (groupData.Code != 0)
  2862. {
  2863. return Ok(JsonView(false, groupData.Msg));
  2864. }
  2865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2866. }
  2867. catch (Exception ex)
  2868. {
  2869. return Ok(JsonView(false, "程序错误!"));
  2870. throw;
  2871. }
  2872. }
  2873. /// <summary>
  2874. /// 团组英文资料Id查询数据
  2875. /// </summary>
  2876. /// <param name="dto"></param>
  2877. /// <returns></returns>
  2878. [HttpPost]
  2879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2880. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2881. {
  2882. try
  2883. {
  2884. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2885. if (_DelegationEnData != null)
  2886. {
  2887. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2888. }
  2889. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2890. }
  2891. catch (Exception ex)
  2892. {
  2893. return Ok(JsonView(false, "程序错误!"));
  2894. throw;
  2895. }
  2896. }
  2897. /// <summary>
  2898. /// 团组英文资料删除
  2899. /// </summary>
  2900. /// <param name="dto"></param>
  2901. /// <returns></returns>
  2902. [HttpPost]
  2903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2904. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2905. {
  2906. try
  2907. {
  2908. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2909. if (!res)
  2910. {
  2911. return Ok(JsonView(false, "删除失败"));
  2912. }
  2913. return Ok(JsonView(true, "删除成功!"));
  2914. }
  2915. catch (Exception ex)
  2916. {
  2917. return Ok(JsonView(false, "程序错误!"));
  2918. throw;
  2919. }
  2920. }
  2921. #endregion
  2922. #region 导出邀请函
  2923. /// <summary>
  2924. /// 导出邀请函页面初始化
  2925. /// </summary>
  2926. /// <param name="dto"></param>
  2927. /// <returns></returns>
  2928. [HttpPost]
  2929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2930. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2931. {
  2932. try
  2933. {
  2934. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  2935. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2936. if (dto.DiId == 0)
  2937. {
  2938. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2939. }
  2940. else
  2941. {
  2942. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2943. }
  2944. return Ok(JsonView(true, "查询成功!", new
  2945. {
  2946. deleClient = crm_Deles,
  2947. delegations = grp_Delegations
  2948. }));
  2949. }
  2950. catch (Exception ex)
  2951. {
  2952. return Ok(JsonView(false, "程序错误!"));
  2953. throw;
  2954. }
  2955. }
  2956. /// <summary>
  2957. /// 导出邀请函
  2958. /// </summary>
  2959. /// <param name="dto"></param>
  2960. /// <returns></returns>
  2961. [HttpPost]
  2962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2963. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2964. {
  2965. #region 参数验证
  2966. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2967. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2968. #endregion
  2969. try
  2970. {
  2971. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2972. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  2973. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  2974. From Grp_TourClientList tcl
  2975. Left Join
  2976. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  2977. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  2978. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  2979. From Crm_DeleClient dc
  2980. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  2981. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  2982. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  2983. Where dc.IsDel = 0) temp
  2984. On temp.DcId =tcl.ClientId
  2985. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  2986. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  2987. List<string> texts = new List<string>();
  2988. if (datas.Count != 0)
  2989. {
  2990. foreach (TourClientListDetailsView item in datas)
  2991. {
  2992. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2993. {
  2994. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2995. }
  2996. else
  2997. {
  2998. string name = item.LastName + item.FirstName;
  2999. texts.Add(name);
  3000. }
  3001. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3002. {
  3003. if (!transDic.ContainsKey(item.Job))
  3004. {
  3005. texts.Add(item.Job);
  3006. }
  3007. }
  3008. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3009. {
  3010. texts.Add(item.CompanyFullName);
  3011. }
  3012. }
  3013. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3014. if (transData.Count > 0)
  3015. {
  3016. foreach (TranslateResult item in transData)
  3017. {
  3018. if (!transDic.ContainsKey(item.Query))
  3019. {
  3020. transDic.Add(item.Query, item.Translation);
  3021. }
  3022. }
  3023. }
  3024. List<GuestList> list = new List<GuestList>();
  3025. foreach (TourClientListDetailsView dele in datas)
  3026. {
  3027. GuestList guestList = new GuestList();
  3028. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3029. {
  3030. guestList.Name = dele.Pinyin;
  3031. }
  3032. else
  3033. {
  3034. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3035. guestList.Name = Name;
  3036. }
  3037. if (dele.Sex == 0)
  3038. {
  3039. guestList.Sex = "Male";
  3040. }
  3041. else if (dele.Sex == 1)
  3042. {
  3043. guestList.Sex = "Female";
  3044. }
  3045. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3046. if (!string.IsNullOrEmpty(dele.Job))
  3047. {
  3048. guestList.Job = dele.Job;
  3049. }
  3050. list.Add(guestList);
  3051. }
  3052. //载入模板
  3053. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3054. DocumentBuilder builder = new DocumentBuilder(doc);
  3055. //获取word里所有表格
  3056. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3057. //获取所填表格的序数
  3058. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3059. var rowStart = tableOne.Rows[0]; //获取第1行
  3060. //循环赋值
  3061. for (int i = 0; i < list.Count; i++)
  3062. {
  3063. builder.MoveToCell(0, i + 1, 0, 0);
  3064. builder.Write(list[i].Name.ToString());
  3065. builder.MoveToCell(0, i + 1, 1, 0);
  3066. builder.Write(list[i].Sex.ToString());
  3067. builder.MoveToCell(0, i + 1, 2, 0);
  3068. builder.Write(list[i].DOB.ToString());
  3069. builder.MoveToCell(0, i + 1, 3, 0);
  3070. builder.Write(list[i].Job.ToString());
  3071. }
  3072. //删除多余行
  3073. while (tableOne.Rows.Count > list.Count + 1)
  3074. {
  3075. tableOne.Rows.RemoveAt(list.Count + 1);
  3076. }
  3077. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3078. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3079. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3080. doc.Save(filePath);
  3081. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3082. return Ok(JsonView(true, "操作成功!", Url));
  3083. }
  3084. else
  3085. {
  3086. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3087. }
  3088. }
  3089. catch (Exception ex)
  3090. {
  3091. return Ok(JsonView(false, ex.Message));
  3092. throw;
  3093. }
  3094. }
  3095. #endregion
  3096. #region 团组经理模块 出入境费用
  3097. ///// <summary>
  3098. ///// 团组模块 - 出入境费用
  3099. ///// </summary>
  3100. ///// <returns></returns>
  3101. //[HttpPost]
  3102. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3103. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3104. //{
  3105. // try
  3106. // {
  3107. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3108. // if (data.Code != 0)
  3109. // {
  3110. // return Ok(JsonView(false, data.Msg));
  3111. // }
  3112. // return Ok(JsonView(true, "查询成功!"));
  3113. // }
  3114. // catch (Exception ex)
  3115. // {
  3116. // return Ok(JsonView(false, ex.Message));
  3117. // throw;
  3118. // }
  3119. //}
  3120. /// <summary>
  3121. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3122. /// </summary>
  3123. /// <returns></returns>
  3124. [HttpPost]
  3125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3126. public async Task<IActionResult> SetDayAndCostAreaChange()
  3127. {
  3128. try
  3129. {
  3130. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3131. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3132. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3133. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3134. foreach (var item in unite) //处理交集数据
  3135. {
  3136. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3137. }
  3138. foreach (var item in merge) //处理差集数据
  3139. {
  3140. int nationalTravelFeeId = 0;
  3141. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3142. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3143. else
  3144. {
  3145. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3146. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3147. }
  3148. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3149. }
  3150. //只更新dayAndCost 的 nationalTravelFeeId;
  3151. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3152. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3153. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3154. }
  3155. catch (Exception ex)
  3156. {
  3157. return Ok(JsonView(false, ex.Message));
  3158. throw;
  3159. }
  3160. }
  3161. /// <summary>
  3162. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3163. /// </summary>
  3164. /// <returns></returns>
  3165. [HttpPost]
  3166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3167. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3168. {
  3169. try
  3170. {
  3171. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3172. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3173. //SetDataInfoView
  3174. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3175. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3176. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3177. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3178. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3179. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3180. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3181. //默认币种显示
  3182. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3183. {
  3184. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 0.0000M },
  3185. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 0.0000M },
  3186. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 0.0000M },
  3187. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0000M },
  3188. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.0000M },
  3189. };
  3190. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3191. if (_currencyRate.Count > 0)
  3192. {
  3193. foreach (var item in _currencyInfos)
  3194. {
  3195. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3196. if (rateInfo != null)
  3197. {
  3198. item.Rate = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3199. }
  3200. }
  3201. }
  3202. return Ok(JsonView(true, "查询成功!", new
  3203. {
  3204. GroupNameData = groupNameData.Data,
  3205. CurrencyData = _CurrencyData,
  3206. WordTypeData = _WordTypeData,
  3207. ExcelTypeData = _ExcelTypeData,
  3208. CurrencyInit = _currencyInfos
  3209. }));
  3210. }
  3211. catch (Exception ex)
  3212. {
  3213. return Ok(JsonView(false, ex.Message));
  3214. throw;
  3215. }
  3216. }
  3217. /// <summary>
  3218. /// 团组模块 - 出入境费用 - Info
  3219. /// </summary>
  3220. /// <returns></returns>
  3221. [HttpPost]
  3222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3223. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3224. {
  3225. try
  3226. {
  3227. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3228. if (data.Code != 0)
  3229. {
  3230. return Ok(JsonView(false, data.Msg));
  3231. }
  3232. return Ok(JsonView(true, "查询成功!", data.Data));
  3233. }
  3234. catch (Exception ex)
  3235. {
  3236. return Ok(JsonView(false, ex.Message));
  3237. }
  3238. }
  3239. /// <summary>
  3240. /// 团组模块 - 出入境费用 - Add And Update
  3241. /// </summary>
  3242. /// <returns></returns>
  3243. [HttpPost]
  3244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3245. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3246. {
  3247. try
  3248. {
  3249. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3250. if (data.Code != 0)
  3251. {
  3252. return Ok(JsonView(false, data.Msg));
  3253. }
  3254. return Ok(JsonView(true, data.Msg, data.Data));
  3255. }
  3256. catch (Exception ex)
  3257. {
  3258. return Ok(JsonView(false, ex.Message));
  3259. }
  3260. }
  3261. /// <summary>
  3262. /// 团组模块 - 出入境费用 - File downlaod
  3263. /// </summary>
  3264. /// <param name="dto"></param>
  3265. /// <returns></returns>
  3266. [HttpPost]
  3267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3268. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3269. {
  3270. try
  3271. {
  3272. if (dto.DiId < 1)
  3273. {
  3274. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3275. }
  3276. if (dto.ExportType <1)
  3277. {
  3278. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3279. }
  3280. if (dto.SubTypeId < 1)
  3281. {
  3282. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3283. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3284. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3285. 3 团组成员名单 1 团组成员名单"));
  3286. }
  3287. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3288. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3289. if (_EnterExitCosts == null)
  3290. {
  3291. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3292. }
  3293. //数据源
  3294. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3295. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3296. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3297. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3298. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3299. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3300. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3301. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3302. .LeftJoin<Crm_CustomerCompany>((tcl, dc,cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3303. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3304. .Select((tcl, dc, cc) => new
  3305. {
  3306. Name = dc.LastName + dc.FirstName,
  3307. Sex = dc.Sex,
  3308. Birthday = dc.BirthDay,
  3309. Company = cc.CompanyFullName,
  3310. Job = dc.Job
  3311. })
  3312. .ToList();
  3313. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3314. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3315. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3316. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3317. if (dto.ExportType == 1) //明细表
  3318. {
  3319. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3320. {
  3321. //获取模板
  3322. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3323. //载入模板
  3324. Document doc = new Document(tempPath);
  3325. DocumentBuilder builder = new DocumentBuilder(doc);
  3326. //利用键值对存放数据
  3327. Dictionary<string, string> dic = new Dictionary<string, string>();
  3328. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3329. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3330. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3331. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3332. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3333. string row1_1 = "";
  3334. if (_EnterExitCosts.Visa > 0)
  3335. {
  3336. //insidePayTotal += _EnterExitCosts.Visa;
  3337. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3338. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3339. {
  3340. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3341. }
  3342. }
  3343. string row1_2 = "";
  3344. if (_EnterExitCosts.YiMiao > 0)
  3345. {
  3346. //insidePayTotal += _EnterExitCosts.YiMiao;
  3347. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3348. }
  3349. if (_EnterExitCosts.HeSuan > 0)
  3350. {
  3351. //insidePayTotal += _EnterExitCosts.HeSuan;
  3352. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3353. }
  3354. if (_EnterExitCosts.Service > 0)
  3355. {
  3356. //insidePayTotal += _EnterExitCosts.Service;
  3357. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3358. }
  3359. string row1_3 = "";
  3360. if (_EnterExitCosts.Safe > 0)
  3361. {
  3362. //insidePayTotal += _EnterExitCosts.Safe;
  3363. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3364. }
  3365. if (_EnterExitCosts.Ticket > 0)
  3366. {
  3367. //insidePayTotal += _EnterExitCosts.Ticket;
  3368. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3369. }
  3370. string row1 = "";
  3371. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3372. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3373. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3374. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3375. dic.Add("Row1Str", row1);
  3376. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3377. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3378. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3379. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3380. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3381. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3382. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3383. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3384. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3385. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3386. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3387. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3388. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3389. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3390. #region 填充word模板书签内容
  3391. foreach (var key in dic.Keys)
  3392. {
  3393. builder.MoveToBookmark(key);
  3394. builder.Write(dic[key]);
  3395. }
  3396. #endregion
  3397. #region 填充word表格内容
  3398. ////获读取指定表格方法二
  3399. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3400. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3401. for (int i = 0; i < dac1.Count; i++)
  3402. {
  3403. Grp_DayAndCost dac = dac1[i];
  3404. if (dac == null) continue;
  3405. builder.MoveToCell(0, i, 0, 0);
  3406. builder.Write("第" + dac.Days.ToString() + "晚:");
  3407. builder.MoveToCell(0, i, 1, 0);
  3408. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3409. builder.Write(dac.Place == null ? "" : dac.Place);
  3410. builder.MoveToCell(0, i, 2, 0);
  3411. builder.Write("费用标准:");
  3412. string curr = "";
  3413. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3414. if (currData != null)
  3415. {
  3416. curr = currData.Name;
  3417. }
  3418. builder.MoveToCell(0, i, 3, 0);
  3419. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3420. builder.MoveToCell(0, i, 4, 0);
  3421. builder.Write("费用小计:");
  3422. builder.MoveToCell(0, i, 5, 0);
  3423. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3424. }
  3425. //删除多余行
  3426. while (table1.Rows.Count > dac1.Count)
  3427. {
  3428. table1.Rows.RemoveAt(dac1.Count);
  3429. }
  3430. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3431. for (int i = 0; i < dac2.Count; i++)
  3432. {
  3433. Grp_DayAndCost dac = dac2[i];
  3434. if (dac == null) continue;
  3435. builder.MoveToCell(1, i, 0, 0);
  3436. builder.Write("第" + dac.Days.ToString() + "天:");
  3437. builder.MoveToCell(1, i, 1, 0);
  3438. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3439. builder.MoveToCell(1, i, 2, 0);
  3440. builder.Write("费用标准:");
  3441. string curr = "";
  3442. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3443. if (currData != null)
  3444. {
  3445. curr = currData.Name;
  3446. }
  3447. builder.MoveToCell(1, i, 3, 0);
  3448. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3449. builder.MoveToCell(1, i, 4, 0);
  3450. builder.Write("费用小计:");
  3451. builder.MoveToCell(1, i, 5, 0);
  3452. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3453. }
  3454. //删除多余行
  3455. while (table2.Rows.Count > dac2.Count)
  3456. {
  3457. table2.Rows.RemoveAt(dac2.Count);
  3458. }
  3459. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3460. for (int i = 0; i < dac3.Count; i++)
  3461. {
  3462. Grp_DayAndCost dac = dac3[i];
  3463. if (dac == null) continue;
  3464. builder.MoveToCell(2, i, 0, 0);
  3465. builder.Write("第" + dac.Days.ToString() + "天:");
  3466. builder.MoveToCell(2, i, 1, 0);
  3467. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3468. builder.MoveToCell(2, i, 2, 0);
  3469. builder.Write("费用标准:");
  3470. string curr = "";
  3471. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3472. if (currData != null)
  3473. {
  3474. curr = currData.Name;
  3475. }
  3476. builder.MoveToCell(2, i, 3, 0);
  3477. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3478. builder.MoveToCell(2, i, 4, 0);
  3479. builder.Write("费用小计:");
  3480. builder.MoveToCell(2, i, 5, 0);
  3481. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3482. }
  3483. //删除多余行
  3484. while (table3.Rows.Count > dac3.Count)
  3485. {
  3486. table3.Rows.RemoveAt(dac3.Count);
  3487. }
  3488. #endregion
  3489. //文件名
  3490. string strFileName = _DelegationInfo.TeamName + "出入境费用.docx";
  3491. //文件流下载
  3492. //byte[] bytes = null;
  3493. //using (MemoryStream stream = new MemoryStream())
  3494. //{
  3495. // doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  3496. // bytes = stream.ToArray();
  3497. //}
  3498. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3499. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3500. return Ok(JsonView(true, "成功", new { Url = url }));
  3501. }
  3502. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3503. {
  3504. //获取模板
  3505. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3506. //载入模板
  3507. Document doc = new Document(tempPath);
  3508. DocumentBuilder builder = new DocumentBuilder(doc);
  3509. Dictionary<string, string> dic = new Dictionary<string, string>();
  3510. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3511. {
  3512. List<string> list = new List<string>();
  3513. try
  3514. {
  3515. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3516. foreach (var item in spilitArr)
  3517. {
  3518. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3519. var depCode = spDotandEmpty[2].Substring(0, 3);
  3520. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3521. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3522. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3523. list.Add(depName);
  3524. list.Add(arrName);
  3525. }
  3526. list = list.Distinct().ToList();
  3527. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3528. }
  3529. catch (Exception)
  3530. {
  3531. dic.Add("ReturnCode", "行程录入不正确!");
  3532. }
  3533. }
  3534. else
  3535. {
  3536. dic.Add("ReturnCode", "未录入行程!");
  3537. }
  3538. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3539. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3540. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3541. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3542. {
  3543. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3544. dic.Add("Day", sp.Days.ToString());
  3545. }
  3546. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3547. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3548. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3549. dic.Add("Names", Names);
  3550. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3551. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3552. decimal dac1totalPrice = 0.00M;
  3553. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3554. foreach (var dac in dac1)
  3555. {
  3556. if (dac.SubTotal == 0.00M)
  3557. {
  3558. continue;
  3559. }
  3560. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3561. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3562. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3563. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3564. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3565. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown";
  3566. builder.Write(currency);//币种
  3567. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3568. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3569. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3570. builder.Write("");//人数
  3571. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3572. builder.Write("");//天数
  3573. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3574. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3575. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3576. decimal rate = 0.00M;
  3577. rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
  3578. builder.Write(rate.ToString("#0.0000"));//汇率
  3579. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3580. decimal rbmPrice = rate * dac.SubTotal;
  3581. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3582. accommodationStartIndex++;
  3583. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3584. }
  3585. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3586. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3587. {
  3588. table1.Rows.RemoveAt(i - 1);
  3589. foodandotherStartIndex--;
  3590. }
  3591. if (dac2.Count == dac3.Count)//国家 币种 金额
  3592. {
  3593. for (int i = 0; i < dac2.Count; i++)
  3594. {
  3595. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3596. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3597. }
  3598. }
  3599. decimal dac2totalPrice = 0.00M;
  3600. foreach (var dac in dac2)
  3601. {
  3602. if (dac.SubTotal == 0)
  3603. {
  3604. continue;
  3605. }
  3606. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3607. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3608. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3609. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown" ;
  3610. builder.Write(currency);//币种
  3611. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3612. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3613. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3614. builder.Write("");//人数
  3615. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3616. builder.Write("");//天数
  3617. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3618. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3619. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3620. decimal rate = 0.00M;
  3621. rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
  3622. builder.Write(rate.ToString("#0.0000"));//汇率
  3623. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3624. decimal rbmPrice = rate * dac.SubTotal;
  3625. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3626. foodandotherStartIndex++;
  3627. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3628. }
  3629. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3630. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3631. {
  3632. table1.Rows.RemoveAt(i - 1);
  3633. }
  3634. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3635. dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3636. dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3637. dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3638. foreach (var key in dic.Keys)
  3639. {
  3640. builder.MoveToBookmark(key);
  3641. builder.Write(dic[key]);
  3642. }
  3643. //模板文件名
  3644. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3645. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3646. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3647. return Ok(JsonView(true, "成功", new { Url = url }));
  3648. }
  3649. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3650. {
  3651. //获取模板
  3652. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3653. //载入模板
  3654. WorkbookDesigner designer = new WorkbookDesigner();
  3655. designer.Workbook = new Workbook(tempPath);
  3656. Dictionary<string, string> dic = new Dictionary<string, string>();
  3657. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3658. {
  3659. List<string> list = new List<string>();
  3660. try
  3661. {
  3662. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3663. foreach (var item in spilitArr)
  3664. {
  3665. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3666. var depCode = spDotandEmpty[2].Substring(0, 3);
  3667. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3668. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3669. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3670. list.Add(depName);
  3671. list.Add(arrName);
  3672. }
  3673. list = list.Distinct().ToList();
  3674. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3675. }
  3676. catch (Exception)
  3677. {
  3678. dic.Add("ReturnCode", "行程录入不正确!");
  3679. }
  3680. }
  3681. else
  3682. {
  3683. dic.Add("ReturnCode", "未录入行程!");
  3684. }
  3685. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3686. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3687. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3688. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3689. {
  3690. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3691. dic.Add("Day", sp.Days.ToString());
  3692. }
  3693. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3694. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3695. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3696. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3697. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3698. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3699. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3700. designer.SetDataSource("Name", Names);
  3701. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3702. designer.SetDataSource("Day", dic["Day"] + "天");
  3703. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3704. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3705. int startIndex = 10;
  3706. const int startIndexcopy = 10;
  3707. if (dac2.Count == dac3.Count)//国家 币种 金额
  3708. {
  3709. for (int i = 0; i < dac2.Count; i++)
  3710. {
  3711. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3712. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3713. }
  3714. }
  3715. DataTable dtdac1 = new DataTable();
  3716. List<string> place = new List<string>();
  3717. dtdac1.Columns.AddRange(new DataColumn[] {
  3718. new DataColumn(){ ColumnName = "city"},
  3719. new DataColumn(){ ColumnName = "curr"},
  3720. new DataColumn(){ ColumnName = "criterion"},
  3721. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3722. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3723. new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
  3724. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3725. new DataColumn(){ ColumnName = "costRMB"},
  3726. });
  3727. DataTable dtdac2 = new DataTable();
  3728. dtdac2.Columns.AddRange(new DataColumn[] {
  3729. new DataColumn(){ ColumnName = "city"},
  3730. new DataColumn(){ ColumnName = "curr"},
  3731. new DataColumn(){ ColumnName = "criterion"},
  3732. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3733. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3734. new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
  3735. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3736. new DataColumn(){ ColumnName = "costRMB"},
  3737. });
  3738. dtdac1.TableName = "tb1";
  3739. dtdac2.TableName = "tb2";
  3740. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3741. foreach (var item in dac1)
  3742. {
  3743. item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3744. if (place.Contains(item.Place))
  3745. {
  3746. continue;
  3747. }
  3748. DataRow row = dtdac1.NewRow();
  3749. row["city"] = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3750. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
  3751. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3752. row["curr"] = currency;
  3753. row["rate"] = rate;
  3754. row["criterion"] = item.Cost;
  3755. row["number"] = 1;
  3756. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3757. //row["costRMB"] = rbmPrice;
  3758. dtdac1.Rows.Add(row);
  3759. place.Add(item.Place);
  3760. }
  3761. place = new List<string>();
  3762. foreach (var item in dac2)
  3763. {
  3764. item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3765. if (place.Contains(item.Place))
  3766. {
  3767. continue;
  3768. }
  3769. DataRow row = dtdac2.NewRow();
  3770. row["city"] = item.Place;
  3771. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
  3772. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3773. row["curr"] = currency;
  3774. row["rate"] = rate;
  3775. row["criterion"] = item.Cost;
  3776. row["number"] = 1;
  3777. row["day"] = dac2.FindAll(x => x.Place == item.Place).Count;
  3778. //row["cost"] = item.SubTotal;
  3779. //row["costRMB"] = rbmPrice;
  3780. dtdac2.Rows.Add(row);
  3781. place.Add(item.Place);
  3782. //dac2totalPrice += rbmPrice;
  3783. }
  3784. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  3785. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  3786. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3787. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  3788. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元,公务舱:{_EnterExitCosts.OutsaideGWPay.ToString("#0.00")}元";
  3789. string cellStr = $" 5.其他费用(签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,保险费 :{_EnterExitCosts.Safe.ToString("#0.00")}元)";
  3790. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + _EnterExitCosts.Visa + _EnterExitCosts.Safe;
  3791. string celllastStr = $" 经审核,住宿费 {dac1totalPrice.ToString("#0.00")} 元,伙食费和公杂费 {dac2totalPrice.ToString(".00")} 元,培训费 元,国际旅费 {(_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00")} 元,其他费用 {(_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00")} 元,本次出国经费预算合计为 {s.ToString("#0.00")} 元。其中:市本级安排 。";
  3792. designer.SetDataSource("cell4Str", cell4Str);
  3793. designer.SetDataSource("cellStr", cellStr);
  3794. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  3795. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3796. designer.SetDataSource("celllastStr", celllastStr);
  3797. Workbook wb = designer.Workbook;
  3798. var sheet = wb.Worksheets[0];
  3799. //绑定datatable数据集
  3800. designer.SetDataSource(dtdac1);
  3801. designer.SetDataSource(dtdac2);
  3802. designer.Process();
  3803. var rowStart = dtdac1.Rows.Count;
  3804. while (rowStart > 0)
  3805. {
  3806. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  3807. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3808. startIndex++;
  3809. rowStart--;
  3810. }
  3811. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  3812. startIndex += 1; //总计行
  3813. rowStart = dtdac2.Rows.Count;
  3814. while (rowStart > 0)
  3815. {
  3816. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  3817. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3818. startIndex++;
  3819. rowStart--;
  3820. }
  3821. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  3822. wb.CalculateFormula(true);
  3823. //模板文件名
  3824. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  3825. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3826. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3827. return Ok(JsonView(true, "成功", new { Url = url }));
  3828. }
  3829. }
  3830. else if (dto.ExportType == 2) //表格
  3831. {
  3832. //利用键值对存放数据
  3833. Dictionary<string, string> dic = new Dictionary<string, string>();
  3834. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3835. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3836. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3837. dic.Add("Day", sp.Days.ToString());
  3838. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3839. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  3840. {
  3841. //获取模板
  3842. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  3843. //载入模板
  3844. Document doc = new Document(tempPath);
  3845. DocumentBuilder builder = new DocumentBuilder(doc);
  3846. dic.Add("TeamName", _DelegationInfo.TeamName);
  3847. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3848. dic.Add("TellPhone", _DelegationInfo.TellPhone);
  3849. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  3850. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  3851. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3852. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3853. int rowCount = 10;//总人数行
  3854. int startRowIndex = 7; //起始行
  3855. for (int i = 0; i < DeleClientList.Count; i++)
  3856. {
  3857. builder.MoveToCell(0, startRowIndex, 0, 0);
  3858. builder.Write(DeleClientList[i].Name); //出国人员姓名
  3859. builder.MoveToCell(0, startRowIndex, 1, 0);
  3860. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  3861. builder.Write(sex);//性别
  3862. builder.MoveToCell(0, startRowIndex, 2, 0);
  3863. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  3864. builder.MoveToCell(0, startRowIndex, 3, 0);
  3865. builder.Write(DeleClientList[i].Company);//工作单位
  3866. builder.MoveToCell(0, startRowIndex, 4, 0);
  3867. builder.Write(DeleClientList[i].Job);//职务及级别
  3868. builder.MoveToCell(0, startRowIndex, 5, 0);
  3869. builder.Write("");//人员属性
  3870. builder.MoveToCell(0, startRowIndex, 6, 0);
  3871. builder.Write("");//上次出国时间
  3872. startRowIndex++;
  3873. }
  3874. int nullRow = rowCount - DeleClientList.Count;//空行
  3875. for (int i = 0; i < nullRow; i++)
  3876. {
  3877. table1.Rows.Remove(table1.Rows[startRowIndex]);
  3878. }
  3879. foreach (var key in dic.Keys)
  3880. {
  3881. builder.MoveToBookmark(key);
  3882. builder.Write(dic[key]);
  3883. }
  3884. //模板文件名
  3885. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  3886. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3887. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3888. return Ok(JsonView(true, "成功", new { Url = url }));
  3889. }
  3890. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  3891. {
  3892. //获取模板
  3893. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  3894. //载入模板
  3895. Document doc = new Document(tempPath);
  3896. DocumentBuilder builder = new DocumentBuilder(doc);
  3897. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  3898. dic.Add("Names", Names);
  3899. int accommodationStartIndex = 6;
  3900. int foodandotherStartIndex = 19;//
  3901. int accommodationRows = 12, foodandotherRows = 12;
  3902. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3903. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3904. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3905. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3906. decimal dac1totalPrice = 0.00M;
  3907. foreach (var dac in dac1)
  3908. {
  3909. if (dac.SubTotal == 0)
  3910. {
  3911. continue;
  3912. }
  3913. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3914. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3915. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3916. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3917. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3918. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
  3919. builder.Write(currency);//币种
  3920. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3921. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3922. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3923. builder.Write("");//人数
  3924. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3925. builder.Write("");//天数
  3926. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3927. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3928. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3929. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3930. builder.Write(rate.ToString("#0.0000"));//汇率
  3931. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3932. decimal rbmPrice = rate * dac.SubTotal;
  3933. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3934. accommodationStartIndex++;
  3935. dac1totalPrice += rbmPrice;
  3936. }
  3937. dic.Add("dac1totalPrice", dac1totalPrice.ToString());
  3938. if (dac2.Count == dac3.Count)//国家 币种 金额
  3939. {
  3940. for (int i = 0; i < dac2.Count; i++)
  3941. {
  3942. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3943. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3944. }
  3945. }
  3946. decimal dac2totalPrice = 0.00M;
  3947. foreach (var dac in dac2)
  3948. {
  3949. if (dac.SubTotal == 0)
  3950. {
  3951. continue;
  3952. }
  3953. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3954. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3955. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3956. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
  3957. builder.Write(currency);//币种
  3958. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3959. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3960. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3961. builder.Write("");//人数
  3962. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3963. builder.Write("");//天数
  3964. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3965. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3966. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3967. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3968. builder.Write(rate.ToString());//汇率
  3969. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3970. decimal rbmPrice = rate * dac.SubTotal;
  3971. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3972. foodandotherStartIndex++;
  3973. dac2totalPrice += rbmPrice;
  3974. }
  3975. dic.Add("dac2totalPrice", dac2totalPrice.ToString());
  3976. //删除空行
  3977. if (dac1.Count < accommodationRows)
  3978. {
  3979. int nullRow = accommodationRows - dac1.Count;
  3980. }
  3981. foreach (var key in dic.Keys)
  3982. {
  3983. builder.MoveToBookmark(key);
  3984. builder.Write(dic[key]);
  3985. }
  3986. //模板文件名
  3987. string strFileName = $"省级单位出(境)经费报销单.docx";
  3988. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3989. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3990. return Ok(JsonView(true, "成功", new { Url = url }));
  3991. }
  3992. }
  3993. else if (dto.ExportType == 3)
  3994. {
  3995. if (dto.SubTypeId == 1) //团组成员名单
  3996. {
  3997. if (DeleClientList.Count < 1)
  3998. {
  3999. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4000. }
  4001. //获取模板
  4002. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4003. //载入模板
  4004. Document doc = new Document(tempPath);
  4005. DocumentBuilder builder = new DocumentBuilder(doc);
  4006. //获取word里所有表格
  4007. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4008. //获取所填表格的序数
  4009. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4010. var rowStart = tableOne.Rows[0]; //获取第1行
  4011. //循环赋值
  4012. for (int i = 0; i < DeleClientList.Count; i++)
  4013. {
  4014. builder.MoveToCell(0, i + 1, 0, 0);
  4015. builder.Write(DeleClientList[i].Name);
  4016. builder.MoveToCell(0, i + 1, 1, 0);
  4017. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4018. builder.Write(sex);
  4019. builder.MoveToCell(0, i + 1, 2, 0);
  4020. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4021. builder.MoveToCell(0, i + 1, 3, 0);
  4022. builder.Write(DeleClientList[i].Company);
  4023. builder.MoveToCell(0, i + 1, 4, 0);
  4024. builder.Write(DeleClientList[i].Job);
  4025. }
  4026. //删除多余行
  4027. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4028. {
  4029. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4030. }
  4031. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4032. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4033. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4034. return Ok(JsonView(true, "成功", new { Url = url }));
  4035. }
  4036. }
  4037. return Ok(JsonView(false,"操作失败!"));
  4038. }
  4039. catch (Exception ex)
  4040. {
  4041. return Ok(JsonView(false, ex.Message));
  4042. }
  4043. }
  4044. /// <summary>
  4045. /// 团组模块 - 出入境费用 - 明细表导出
  4046. /// </summary>
  4047. /// <returns></returns>
  4048. [HttpPost]
  4049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4050. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4051. {
  4052. try
  4053. {
  4054. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4055. if (data.Code != 0)
  4056. {
  4057. return Ok(JsonView(false, data.Msg));
  4058. }
  4059. return Ok(JsonView(true, data.Msg, data.Data));
  4060. }
  4061. catch (Exception ex)
  4062. {
  4063. return Ok(JsonView(false, ex.Message));
  4064. }
  4065. }
  4066. /// <summary>
  4067. /// 团组模块 - 出入境费用 - 子项删除
  4068. /// </summary>
  4069. /// <returns></returns>
  4070. [HttpPost]
  4071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4072. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4073. {
  4074. try
  4075. {
  4076. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4077. if (data.Code != 0)
  4078. {
  4079. return Ok(JsonView(false, data.Msg));
  4080. }
  4081. return Ok(JsonView(true, "操作成功!", data.Data));
  4082. }
  4083. catch (Exception ex)
  4084. {
  4085. return Ok(JsonView(false, ex.Message));
  4086. }
  4087. }
  4088. /// <summary>
  4089. /// 团组模块 - 出入境国家费用标准 List
  4090. /// </summary>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4094. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4095. {
  4096. try
  4097. {
  4098. Stopwatch sw = new Stopwatch();
  4099. sw.Start();
  4100. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4101. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4102. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4103. Where gntf.Isdel = 0");
  4104. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4105. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4106. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4107. //foreach (var item in nationalTravel)
  4108. //{
  4109. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4110. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4111. // if (otherData != null)
  4112. // {
  4113. // cityData.Remove(otherData);
  4114. // cityData.Add(otherData);
  4115. // }
  4116. // nationalTravelFeeData1.Add(new
  4117. // {
  4118. // Country = item.Country,
  4119. // CityData = cityData
  4120. // });
  4121. //}
  4122. sw.Stop();
  4123. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4124. }
  4125. catch (Exception ex)
  4126. {
  4127. return Ok(JsonView(false, ex.Message));
  4128. throw;
  4129. }
  4130. }
  4131. /// <summary>
  4132. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4133. /// </summary>
  4134. /// <returns></returns>
  4135. [HttpPost]
  4136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4137. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4138. {
  4139. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4140. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4141. List<string> countryData = new List<string>();
  4142. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4143. countryData = countryData.Distinct().ToList();
  4144. List<dynamic> dataSource = new List<dynamic>();
  4145. foreach (var item in countryData)
  4146. {
  4147. List<string> cityData1 = new List<string>();
  4148. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4149. var countryData2 = new
  4150. {
  4151. CountryName = item,
  4152. CityData = cityData1
  4153. };
  4154. dataSource.Add(countryData2);
  4155. }
  4156. return Ok(JsonView(true, "查询成功!", dataSource));
  4157. }
  4158. /// <summary>
  4159. /// 团组模块 - 出入境国家费用标准 Page List
  4160. /// </summary>
  4161. /// <returns></returns>
  4162. [HttpPost]
  4163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4164. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4165. {
  4166. int portId = dto.PortType;
  4167. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4168. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4169. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4170. string whereSql = string.Empty;
  4171. if (!string.IsNullOrEmpty(dto.Country))
  4172. {
  4173. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4174. }
  4175. if (!string.IsNullOrEmpty(dto.City))
  4176. {
  4177. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4178. }
  4179. string pageSql = string.Format(@"Select * From (
  4180. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4181. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4182. From Grp_NationalTravelFee gntf
  4183. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4184. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4185. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4186. RefAsync<int> total = 0;
  4187. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4188. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4189. }
  4190. /// <summary>
  4191. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4192. /// </summary>
  4193. /// <returns></returns>
  4194. [HttpPost]
  4195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4196. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4197. {
  4198. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4199. int portId = dto.PortType;
  4200. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4201. string whereSql = string.Empty;
  4202. if (!string.IsNullOrEmpty(dto.Country))
  4203. {
  4204. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4205. }
  4206. if (!string.IsNullOrEmpty(dto.City))
  4207. {
  4208. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4209. }
  4210. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4211. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4212. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4213. From Grp_NationalTravelFee gntf
  4214. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4215. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4216. Where gntf.Isdel = 0 {0} ", whereSql);
  4217. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4218. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4219. }
  4220. /// <summary>
  4221. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4222. /// </summary>
  4223. /// <returns></returns>
  4224. [HttpPost]
  4225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4226. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4227. {
  4228. try
  4229. {
  4230. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4231. if (data.Code != 0)
  4232. {
  4233. return Ok(JsonView(false, data.Msg));
  4234. }
  4235. return Ok(JsonView(true, "操作成功!", data.Data));
  4236. }
  4237. catch (Exception ex)
  4238. {
  4239. return Ok(JsonView(false, ex.Message));
  4240. }
  4241. }
  4242. /// <summary>
  4243. /// 团组模块 - 出入境国家费用标准 - Del
  4244. /// </summary>
  4245. /// <returns></returns>
  4246. [HttpPost]
  4247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4248. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4249. {
  4250. try
  4251. {
  4252. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4253. {
  4254. Id = dto.Id,
  4255. DeleteUserId = dto.DeleteUserId,
  4256. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4257. IsDel = 1
  4258. };
  4259. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4260. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4261. .WhereColumns(it => new { it.Id })
  4262. .ExecuteCommandAsync();
  4263. if (delStatus <= 0)
  4264. {
  4265. return Ok(JsonView(false, "删除失败!"));
  4266. }
  4267. return Ok(JsonView(true, "操作成功!"));
  4268. }
  4269. catch (Exception ex)
  4270. {
  4271. return Ok(JsonView(false, ex.Message));
  4272. }
  4273. }
  4274. #endregion
  4275. #region 签证费用录入
  4276. /// <summary>
  4277. /// 根据diid查询签证费用列表
  4278. /// </summary>
  4279. /// <param name="dto"></param>
  4280. /// <returns></returns>
  4281. [HttpPost]
  4282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4283. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4284. {
  4285. try
  4286. {
  4287. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4288. if (groupData.Code != 0)
  4289. {
  4290. return Ok(JsonView(false, groupData.Msg));
  4291. }
  4292. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4293. }
  4294. catch (Exception ex)
  4295. {
  4296. return Ok(JsonView(false, ex.Message));
  4297. }
  4298. }
  4299. /// <summary>
  4300. /// 根据签证费用Id查询单条数据及c表数据
  4301. /// </summary>
  4302. /// <param name="dto"></param>
  4303. /// <returns></returns>
  4304. [HttpPost]
  4305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4306. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4307. {
  4308. try
  4309. {
  4310. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4311. if (groupData.Code != 0)
  4312. {
  4313. return Ok(JsonView(false, groupData.Msg));
  4314. }
  4315. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4316. }
  4317. catch (Exception ex)
  4318. {
  4319. return Ok(JsonView(false, ex.Message));
  4320. }
  4321. }
  4322. /// <summary>
  4323. /// 签证费用删除
  4324. /// </summary>
  4325. /// <param name="dto"></param>
  4326. /// <returns></returns>
  4327. [HttpPost]
  4328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4329. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4330. {
  4331. try
  4332. {
  4333. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4334. if (!res)
  4335. {
  4336. return Ok(JsonView(false, "删除失败"));
  4337. }
  4338. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  4339. {
  4340. IsDel = 1,
  4341. DeleteUserId = dto.DeleteUserId,
  4342. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4343. }).ExecuteCommandAsync();
  4344. return Ok(JsonView(true, "删除成功!"));
  4345. }
  4346. catch (Exception ex)
  4347. {
  4348. return Ok(JsonView(false, "程序错误!"));
  4349. throw;
  4350. }
  4351. }
  4352. /// <summary>
  4353. /// 签证费用录入下拉框初始化
  4354. /// </summary>
  4355. /// <returns></returns>
  4356. [HttpPost]
  4357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4358. public async Task<IActionResult> VisaPriceAddSelect()
  4359. {
  4360. try
  4361. {
  4362. //支付方式
  4363. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4364. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4365. //币种
  4366. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4367. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4368. //乘客类型
  4369. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4370. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4371. //卡类型
  4372. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4373. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4374. var data = new
  4375. {
  4376. Payment = _Payment,
  4377. CurrencyList = _CurrencyList,
  4378. PassengerType = _PassengerType,
  4379. BankCard = _BankCard
  4380. };
  4381. return Ok(JsonView(true, "查询成功!", data));
  4382. }
  4383. catch (Exception ex)
  4384. {
  4385. return Ok(JsonView(false, "程序错误!"));
  4386. throw;
  4387. }
  4388. }
  4389. /// <summary>
  4390. /// 签证费用录入操作(Status:1.新增,2.修改)
  4391. /// </summary>
  4392. /// <param name="dto"></param>
  4393. /// <returns></returns>
  4394. [HttpPost]
  4395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4396. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4397. {
  4398. try
  4399. {
  4400. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4401. if (groupData.Code != 0)
  4402. {
  4403. return Ok(JsonView(false, groupData.Msg));
  4404. }
  4405. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4406. }
  4407. catch (Exception ex)
  4408. {
  4409. return Ok(JsonView(false, ex.Message));
  4410. }
  4411. }
  4412. #endregion
  4413. #region op费用录入
  4414. /// <summary>
  4415. /// 根据diid查询op费用列表
  4416. /// </summary>
  4417. /// <param name="dto"></param>
  4418. /// <returns></returns>
  4419. [HttpPost]
  4420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4421. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4422. {
  4423. try
  4424. {
  4425. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4426. if (groupData.Code != 0)
  4427. {
  4428. return Ok(JsonView(false, groupData.Msg));
  4429. }
  4430. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4431. }
  4432. catch (Exception ex)
  4433. {
  4434. return Ok(JsonView(false, ex.Message));
  4435. }
  4436. }
  4437. /// <summary>
  4438. /// 根据op费用Id查询单条数据及c表数据
  4439. /// </summary>
  4440. /// <param name="dto"></param>
  4441. /// <returns></returns>
  4442. [HttpPost]
  4443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4444. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4445. {
  4446. try
  4447. {
  4448. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4449. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4450. var data = new
  4451. {
  4452. CarTouristGuideGround = _groupData,
  4453. CreditCardPayment = _creditCardPayment
  4454. };
  4455. return Ok(JsonView(true, "查询成功!", data));
  4456. }
  4457. catch (Exception ex)
  4458. {
  4459. return Ok(JsonView(false, "程序错误!"));
  4460. }
  4461. }
  4462. /// <summary>
  4463. /// op费用删除
  4464. /// </summary>
  4465. /// <param name="dto"></param>
  4466. /// <returns></returns>
  4467. [HttpPost]
  4468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4469. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4470. {
  4471. try
  4472. {
  4473. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4474. if (!res)
  4475. {
  4476. return Ok(JsonView(false, "删除失败"));
  4477. }
  4478. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4479. {
  4480. IsDel = 1,
  4481. DeleteUserId = dto.DeleteUserId,
  4482. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4483. }).ExecuteCommandAsync();
  4484. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4485. {
  4486. IsDel = 1,
  4487. DeleteUserId = dto.DeleteUserId,
  4488. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4489. }).ExecuteCommandAsync();
  4490. return Ok(JsonView(true, "删除成功!"));
  4491. }
  4492. catch (Exception ex)
  4493. {
  4494. return Ok(JsonView(false, "程序错误!"));
  4495. throw;
  4496. }
  4497. }
  4498. /// <summary>
  4499. /// op费用录入操作(Status:1.新增,2.修改)
  4500. /// </summary>
  4501. /// <param name="dto"></param>
  4502. /// <returns></returns>
  4503. [HttpPost]
  4504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4505. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  4506. {
  4507. try
  4508. {
  4509. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  4510. if (groupData.Code != 0)
  4511. {
  4512. return Ok(JsonView(false, groupData.Msg));
  4513. }
  4514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4515. }
  4516. catch (Exception ex)
  4517. {
  4518. return Ok(JsonView(false, ex.Message));
  4519. }
  4520. }
  4521. /// <summary>
  4522. /// 填写费用详细页面初始化绑定
  4523. /// </summary>
  4524. /// <param name="dto"></param>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  4529. {
  4530. try
  4531. {
  4532. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  4533. if (groupData.Code != 0)
  4534. {
  4535. return Ok(JsonView(false, groupData.Msg));
  4536. }
  4537. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4538. }
  4539. catch (Exception ex)
  4540. {
  4541. return Ok(JsonView(false, ex.Message));
  4542. }
  4543. }
  4544. /// <summary>
  4545. /// 根据op费用Id查询详细数据
  4546. /// </summary>
  4547. /// <param name="dto"></param>
  4548. /// <returns></returns>
  4549. [HttpPost]
  4550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4551. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  4552. {
  4553. try
  4554. {
  4555. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  4556. if (groupData.Code != 0)
  4557. {
  4558. return Ok(JsonView(false, groupData.Msg));
  4559. }
  4560. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4561. }
  4562. catch (Exception ex)
  4563. {
  4564. return Ok(JsonView(false, ex.Message));
  4565. }
  4566. }
  4567. /// <summary>
  4568. /// OP费用录入填写详情
  4569. /// </summary>
  4570. /// <param name="dto"></param>
  4571. /// <returns></returns>
  4572. [HttpPost]
  4573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4574. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  4575. {
  4576. try
  4577. {
  4578. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  4579. if (groupData.Code != 0)
  4580. {
  4581. return Ok(JsonView(false, groupData.Msg));
  4582. }
  4583. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4584. }
  4585. catch (Exception ex)
  4586. {
  4587. return Ok(JsonView(false, ex.Message));
  4588. }
  4589. }
  4590. /// <summary>
  4591. /// 获取三公详细所有城市
  4592. /// </summary>
  4593. /// <returns></returns>
  4594. [HttpGet]
  4595. public IActionResult OpCarCityResult()
  4596. {
  4597. var jw = JsonView(false);
  4598. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x=>x.IsDel == 0).Select(x => new
  4599. {
  4600. x.Id,
  4601. x.Country,
  4602. x.City,
  4603. }).ToList();
  4604. if (data.Count > 0)
  4605. {
  4606. jw = JsonView(true, "获取成功!", data);
  4607. }
  4608. else
  4609. {
  4610. jw.Msg = "城市数据未空!";
  4611. jw.Data = new string[0];
  4612. }
  4613. return Ok(jw);
  4614. }
  4615. #endregion
  4616. #region 团组成本
  4617. /// <summary>
  4618. /// 团组成本数据初始化
  4619. /// </summary>
  4620. /// <param name="dto"></param>
  4621. /// <returns></returns>
  4622. [HttpPost]
  4623. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  4624. {
  4625. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  4626. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  4627. WHEN COUNT(*) >= 0 THEN 'True'
  4628. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  4629. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  4630. ").ToList(); //团组列表
  4631. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  4632. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  4633. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  4634. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  4635. if (groupinfoValue != null)
  4636. {
  4637. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  4638. var spArr = new string[1] { countryArr };
  4639. if (countryArr.Contains("|"))
  4640. {
  4641. spArr = countryArr.Split("|");
  4642. }
  4643. else if (countryArr.Contains("、"))
  4644. {
  4645. spArr = countryArr.Split("、");
  4646. }
  4647. foreach (var item in spArr.Where(x=>!string.IsNullOrWhiteSpace(x)).ToList())
  4648. {
  4649. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  4650. if (dbQueryCountry != null)
  4651. {
  4652. visaCountryInfoArr.Add(dbQueryCountry);
  4653. }
  4654. }
  4655. }
  4656. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  4657. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  4658. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  4659. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  4660. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  4661. //GroupCostParameter.Add(new
  4662. // Grp_GroupCostParameter());
  4663. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  4664. return Ok(JsonView(new
  4665. {
  4666. groupList,
  4667. groupInfo,
  4668. groupChecks,
  4669. groupCost = groupCostMap,
  4670. hotelNumber,
  4671. GroupCostParameter = GroupCostParameterMap,
  4672. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  4673. {
  4674. x.VisaCountry,
  4675. x.VisaPrice,
  4676. x.Id,
  4677. }).ToList(),
  4678. baoPi = _GroupCostParameterRepository.GetBaoPi(diid)
  4679. }));
  4680. }
  4681. /// <summary>
  4682. /// 团组成本信息保存
  4683. /// </summary>
  4684. /// <param name="dto"></param>
  4685. /// <returns></returns>
  4686. [HttpPost]
  4687. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  4688. {
  4689. if (dto.Diid <= 0 || dto.Userid <= 0)
  4690. {
  4691. return Ok(JsonView(false));
  4692. }
  4693. JsonView jw = null;
  4694. bool isTrue = false;
  4695. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  4696. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  4697. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  4698. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  4699. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  4700. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  4701. try
  4702. {
  4703. _sqlSugar.BeginTran();
  4704. isTrue = await _GroupCostRepository.
  4705. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  4706. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  4707. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  4708. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  4709. _sqlSugar.CommitTran();
  4710. jw = JsonView(true, "保存成功!", isTrue);
  4711. }
  4712. catch (Exception)
  4713. {
  4714. _sqlSugar.RollbackTran();
  4715. jw = JsonView(false);
  4716. }
  4717. return Ok(jw);
  4718. }
  4719. /// <summary>
  4720. /// 司兼导数据
  4721. /// </summary>
  4722. /// <param name="dto"></param>
  4723. /// <returns></returns>
  4724. [HttpPost]
  4725. public IActionResult GetCarGuides(CarGuidesDto dto)
  4726. {
  4727. JsonView jw = null;
  4728. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  4729. jw = JsonView(true, "获取成功!", Data);
  4730. return Ok(jw);
  4731. }
  4732. /// <summary>
  4733. /// 导游数据
  4734. /// </summary>
  4735. /// <param name="dto"></param>
  4736. /// <returns></returns>
  4737. [HttpPost]
  4738. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  4739. {
  4740. JsonView jw = null;
  4741. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  4742. // 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
  4743. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  4744. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  4745. jw = JsonView(true, "获取成功!", Data);
  4746. return Ok(jw);
  4747. }
  4748. /// <summary>
  4749. /// 成本车数据
  4750. /// </summary>
  4751. /// <param name="dto"></param>
  4752. /// <returns></returns>
  4753. [HttpPost]
  4754. public IActionResult GetCarInfo(CarGuidesDto dto)
  4755. {
  4756. JsonView jw = null;
  4757. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  4758. jw = JsonView(true, "获取成功!", Data);
  4759. return Ok(jw);
  4760. }
  4761. /// <summary>
  4762. /// 景点数据
  4763. /// </summary>
  4764. /// <param name="dto"></param>
  4765. /// <returns></returns>
  4766. [HttpPost]
  4767. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  4768. {
  4769. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  4770. return Ok(JsonView(true, "获取成功!", Data));
  4771. }
  4772. /// <summary>
  4773. /// 成本通知
  4774. /// </summary>
  4775. /// <param name="dto"></param>
  4776. /// <returns></returns>
  4777. [HttpPost]
  4778. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  4779. {
  4780. if (dto.Diid < 0)
  4781. {
  4782. return Ok(JsonView(false));
  4783. }
  4784. JsonView jw = null;
  4785. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  4786. if (GroupCostParameter != null)
  4787. {
  4788. int IsShare = 0;
  4789. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  4790. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  4791. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id,IsShare);
  4792. string msg = string.Empty;
  4793. if (isTrue)
  4794. {
  4795. if (IsShare == 0)
  4796. {
  4797. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  4798. }
  4799. else
  4800. {
  4801. msg = "通知成功,其他模块操作人员可见此成本信息!";
  4802. }
  4803. jw = JsonView(isTrue, msg);
  4804. }
  4805. else
  4806. {
  4807. msg = "修改失败!";
  4808. jw = JsonView(isTrue, msg);
  4809. }
  4810. }
  4811. else
  4812. {
  4813. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  4814. }
  4815. return Ok(jw);
  4816. }
  4817. /// <summary>
  4818. /// 导出收款账单
  4819. /// </summary>
  4820. /// <param name="dto"></param>
  4821. /// <returns></returns>
  4822. [HttpPost]
  4823. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  4824. {
  4825. if (dto.Diid == 0)
  4826. {
  4827. return Ok(JsonView(false, "请传递团组id"));
  4828. }
  4829. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  4830. if (deleInfo.Code != 0)
  4831. {
  4832. return Ok(JsonView(false, "团组信息查询失败!"));
  4833. }
  4834. var di = deleInfo.Data as DelegationInfoWebView;
  4835. if (di != null)
  4836. {
  4837. //文件名
  4838. string strFileName = di.TeamName + "-收款账单.doc";
  4839. //获取模板
  4840. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  4841. //载入模板
  4842. Document doc = new Document(tmppath);
  4843. decimal TotalPrice = 0.00M;
  4844. string itemStr = string.Empty;
  4845. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  4846. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  4847. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  4848. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  4849. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  4850. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  4851. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  4852. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  4853. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x=>x.Key);
  4854. foreach(var cost in groupCostType)
  4855. {
  4856. var List = cost.ToList();
  4857. if (cost.Key == "A")
  4858. {
  4859. foreach (var ListItem in List)
  4860. {
  4861. if (ListItem.number > 0)
  4862. {
  4863. if (ListItem.code.Contains("TBR"))
  4864. {
  4865. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4866. }
  4867. else
  4868. {
  4869. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4870. }
  4871. TotalPrice += (ListItem.number * ListItem.price);
  4872. }
  4873. }
  4874. }
  4875. else
  4876. {
  4877. itemStr = itemStr.Insert(0, "A段\r\n");
  4878. itemStr += "B段\r\n";
  4879. foreach (var ListItem in List)
  4880. {
  4881. if (ListItem.number > 0)
  4882. {
  4883. if (ListItem.code.Contains("TBR"))
  4884. {
  4885. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4886. }
  4887. else
  4888. {
  4889. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4890. }
  4891. TotalPrice += (ListItem.number * ListItem.price);
  4892. }
  4893. }
  4894. }
  4895. }
  4896. #region 替换Word模板书签内容
  4897. Dictionary<string, string> marks = new Dictionary<string, string>();
  4898. marks.Add("To", di.ClientUnit);//付款方
  4899. marks.Add("ToTel", di.TellPhone);//付款方电话
  4900. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  4901. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  4902. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  4903. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  4904. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  4905. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  4906. marks.Add("PayItemContent", itemStr);//详细信息
  4907. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  4908. #endregion
  4909. ////注
  4910. //if (doc.Range.Bookmarks["Attention"] != null)
  4911. //{
  4912. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  4913. // mark.Text = frList[0].Attention;
  4914. //}
  4915. foreach (var item in marks.Keys)
  4916. {
  4917. if (doc.Range.Bookmarks[item] != null)
  4918. {
  4919. Bookmark mark = doc.Range.Bookmarks[item];
  4920. mark.Text = marks[item];
  4921. }
  4922. }
  4923. byte[] bytes = null;
  4924. using (MemoryStream stream = new MemoryStream())
  4925. {
  4926. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  4927. bytes = stream.ToArray();
  4928. }
  4929. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  4930. return Ok(JsonView(true,"",new
  4931. {
  4932. Data = bytes,
  4933. strFileName,
  4934. }));
  4935. }
  4936. else
  4937. {
  4938. return Ok(JsonView(false,"团组信息不存在!"));
  4939. }
  4940. }
  4941. /// <summary>
  4942. /// 导出团组成本
  4943. /// </summary>
  4944. /// <param name="dto"></param>
  4945. /// <returns></returns>
  4946. [HttpPost]
  4947. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  4948. {
  4949. var jw = JsonView(false);
  4950. if (dto.Diid == 0)
  4951. {
  4952. return Ok(JsonView(false, "请传递团组id"));
  4953. }
  4954. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  4955. if (deleInfo.Code != 0)
  4956. {
  4957. return Ok(JsonView(false, "团组信息查询失败!"));
  4958. }
  4959. var di = deleInfo.Data as DelegationInfoWebView;
  4960. if (di == null)
  4961. {
  4962. return Ok(JsonView(false, "团组信息查询失败!"));
  4963. }
  4964. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  4965. WorkbookDesigner designer = new WorkbookDesigner();
  4966. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  4967. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  4968. for (int i = 0; i < List_GC.Count; i++)
  4969. {
  4970. GroupCost_Excel gc = new GroupCost_Excel();
  4971. gc.Id = List_GC[i].Id;
  4972. gc.Diid = List_GC[i].Diid.ToString();
  4973. gc.DAY = List_GC[i].DAY;
  4974. string week = "";
  4975. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  4976. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  4977. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  4978. gc.ITIN = List_GC[i].ITIN;
  4979. gc.CarType = List_GC[i].CarType;
  4980. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  4981. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  4982. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  4983. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  4984. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  4985. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  4986. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  4987. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  4988. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  4989. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  4990. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  4991. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  4992. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  4993. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  4994. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  4995. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  4996. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  4997. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  4998. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  4999. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  5000. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  5001. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  5002. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  5003. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  5004. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  5005. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  5006. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  5007. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  5008. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  5009. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  5010. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  5011. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  5012. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  5013. List_GC1.Add(gc);
  5014. }
  5015. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  5016. dt.TableName = "TB";
  5017. //报表标题等不用dt的值
  5018. designer.SetDataSource("TeamName", dto.title.TeamName);
  5019. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  5020. designer.SetDataSource("Tax", dto.title.Tax);
  5021. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  5022. designer.SetDataSource("Currency", dto.title.Currency);
  5023. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  5024. designer.SetDataSource("Rate", dto.title.Rate);
  5025. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  5026. var Aparams = hotels.Find(x => x.Type == "Default");
  5027. if (Aparams == null)
  5028. {
  5029. return Ok(jw);
  5030. }
  5031. //酒店数量
  5032. var txtSGRNumber = Aparams.SGR.ToString();
  5033. var txtTBRNumber = Aparams.TBR.ToString();
  5034. var txtJSESNumber = Aparams.JSES.ToString();
  5035. var txtSUITENumbe = Aparams.SUITE.ToString();
  5036. if (dto.costType == "B")
  5037. {
  5038. Aparams = hotels.Find(x => x.Type == "A");
  5039. var Bparams = hotels.Find(x => x.Type == "B");
  5040. if (Aparams == null || Bparams == null)
  5041. {
  5042. return Ok(jw);
  5043. }
  5044. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  5045. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  5046. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  5047. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  5048. }
  5049. designer.SetDataSource("SGRNumber", txtSGRNumber);
  5050. designer.SetDataSource("TBRNumber", txtTBRNumber);
  5051. designer.SetDataSource("JSESNumber", txtJSESNumber);
  5052. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  5053. var ws = designer.Workbook.Worksheets[0];
  5054. int Row = List_GC.Count;
  5055. int startIndex = 11;
  5056. int HideRows = 0;
  5057. List<int> hideRowsList = new List<int>();
  5058. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  5059. #region A段left数据
  5060. var left = dto.leftInfo.Find(x => x.Type == "A");
  5061. if (left == null)
  5062. {
  5063. return Ok(jw);
  5064. }
  5065. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  5066. if (leftBindData != null)
  5067. {
  5068. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  5069. designer.SetDataSource("VisaRS", leftBindData.rs);
  5070. designer.SetDataSource("VisaXS", leftBindData.xs);
  5071. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5072. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5073. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5074. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5075. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5076. }
  5077. else {
  5078. hideRowsList.Add(Row + startIndex + HideRows);
  5079. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5080. }
  5081. HideRows += 2;
  5082. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  5083. if (leftBindData != null)
  5084. {
  5085. designer.SetDataSource("BXDRCB", leftBindData.cb);
  5086. designer.SetDataSource("BXRS", leftBindData.rs);
  5087. designer.SetDataSource("BXXS", leftBindData.xs);
  5088. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5089. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5090. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5091. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5092. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5093. }
  5094. else
  5095. {
  5096. hideRowsList.Add(Row + startIndex + HideRows);
  5097. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5098. }
  5099. HideRows += 2;
  5100. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  5101. if (leftBindData != null)
  5102. {
  5103. designer.SetDataSource("HSDRCB", leftBindData.cb);
  5104. designer.SetDataSource("HSRS", leftBindData.rs);
  5105. designer.SetDataSource("HSXS", leftBindData.xs);
  5106. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5107. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5108. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5109. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5110. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5111. }
  5112. else
  5113. {
  5114. hideRowsList.Add(Row + startIndex + HideRows);
  5115. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5116. }
  5117. HideRows += 2;
  5118. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  5119. if (leftBindData != null)
  5120. {
  5121. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  5122. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  5123. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  5124. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5125. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5126. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5127. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5128. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5129. }
  5130. else
  5131. {
  5132. hideRowsList.Add(Row + startIndex + HideRows);
  5133. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5134. }
  5135. HideRows += 2;
  5136. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  5137. if (leftBindData != null)
  5138. {
  5139. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  5140. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  5141. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  5142. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5143. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5144. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5145. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5146. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5147. }
  5148. else
  5149. {
  5150. hideRowsList.Add(Row + startIndex + HideRows);
  5151. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5152. }
  5153. HideRows += 2;
  5154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  5155. if (leftBindData != null)
  5156. {
  5157. ////TBR
  5158. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  5159. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  5160. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  5161. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5162. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5163. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5164. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5165. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5166. }
  5167. else
  5168. {
  5169. hideRowsList.Add(Row + startIndex + HideRows);
  5170. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5171. }
  5172. HideRows += 2;
  5173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  5174. if (leftBindData != null)
  5175. {
  5176. ////SGR
  5177. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  5178. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  5179. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  5180. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5181. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5182. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5183. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5184. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5185. }
  5186. else
  5187. {
  5188. hideRowsList.Add(Row + startIndex + HideRows);
  5189. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5190. }
  5191. HideRows += 2;
  5192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  5193. if (leftBindData != null)
  5194. {
  5195. ////JS/ES
  5196. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  5197. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  5198. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  5199. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5200. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5201. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5202. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5203. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5204. }
  5205. else
  5206. {
  5207. hideRowsList.Add(Row + startIndex + HideRows);
  5208. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5209. }
  5210. HideRows += 2;
  5211. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  5212. if (leftBindData != null)
  5213. {
  5214. ////SUITE
  5215. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  5216. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  5217. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  5218. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5219. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5220. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5221. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5222. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5223. }
  5224. else
  5225. {
  5226. hideRowsList.Add(Row + startIndex + HideRows);
  5227. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5228. }
  5229. HideRows += 2;
  5230. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  5231. if (leftBindData != null)
  5232. {
  5233. designer.SetDataSource("DJDRCB", leftBindData.cb);
  5234. designer.SetDataSource("DJRS", leftBindData.rs);
  5235. designer.SetDataSource("DJXS", leftBindData.xs);
  5236. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5237. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5238. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5239. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5240. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5241. }
  5242. else
  5243. {
  5244. hideRowsList.Add(Row + startIndex + HideRows);
  5245. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5246. }
  5247. HideRows += 2;
  5248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  5249. if (leftBindData != null)
  5250. {
  5251. designer.SetDataSource("HCPCB", leftBindData.cb);
  5252. designer.SetDataSource("HCPRS", leftBindData.rs);
  5253. designer.SetDataSource("HCPXS", leftBindData.xs);
  5254. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5255. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5256. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5257. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5258. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5259. }
  5260. else
  5261. {
  5262. hideRowsList.Add(Row + startIndex + HideRows);
  5263. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5264. }
  5265. HideRows += 2;
  5266. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  5267. if (leftBindData != null)
  5268. {
  5269. designer.SetDataSource("CPCB", leftBindData.cb);
  5270. designer.SetDataSource("CPRS", leftBindData.rs);
  5271. designer.SetDataSource("CPXS", leftBindData.xs);
  5272. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5273. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5274. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5275. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5276. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5277. }
  5278. else
  5279. {
  5280. hideRowsList.Add(Row + startIndex + HideRows);
  5281. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5282. }
  5283. HideRows += 2;
  5284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  5285. if (leftBindData != null)
  5286. {
  5287. designer.SetDataSource("GWDRCD", leftBindData.cb);
  5288. designer.SetDataSource("GWRS", leftBindData.rs);
  5289. designer.SetDataSource("GWXS", leftBindData.xs);
  5290. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5291. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5292. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5293. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5294. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5295. }
  5296. else
  5297. {
  5298. hideRowsList.Add(Row + startIndex + HideRows);
  5299. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5300. }
  5301. HideRows += 2;
  5302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  5303. if (leftBindData != null)
  5304. {
  5305. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  5306. designer.SetDataSource("LYJRS", leftBindData.rs);
  5307. designer.SetDataSource("LYJXS", leftBindData.xs);
  5308. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5309. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5310. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5311. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5312. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5313. }
  5314. else
  5315. {
  5316. hideRowsList.Add(Row + startIndex + HideRows);
  5317. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5318. }
  5319. #endregion
  5320. #region A段Right信息
  5321. var right = dto.rightInfo.Find(x => x.Type == "A");
  5322. if (right == null)
  5323. {
  5324. return Ok(jw);
  5325. }
  5326. HideRows += 4;
  5327. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  5328. if (rightBindData!= null)
  5329. {
  5330. //经济舱 + 双人间 TBR
  5331. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  5332. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  5333. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5334. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  5335. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5336. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5337. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5338. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5339. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5340. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5341. }
  5342. else
  5343. {
  5344. hideRowsList.Add(Row + startIndex + HideRows);
  5345. }
  5346. HideRows += 2;
  5347. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  5348. if (rightBindData != null)
  5349. {
  5350. //经济舱 + 单人间 SGR
  5351. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  5352. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  5353. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5354. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  5355. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5356. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5357. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5358. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5359. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5360. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5361. }
  5362. else
  5363. {
  5364. hideRowsList.Add(Row + startIndex + HideRows);
  5365. }
  5366. HideRows += 2;
  5367. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  5368. if (rightBindData != null)
  5369. {
  5370. //公务舱 + 单人间 SGR
  5371. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  5372. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  5373. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5374. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  5375. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5376. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5377. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5378. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5379. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5380. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5381. }
  5382. else
  5383. {
  5384. hideRowsList.Add(Row + startIndex + HideRows);
  5385. }
  5386. HideRows += 2;
  5387. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  5388. if (rightBindData != null)
  5389. {
  5390. //公务舱 + 小套房 JSES
  5391. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  5392. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  5393. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5394. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  5395. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5396. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5397. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5398. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5399. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5400. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5401. }
  5402. else
  5403. {
  5404. hideRowsList.Add(Row + startIndex + HideRows);
  5405. }
  5406. HideRows += 2;
  5407. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  5408. if (rightBindData != null)
  5409. {
  5410. //公务舱 + 小套房 JSES
  5411. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  5412. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  5413. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5414. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  5415. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5416. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5417. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5418. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5419. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5420. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5421. }
  5422. else
  5423. {
  5424. hideRowsList.Add(Row + startIndex + HideRows);
  5425. }
  5426. HideRows += 2;
  5427. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  5428. if (rightBindData != null)
  5429. {
  5430. //经济舱 + 大套房
  5431. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  5432. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  5433. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5434. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  5435. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5436. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5437. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5438. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5439. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5440. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5441. }
  5442. else
  5443. {
  5444. hideRowsList.Add(Row + startIndex + HideRows);
  5445. }
  5446. #endregion
  5447. #region B段标题清空
  5448. designer.SetDataSource("CostBDRCB", "");
  5449. designer.SetDataSource("CostBRS", "");
  5450. designer.SetDataSource("CostBXS", "");
  5451. designer.SetDataSource("CostBZCB", "");
  5452. designer.SetDataSource("CostBDRBJ", "");
  5453. designer.SetDataSource("CostBZBJ", "");
  5454. designer.SetDataSource("CostBDRLR", "");
  5455. designer.SetDataSource("CostBZLR", "");
  5456. designer.SetDataSource("CostBDRCBOM", "");
  5457. designer.SetDataSource("CostBRSOM", "");
  5458. designer.SetDataSource("CostBZCBOM", "");
  5459. designer.SetDataSource("CostBDRBJOM", "");
  5460. designer.SetDataSource("CostBZBJOM", "");
  5461. designer.SetDataSource("CostBDRLROM", "");
  5462. designer.SetDataSource("CostBZLROM", "");
  5463. #endregion
  5464. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  5465. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  5466. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  5467. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  5468. designer.SetDataSource("DJName", "地接(CNY)");
  5469. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  5470. designer.SetDataSource("CPName", "地接-船票(CNY)");
  5471. designer.SetDataSource("GWName", "公务(CNY)");
  5472. designer.SetDataSource("YQHName", "邀请函(CNY)");
  5473. designer.SetDataSource("LYJName", "零用金(CNY)");
  5474. designer.SetDataSource("HSName", "核酸检测(CNY)");
  5475. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  5476. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  5477. designer.SetDataSource("BXName", "保险(CNY)");
  5478. designer.SetDataSource("VisaName", "签证(CNY)");
  5479. #region B段基本数据
  5480. if (dto.costType == "B")
  5481. {
  5482. left = dto.leftInfo.Find(x => x.Type == "B");
  5483. if (left == null)
  5484. {
  5485. return Ok(jw);
  5486. }
  5487. #region B段left数据
  5488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  5489. if (leftBindData != null)
  5490. {
  5491. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  5492. designer.SetDataSource("BHSRS", leftBindData.rs);
  5493. designer.SetDataSource("BHSXS", leftBindData.xs);
  5494. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5495. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5496. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5497. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5498. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5499. }
  5500. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  5501. if (leftBindData != null)
  5502. {
  5503. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  5504. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  5505. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  5506. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5507. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5508. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5509. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5510. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5511. }
  5512. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  5513. if (leftBindData != null)
  5514. {
  5515. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  5516. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  5517. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  5518. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5519. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5520. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5521. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5522. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5523. }
  5524. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  5525. if (leftBindData != null)
  5526. {
  5527. designer.SetDataSource("BHCPCB", leftBindData.cb);
  5528. designer.SetDataSource("BHCPRS", leftBindData.rs);
  5529. designer.SetDataSource("BHCPXS", leftBindData.xs);
  5530. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5531. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5532. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5533. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5534. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5535. }
  5536. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  5537. if (leftBindData != null)
  5538. {
  5539. designer.SetDataSource("BCPCB", leftBindData.cb);
  5540. designer.SetDataSource("BCPRS", leftBindData.rs);
  5541. designer.SetDataSource("BCPXS", leftBindData.xs);
  5542. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5543. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5544. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5545. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5546. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5547. }
  5548. //TBR
  5549. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  5550. if (leftBindData != null)
  5551. {
  5552. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  5553. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  5554. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  5555. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5556. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5557. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5558. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5559. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5560. }
  5561. //SGR
  5562. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  5563. if (leftBindData != null)
  5564. {
  5565. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  5566. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  5567. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  5568. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5569. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5570. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5571. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5572. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5573. }
  5574. //JS/ES
  5575. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  5576. if (leftBindData != null)
  5577. {
  5578. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  5579. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  5580. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  5581. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5582. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5583. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5584. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5585. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5586. }
  5587. //SUITE
  5588. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  5589. if (leftBindData != null)
  5590. {
  5591. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  5592. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  5593. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  5594. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5595. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5596. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5597. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5598. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5599. }
  5600. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  5601. if (leftBindData != null)
  5602. {
  5603. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  5604. designer.SetDataSource("BDJRS", leftBindData.rs);
  5605. designer.SetDataSource("BDJXS", leftBindData.xs);
  5606. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5607. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5608. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5609. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5610. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5611. }
  5612. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  5613. if (leftBindData != null)
  5614. {
  5615. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  5616. designer.SetDataSource("BGWRS", leftBindData.rs);
  5617. designer.SetDataSource("BGWXS", leftBindData.xs);
  5618. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5619. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5620. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5621. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5622. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5623. }
  5624. #region 优化方案
  5625. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  5626. //excelBind.Add("零用金", new {
  5627. //cb="",
  5628. //rs="",
  5629. //xs ="",
  5630. //zcb = "",
  5631. //});
  5632. #endregion
  5633. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  5634. if (leftBindData != null)
  5635. {
  5636. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  5637. designer.SetDataSource("BLYJRS", leftBindData.rs);
  5638. designer.SetDataSource("BLYJXS", leftBindData.xs);
  5639. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5640. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5641. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5642. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5643. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5644. }
  5645. #endregion
  5646. #region B段Right信息
  5647. right = dto.rightInfo.Find(x => x.Type == "B");
  5648. if (right == null)
  5649. {
  5650. return Ok(jw);
  5651. }
  5652. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  5653. if (rightBindData!= null)
  5654. {
  5655. //经济舱 + 双人间 TBR
  5656. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  5657. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  5658. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5659. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  5660. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5661. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5662. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5663. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5664. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5665. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5666. }
  5667. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  5668. if (rightBindData != null)
  5669. {
  5670. //经济舱 + 单人间 SGR
  5671. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  5672. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  5673. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5674. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  5675. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5676. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5677. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5678. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5679. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5680. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5681. }
  5682. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  5683. if (rightBindData != null)
  5684. {
  5685. //公务舱 + 单人间 SGR
  5686. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  5687. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  5688. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5689. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  5690. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5691. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5692. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5693. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5694. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5695. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5696. }
  5697. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  5698. if (rightBindData != null)
  5699. {
  5700. //公务舱 + 小套房 JSES
  5701. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  5702. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  5703. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5704. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  5705. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5706. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5707. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5708. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5709. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5710. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5711. }
  5712. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  5713. if (rightBindData != null)
  5714. {
  5715. //公务舱 + 小套房 JSES
  5716. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  5717. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  5718. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5719. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  5720. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5721. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5722. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5723. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5724. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5725. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5726. }
  5727. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  5728. if (rightBindData != null)
  5729. {
  5730. //经济舱 + 大套房
  5731. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  5732. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  5733. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5734. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  5735. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5736. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5737. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5738. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5739. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5740. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5741. }
  5742. #endregion
  5743. #region 标题
  5744. designer.SetDataSource("CostBDRCB", "单人成本");
  5745. designer.SetDataSource("CostBRS", "人数");
  5746. designer.SetDataSource("CostBXS", "系数");
  5747. designer.SetDataSource("CostBZCB", "总成本");
  5748. designer.SetDataSource("CostBDRBJ", "单人报价");
  5749. designer.SetDataSource("CostBZBJ", "总报价");
  5750. designer.SetDataSource("CostBDRLR", "单人利润");
  5751. designer.SetDataSource("CostBZLR", "总利润");
  5752. designer.SetDataSource("CostBDRCBOM", "单人成本");
  5753. designer.SetDataSource("CostBRSOM", "人数");
  5754. designer.SetDataSource("CostBZCBOM", "总成本");
  5755. designer.SetDataSource("CostBDRBJOM", "单人报价");
  5756. designer.SetDataSource("CostBZBJOM", "总报价");
  5757. designer.SetDataSource("CostBDRLROM", "单人利润");
  5758. designer.SetDataSource("CostBZLROM", "总利润");
  5759. #endregion
  5760. }
  5761. #endregion
  5762. designer.SetDataSource("TzZCB2", TzZCB2);
  5763. designer.SetDataSource("TzZBJ2", TzZBJ2);
  5764. designer.SetDataSource("TzZLR2", TzZLR2);
  5765. string[] dataSourceKeys = new string[]
  5766. {
  5767. "VF",
  5768. "TGS",
  5769. "TGOF",
  5770. "TGM",
  5771. "TGA",
  5772. "TGTF",
  5773. "TGEF",
  5774. "CFM",
  5775. "CFOF",
  5776. "B",
  5777. "L",
  5778. "D",
  5779. "TBR",
  5780. "SGR",
  5781. "JSES",
  5782. "Suite",
  5783. "TV",
  5784. "1L",
  5785. "IF",
  5786. "EF",
  5787. "BRF",
  5788. "TE",
  5789. "TGT",
  5790. "DRVT",
  5791. "PC",
  5792. "TLF",
  5793. "ECT"
  5794. };
  5795. foreach (var item in dataSourceKeys)
  5796. {
  5797. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  5798. if (find != null)
  5799. {
  5800. designer.SetDataSource(item, find.text);
  5801. }
  5802. else
  5803. {
  5804. designer.SetDataSource(item, 0);
  5805. }
  5806. }
  5807. designer.SetDataSource(dt);
  5808. //根据数据源处理生成报表内容
  5809. designer.Process();
  5810. designer.Workbook.Worksheets[0].Name = "清单";
  5811. Worksheet sheet = designer.Workbook.Worksheets[0];
  5812. foreach (var Rowindex in hideRowsList)
  5813. {
  5814. ws.Cells.HideRows(Rowindex, 2);
  5815. }
  5816. byte[] bytes = null;
  5817. string strFileName = di.TeamName + "-团组-成本.xls";
  5818. using (MemoryStream stream = new MemoryStream())
  5819. {
  5820. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5821. bytes = stream.ToArray();
  5822. }
  5823. return Ok(JsonView(true, "", new
  5824. {
  5825. Data = bytes,
  5826. strFileName,
  5827. }));
  5828. }
  5829. /// <summary>
  5830. /// 导出客户报表
  5831. /// </summary>
  5832. /// <returns></returns>
  5833. [HttpPost]
  5834. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  5835. {
  5836. var jw = JsonView(false);
  5837. if (dto.Diid == 0)
  5838. {
  5839. return Ok(JsonView(false, "请传递团组id"));
  5840. }
  5841. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  5842. if (deleInfo.Code != 0)
  5843. {
  5844. return Ok(JsonView(false, "团组信息查询失败!"));
  5845. }
  5846. var di = deleInfo.Data as DelegationInfoWebView;
  5847. if (di == null)
  5848. {
  5849. return Ok(JsonView(false, "团组信息查询失败!"));
  5850. }
  5851. //文件名
  5852. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  5853. //获取模板
  5854. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  5855. //载入模板
  5856. Document doc = new Document(tmppath);
  5857. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  5858. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  5859. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  5860. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  5861. var AParameter = ParameterList.Find(x => x.CostType == "A");
  5862. var BParameter = ParameterList.Find(x => x.CostType == "B");
  5863. if (AParameter == null)
  5864. {
  5865. return Ok(JsonView(false, "系数不存在!"));
  5866. }
  5867. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  5868. , TzAirDesc, TzZCost;
  5869. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  5870. = TzAirDesc = TzZCost = string.Empty;
  5871. TzNumber = AParameter.CostTypenumber.ToString();
  5872. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  5873. CarGuides1 = dto.CarGuides1;
  5874. Meal = dto.Meal;
  5875. SubsidizedMeals = dto.SubsidizedMeals;
  5876. NightRepair = dto.NightRepair;
  5877. AttractionsTickets = dto.AttractionsTickets;
  5878. MiscellaneousFees = dto.MiscellaneousFees;
  5879. ATip = dto.ATip;
  5880. TzHotelDesc = "";
  5881. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  5882. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  5883. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  5884. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  5885. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  5886. TzAirDesc = "";
  5887. TzZCost = dto.TzZCost;
  5888. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  5889. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  5890. var index = 1;
  5891. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  5892. foreach (var item in TzHotelDescArr)
  5893. {
  5894. if (AinfoArr != null)
  5895. {
  5896. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5897. if (Ainfo != null)
  5898. {
  5899. if (int.Parse(Ainfo.rs) <= 0)
  5900. {
  5901. continue;
  5902. }
  5903. var hotelText = string.Empty;
  5904. switch (item)
  5905. {
  5906. case "SGR":
  5907. hotelText = "单人间";
  5908. break;
  5909. case "JSES":
  5910. hotelText = "小套房";
  5911. break;
  5912. case "SUITE":
  5913. hotelText = "套房";
  5914. break;
  5915. case "TBR":
  5916. hotelText = "双人间";
  5917. break;
  5918. }
  5919. if (item != "TBR")
  5920. {
  5921. 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";
  5922. }
  5923. else
  5924. {
  5925. 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";
  5926. }
  5927. index++;
  5928. }
  5929. }
  5930. }
  5931. index = 1;
  5932. foreach (var item in TzAirDescArr)
  5933. {
  5934. if (AinfoArr != null)
  5935. {
  5936. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5937. if (Ainfo != null)
  5938. {
  5939. if (int.Parse(Ainfo.rs) <= 0)
  5940. {
  5941. continue;
  5942. }
  5943. 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";
  5944. index++;
  5945. }
  5946. }
  5947. }
  5948. if (dto.costType == "B")
  5949. {
  5950. if (BParameter == null)
  5951. {
  5952. return Ok(JsonView(false, "B段系数不存在!"));
  5953. }
  5954. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  5955. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  5956. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  5957. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  5958. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  5959. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  5960. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  5961. foreach (var item in TzHotelDescArr)
  5962. {
  5963. if (AinfoArr != null)
  5964. {
  5965. TzHotelDesc += "B段信息 \r\n";
  5966. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5967. if (Ainfo != null)
  5968. {
  5969. if (int.Parse(Ainfo.rs) <= 0)
  5970. {
  5971. continue;
  5972. }
  5973. var hotelText = string.Empty;
  5974. switch (item)
  5975. {
  5976. case "SGR":
  5977. hotelText = "单人间";
  5978. break;
  5979. case "JSES":
  5980. hotelText = "小套房";
  5981. break;
  5982. case "SUITE":
  5983. hotelText = "套房";
  5984. break;
  5985. case "TBR":
  5986. hotelText = "双人间";
  5987. break;
  5988. }
  5989. if (item != "TBR")
  5990. {
  5991. 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";
  5992. }
  5993. else
  5994. {
  5995. 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";
  5996. }
  5997. index++;
  5998. }
  5999. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  6000. }
  6001. }
  6002. index = 1;
  6003. foreach (var item in TzAirDescArr)
  6004. {
  6005. if (AinfoArr != null)
  6006. {
  6007. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  6008. if (Ainfo != null)
  6009. {
  6010. if (int.Parse(Ainfo.rs) <= 0)
  6011. {
  6012. continue;
  6013. }
  6014. 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";
  6015. index++;
  6016. }
  6017. }
  6018. }
  6019. }
  6020. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  6021. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  6022. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  6023. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  6024. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  6025. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  6026. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  6027. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  6028. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  6029. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  6030. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  6031. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  6032. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  6033. DickeyValue.Add("Visa", Visa); // 签证单人报价
  6034. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  6035. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  6036. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  6037. DickeyValue.Add("TzZCost", TzZCost);
  6038. foreach (var key in DickeyValue.Keys)
  6039. {
  6040. if (doc.Range.Bookmarks[key] != null)
  6041. {
  6042. Bookmark mark = doc.Range.Bookmarks[key];
  6043. mark.Text = DickeyValue[key];
  6044. }
  6045. }
  6046. byte[] bytes = null;
  6047. string strFileName = di.TeamName + "-客户报价.doc";
  6048. using (MemoryStream stream = new MemoryStream())
  6049. {
  6050. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6051. bytes = stream.ToArray();
  6052. }
  6053. return Ok(JsonView(true, "", new
  6054. {
  6055. Data = bytes,
  6056. strFileName,
  6057. }));
  6058. }
  6059. /// <summary>
  6060. /// 团组成本 各模块(酒店,地接,机票)成本提示
  6061. /// </summary>
  6062. /// <param name="dto"></param>
  6063. /// <returns></returns>
  6064. [HttpPost]
  6065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6066. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  6067. {
  6068. try
  6069. {
  6070. #region 参数验证
  6071. if (dto.DiId < 0)
  6072. {
  6073. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6074. }
  6075. List<int> cTableIds = new List<int>() {
  6076. 76 ,//酒店预订
  6077. 77 ,//行程
  6078. 79 ,//车/导游地接
  6079. 80 ,//签证
  6080. 81 ,//邀请/公务活
  6081. 82 ,//团组客户保险
  6082. 85 ,//机票预订
  6083. 98 ,//其他款项
  6084. 285 ,//收款退还
  6085. 751 ,//酒店早餐
  6086. 1015 // 超支费用
  6087. };
  6088. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  6089. {
  6090. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  6091. }
  6092. #endregion
  6093. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  6094. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6095. if (_GroupCostParameters.Count <= 0)
  6096. {
  6097. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  6098. }
  6099. if (_GroupCostParameters[0].IsShare == 0)
  6100. {
  6101. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  6102. }
  6103. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  6104. //处理date为空问题
  6105. if (_GroupCosts.Count > 0)
  6106. {
  6107. for (int i = 0; i < _GroupCosts.Count; i++)
  6108. {
  6109. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  6110. {
  6111. if (i > 0)
  6112. {
  6113. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  6114. }
  6115. }
  6116. }
  6117. }
  6118. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  6119. ;
  6120. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  6121. //op,酒店单段模式存储
  6122. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  6123. {
  6124. CurrencyCode = _GroupCostParameters[0].Currency,
  6125. Rate = _GroupCostParameters[0].Rate,
  6126. CostType = _GroupCostParameters[0].CostType,
  6127. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  6128. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  6129. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  6130. };
  6131. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  6132. if (_GroupCostParameters.Count == 2)
  6133. {
  6134. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  6135. }
  6136. foreach (var item in _GroupCostParameters)
  6137. {
  6138. decimal _rate = item.Rate;
  6139. decimal _scale = 0.95M;
  6140. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  6141. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  6142. if (userInfo != null)
  6143. {
  6144. if (userInfo.DepId == 1 || userInfo.DepId == 7)
  6145. {
  6146. if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  6147. {
  6148. _scale = 1.00M;
  6149. }
  6150. }
  6151. }
  6152. #endregion
  6153. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  6154. {
  6155. CurrencyCode = item.Currency,
  6156. Rate = _rate,
  6157. CostType = item.CostType,
  6158. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  6159. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  6160. CostTypeNumber = item.CostTypenumber
  6161. };
  6162. if (_GroupCostParameters.Count > 1)
  6163. {
  6164. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  6165. }
  6166. else
  6167. {
  6168. modulePromptInfo.CostTypeNumber = item.LYJRS;
  6169. }
  6170. if (dto.CTable == 79)//
  6171. {
  6172. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  6173. modulePromptInfo.TotalCost = item.DJCB;
  6174. }
  6175. List<string> costTypes = new List<string>() { "A","B" };
  6176. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  6177. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  6178. if (_GroupCostsDuplicates.Count() == 1)
  6179. {
  6180. _GroupCostsTypeData = _GroupCosts;
  6181. }
  6182. else
  6183. {
  6184. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  6185. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  6186. }
  6187. /*
  6188. * 76 酒店预订
  6189. * 77 行程
  6190. * 79 车/导游地接
  6191. * 80 签证
  6192. * 81 邀请/公务活动
  6193. * 82 团组客户保险
  6194. * 85 机票预订
  6195. * 98 其他款项
  6196. * 285 收款退还
  6197. * 751 酒店早餐
  6198. * 1015 超支费用
  6199. */
  6200. switch (dto.CTable)
  6201. {
  6202. case 76: // 酒店预订
  6203. _ModuleSubPromptInfo.AddRange(
  6204. _GroupCostsTypeData.Select(it => new
  6205. {
  6206. it.DAY,
  6207. it.Date,
  6208. it.ACCON,
  6209. it.ITIN,
  6210. it.SGR,
  6211. it.TBR,
  6212. it.JS_ES,
  6213. it.Suite
  6214. })
  6215. );
  6216. break;
  6217. case 79: // 车/导游地接
  6218. _ModuleSubPromptInfo.AddRange(
  6219. _GroupCostsTypeData.Select(it => new
  6220. {
  6221. Date = it.Date, //日期
  6222. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  6223. GuideFee = (it.TGS + it.TGOF + it.TGM+ it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  6224. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  6225. TicketFee = it.EF * _rate * _scale, //门票费
  6226. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  6227. AirportTransferFee = 0.00M,
  6228. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  6229. TravelSupplies = it.TE * _rate * _scale, //出行物资
  6230. LeadersFee = it.TLF * _rate * _scale, //领队费
  6231. CarFee1 = it.CarCost * _rate * _scale,
  6232. CarType = it.CarType, //车型
  6233. SpentCash = it.PC * _rate * _scale, //零用金
  6234. })
  6235. );
  6236. break;
  6237. case 85: // 机票
  6238. List<dynamic> datas = new List<dynamic>();
  6239. datas.Add(
  6240. new
  6241. {
  6242. AirType = "经济舱",
  6243. AirNum = item.JJCRS,
  6244. AirDRCB = item.JJCCB,
  6245. AirZCB = (item.JJCRS * item.JJCCB)
  6246. }
  6247. );
  6248. datas.Add(
  6249. new
  6250. {
  6251. AirType = "公务舱",
  6252. AirNum = item.GWCRS,
  6253. AirDRCB = item.GWCCB,
  6254. AirZCB = (item.GWCRS * item.GWCCB)
  6255. }
  6256. );
  6257. modulePromptInfo.Data = datas;
  6258. _ModulePromptInfos.Add(modulePromptInfo);
  6259. break;
  6260. default:
  6261. break;
  6262. }
  6263. }
  6264. if (dto.CTable != 85)
  6265. {
  6266. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  6267. _ModulePromptInfos.Add(_ModulePromptInfo);
  6268. }
  6269. _view.ModulePromptInfos = _ModulePromptInfos;
  6270. return Ok(JsonView(true,"操作成功!", _view));
  6271. }
  6272. catch (Exception ex)
  6273. {
  6274. return Ok(JsonView(false, ex.Message));
  6275. }
  6276. }
  6277. #endregion
  6278. #region 酒店预定 保留
  6279. /// <summary>
  6280. /// 酒店预订页面初始化绑定
  6281. /// </summary>
  6282. /// <param name="dto"></param>
  6283. /// <returns></returns>
  6284. [HttpPost]
  6285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6286. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  6287. {
  6288. try
  6289. {
  6290. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  6291. if (groupData.Code != 0)
  6292. {
  6293. return Ok(JsonView(false, groupData.Msg));
  6294. }
  6295. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6296. }
  6297. catch (Exception ex)
  6298. {
  6299. return Ok(JsonView(false, ex.Message));
  6300. }
  6301. }
  6302. /// <summary>
  6303. /// 根据团组Id查询酒店费用列表
  6304. /// </summary>
  6305. /// <param name="dto"></param>
  6306. /// <returns></returns>
  6307. [HttpPost]
  6308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6309. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  6310. {
  6311. try
  6312. {
  6313. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  6314. if (groupData.Code != 0)
  6315. {
  6316. return Ok(JsonView(false, groupData.Msg));
  6317. }
  6318. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6319. }
  6320. catch (Exception ex)
  6321. {
  6322. return Ok(JsonView(false, ex.Message));
  6323. }
  6324. }
  6325. /// <summary>
  6326. /// 根据酒店费用Id查询酒店费用详细
  6327. /// </summary>
  6328. /// <param name="dto"></param>
  6329. /// <returns></returns>
  6330. [HttpPost]
  6331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6332. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  6333. {
  6334. try
  6335. {
  6336. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  6337. if (groupData.Code != 0)
  6338. {
  6339. return Ok(JsonView(false, groupData.Msg));
  6340. }
  6341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6342. }
  6343. catch (Exception ex)
  6344. {
  6345. return Ok(JsonView(false, ex.Message));
  6346. }
  6347. }
  6348. /// <summary>
  6349. /// 计算酒店付款总金额
  6350. /// </summary>
  6351. /// <param name="dto"></param>
  6352. /// <returns></returns>
  6353. [HttpPost]
  6354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6355. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  6356. {
  6357. try
  6358. {
  6359. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  6360. if (groupData.Code != 0)
  6361. {
  6362. return Ok(JsonView(false, groupData.Msg));
  6363. }
  6364. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6365. }
  6366. catch (Exception ex)
  6367. {
  6368. return Ok(JsonView(false, ex.Message));
  6369. }
  6370. }
  6371. /// <summary>
  6372. /// 酒店费用操作(Status:1.新增,2.修改)
  6373. /// </summary>
  6374. /// <param name="dto"></param>
  6375. /// <returns></returns>
  6376. [HttpPost]
  6377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6378. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  6379. {
  6380. try
  6381. {
  6382. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  6383. if (groupData.Code != 0)
  6384. {
  6385. return Ok(JsonView(false, groupData.Msg));
  6386. }
  6387. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6388. }
  6389. catch (Exception ex)
  6390. {
  6391. return Ok(JsonView(false, ex.Message));
  6392. }
  6393. }
  6394. /// <summary>
  6395. /// 文件上传
  6396. /// </summary>
  6397. /// <param name="file"></param>
  6398. /// <returns></returns>
  6399. [HttpPost]
  6400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6401. public async Task<IActionResult> UploadHotel(IFormFile file)
  6402. {
  6403. try
  6404. {
  6405. if (file != null)
  6406. {
  6407. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6408. //文件名称
  6409. string projectFileName = file.FileName;
  6410. //上传的文件的路径
  6411. string filePath = "";
  6412. if (!Directory.Exists(fileDir))
  6413. {
  6414. Directory.CreateDirectory(fileDir);
  6415. }
  6416. //上传的文件的路径
  6417. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  6418. using (FileStream fs = System.IO.File.Create(filePath))
  6419. {
  6420. file.CopyTo(fs);
  6421. fs.Flush();
  6422. }
  6423. return Ok(JsonView(true, "上传成功!", projectFileName));
  6424. }
  6425. else
  6426. {
  6427. return Ok(JsonView(false, "上传失败!"));
  6428. }
  6429. }
  6430. catch (Exception ex)
  6431. {
  6432. return Ok(JsonView(false, "程序错误!"));
  6433. throw;
  6434. }
  6435. }
  6436. /// <summary>
  6437. /// 删除指定文件
  6438. /// </summary>
  6439. /// <param name="dto"></param>
  6440. /// <returns></returns>
  6441. [HttpPost]
  6442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6443. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  6444. {
  6445. try
  6446. {
  6447. string filePath = "";
  6448. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6449. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  6450. //int id = 0;
  6451. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  6452. // 删除该文件
  6453. try
  6454. {
  6455. System.IO.File.Delete(filePath);
  6456. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  6457. {
  6458. Attachment = "",
  6459. }).ExecuteCommandAsync();
  6460. if (result != 0)
  6461. {
  6462. return Ok(JsonView(true, "成功!"));
  6463. }
  6464. else
  6465. {
  6466. return Ok(JsonView(false, "失败!"));
  6467. }
  6468. }
  6469. catch (Exception)
  6470. {
  6471. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  6472. {
  6473. Attachment = "",
  6474. }).ExecuteCommandAsync();
  6475. if (result != 0)
  6476. {
  6477. return Ok(JsonView(true, "成功!"));
  6478. }
  6479. else
  6480. {
  6481. return Ok(JsonView(false, "失败!"));
  6482. }
  6483. throw;
  6484. }
  6485. }
  6486. catch (Exception ex)
  6487. {
  6488. return Ok(JsonView(false, "程序错误!"));
  6489. throw;
  6490. }
  6491. }
  6492. /// <summary>
  6493. /// 生成VOUCHER
  6494. /// </summary>
  6495. /// <param name=""></param>
  6496. /// <returns></returns>
  6497. [HttpPost]
  6498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6499. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  6500. {
  6501. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  6502. //判断数据是否完整
  6503. if (h != null)
  6504. {
  6505. if (!string.IsNullOrEmpty(h.DetermineNo))
  6506. {
  6507. string strFileName = "HotelStatement/";
  6508. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  6509. if (dele != null)
  6510. strFileName += dele.TourCode;
  6511. //载入模板
  6512. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  6513. Document doc = new Document(sss);
  6514. DocumentBuilder builder = new DocumentBuilder(doc);
  6515. try
  6516. {
  6517. #region 替换Word模板书签内容
  6518. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  6519. //入住卷预定号码
  6520. if (doc.Range.Bookmarks["VNO"] != null)
  6521. {
  6522. Bookmark mark = doc.Range.Bookmarks["VNO"];
  6523. mark.Text = h.CheckNumber;
  6524. }
  6525. //酒店时间
  6526. if (doc.Range.Bookmarks["Date"] != null)
  6527. {
  6528. Bookmark mark = doc.Range.Bookmarks["Date"];
  6529. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  6530. }
  6531. //团号
  6532. if (doc.Range.Bookmarks["TNo"] != null)
  6533. {
  6534. Bookmark mark = doc.Range.Bookmarks["TNo"];
  6535. mark.Text = dele.TourCode;
  6536. }
  6537. //预定号码
  6538. if (doc.Range.Bookmarks["BookingId"] != null)
  6539. {
  6540. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  6541. mark.Text = h.ReservationsNo;
  6542. }
  6543. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  6544. {
  6545. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  6546. mark.Text = h.DetermineNo;
  6547. }
  6548. //酒店城市
  6549. if (doc.Range.Bookmarks["City"] != null)
  6550. {
  6551. Bookmark mark = doc.Range.Bookmarks["City"];
  6552. mark.Text = h.City;
  6553. }
  6554. //酒店名称
  6555. if (doc.Range.Bookmarks["HName"] != null)
  6556. {
  6557. Bookmark mark = doc.Range.Bookmarks["HName"];
  6558. mark.Text = h.HotelName;
  6559. }
  6560. //酒店地址
  6561. if (doc.Range.Bookmarks["Address"] != null)
  6562. {
  6563. Bookmark mark = doc.Range.Bookmarks["Address"];
  6564. mark.Text = h.HotelAddress;
  6565. }
  6566. //酒店电话
  6567. if (doc.Range.Bookmarks["Tel"] != null)
  6568. {
  6569. Bookmark mark = doc.Range.Bookmarks["Tel"];
  6570. mark.Text = h.HotelTel;
  6571. }
  6572. //酒店传真
  6573. if (doc.Range.Bookmarks["Fax"] != null)
  6574. {
  6575. Bookmark mark = doc.Range.Bookmarks["Fax"];
  6576. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  6577. {
  6578. mark.Text = h.HotelFax;
  6579. }
  6580. }
  6581. //入住时间
  6582. if (doc.Range.Bookmarks["CIn"] != null)
  6583. {
  6584. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  6585. Bookmark mark = doc.Range.Bookmarks["CIn"];
  6586. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  6587. }
  6588. //退房时间
  6589. if (doc.Range.Bookmarks["COut"] != null)
  6590. {
  6591. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  6592. Bookmark mark = doc.Range.Bookmarks["COut"];
  6593. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  6594. }
  6595. //客户名称
  6596. if (doc.Range.Bookmarks["GName"] != null)
  6597. {
  6598. Bookmark mark = doc.Range.Bookmarks["GName"];
  6599. mark.Text = h.GuestName;
  6600. }
  6601. //房间介绍
  6602. if (doc.Range.Bookmarks["ROOM"] != null)
  6603. {
  6604. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  6605. mark.Text = h.RoomExplanation;
  6606. }
  6607. //报价描述
  6608. if (doc.Range.Bookmarks["NOTE"] != null)
  6609. {
  6610. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  6611. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  6612. if (ss != null)
  6613. mark.Text = ss.Name;
  6614. }
  6615. //入住时间
  6616. if (doc.Range.Bookmarks["CheckIn"] != null)
  6617. {
  6618. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  6619. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  6620. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  6621. }
  6622. //退房时间
  6623. if (doc.Range.Bookmarks["CheckOut"] != null)
  6624. {
  6625. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  6626. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  6627. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  6628. }
  6629. //日期
  6630. if (doc.Range.Bookmarks["DT"] != null)
  6631. {
  6632. Bookmark mark = doc.Range.Bookmarks["DT"];
  6633. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  6634. }
  6635. //名称
  6636. if (doc.Range.Bookmarks["VName"] != null)
  6637. {
  6638. Bookmark mark = doc.Range.Bookmarks["VName"];
  6639. mark.Text = h.HotelName;
  6640. }
  6641. //号码
  6642. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  6643. {
  6644. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  6645. mark.Text = h.CheckNumber;
  6646. }
  6647. #endregion
  6648. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  6649. strFileName += "VOUCHER.doc";
  6650. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  6651. doc.Save(fileDir);
  6652. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  6653. return Ok(JsonView(true, "成功!", Url));
  6654. }
  6655. catch (Exception ex)
  6656. {
  6657. throw;
  6658. }
  6659. }
  6660. else
  6661. {
  6662. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  6663. }
  6664. }
  6665. else
  6666. {
  6667. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  6668. }
  6669. }
  6670. /// <summary>
  6671. /// 导出确认单
  6672. /// </summary>
  6673. /// <param name=""></param>
  6674. /// <returns></returns>
  6675. [HttpPost]
  6676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6677. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  6678. {
  6679. //团组信息
  6680. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  6681. //酒店数据
  6682. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  6683. //利datatable存储
  6684. DataTable dt = new DataTable();
  6685. dt.Columns.Add("CheckInDate", typeof(string));
  6686. dt.Columns.Add("City", typeof(string));
  6687. dt.Columns.Add("Hotel", typeof(string));
  6688. dt.Columns.Add("Room", typeof(string));
  6689. for (int i = 0; i < listhoteldata.Count; i++)
  6690. {
  6691. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  6692. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  6693. while (dayStart < dayEnd)
  6694. {
  6695. string temp = "";
  6696. DataRow row = dt.NewRow();
  6697. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  6698. row["City"] = listhoteldata[i].City;
  6699. row["Hotel"] = listhoteldata[i].HotelName;
  6700. if (listhoteldata[i].SingleRoomCount > 0)
  6701. {
  6702. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  6703. }
  6704. if (listhoteldata[i].DoubleRoomCount > 0)
  6705. {
  6706. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  6707. }
  6708. if (listhoteldata[i].SuiteRoomCount > 0)
  6709. {
  6710. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  6711. }
  6712. if (listhoteldata[i].OtherRoomCount > 0)
  6713. {
  6714. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  6715. }
  6716. row["Room"] = temp;
  6717. dt.Rows.Add(row);
  6718. dayStart = dayStart.AddDays(1);
  6719. }
  6720. }
  6721. Dictionary<string, string> dic = new Dictionary<string, string>();
  6722. dic.Add("Dele", di.TeamName);
  6723. dic.Add("City", di.VisitCountry);
  6724. //模板路径
  6725. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  6726. //载入模板
  6727. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  6728. DocumentBuilder builder = new DocumentBuilder(doc);
  6729. foreach (var key in dic.Keys)
  6730. {
  6731. builder.MoveToBookmark(key);
  6732. builder.Write(dic[key]);
  6733. }
  6734. //获取word里所有表格
  6735. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6736. //获取所填表格的序数
  6737. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6738. var rowStart = tableOne.Rows[0]; //获取第1行
  6739. try
  6740. {
  6741. //循环赋值
  6742. for (int i = 0; i < dt.Rows.Count; i++)
  6743. {
  6744. builder.MoveToCell(0, i + 1, 0, 0);
  6745. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  6746. builder.MoveToCell(0, i + 1, 1, 0);
  6747. builder.Write(dt.Rows[i]["City"].ToString());
  6748. builder.MoveToCell(0, i + 1, 2, 0);
  6749. builder.Write(dt.Rows[i]["Hotel"].ToString());
  6750. builder.MoveToCell(0, i + 1, 3, 0);
  6751. builder.Write(dt.Rows[i]["Room"].ToString());
  6752. }
  6753. }
  6754. catch
  6755. {
  6756. }
  6757. //删除多余行
  6758. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  6759. {
  6760. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  6761. }
  6762. string strFileName = di.TeamName + "酒店确认单.doc";
  6763. try
  6764. {
  6765. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  6766. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  6767. return Ok(JsonView(true, "成功", Url));
  6768. }
  6769. catch (Exception)
  6770. {
  6771. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  6772. throw;
  6773. }
  6774. }
  6775. /// <summary>
  6776. /// 酒店费用删除
  6777. /// </summary>
  6778. /// <param name="dto"></param>
  6779. /// <returns></returns>
  6780. [HttpPost]
  6781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6782. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  6783. {
  6784. try
  6785. {
  6786. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6787. if (!res)
  6788. {
  6789. return Ok(JsonView(false, "删除失败"));
  6790. }
  6791. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  6792. {
  6793. IsDel = 1,
  6794. DeleteUserId = dto.DeleteUserId,
  6795. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6796. }).ExecuteCommandAsync();
  6797. return Ok(JsonView(true, "删除成功!"));
  6798. }
  6799. catch (Exception ex)
  6800. {
  6801. return Ok(JsonView(false, "程序错误!"));
  6802. throw;
  6803. }
  6804. }
  6805. #endregion
  6806. #region 酒店预订 新 雷怡 2023-12-28 17:45
  6807. /// <summary>
  6808. /// 酒店预订
  6809. /// 酒店费用列表 根据团组Id查询
  6810. /// </summary>
  6811. /// <param name="_dto"></param>
  6812. /// <returns></returns>
  6813. [HttpPost]
  6814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6815. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  6816. {
  6817. try
  6818. {
  6819. #region 参数验证
  6820. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6821. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6822. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6823. #region 团组操作权限验证 76 酒店预定模块
  6824. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6825. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6826. #endregion
  6827. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6828. #region 页面操作权限验证
  6829. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6830. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6831. #endregion
  6832. #endregion
  6833. Result _view = await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId);
  6834. if (_view.Code != 0)
  6835. {
  6836. return Ok(JsonView(false, _view.Msg));
  6837. }
  6838. return Ok(JsonView(true, _view.Msg, _view.Data));
  6839. }
  6840. catch (Exception ex)
  6841. {
  6842. return Ok(JsonView(false, ex.Message));
  6843. }
  6844. }
  6845. /// <summary>
  6846. /// 酒店预订
  6847. /// 基础数据
  6848. /// </summary>
  6849. /// <param name="_dto"></param>
  6850. /// <returns></returns>
  6851. [HttpPost]
  6852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6853. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  6854. {
  6855. try
  6856. {
  6857. #region 参数验证
  6858. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6859. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6860. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6861. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6862. #region 页面操作权限验证
  6863. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6864. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6865. #endregion
  6866. #region 团组操作权限验证 76 酒店预定模块
  6867. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6868. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6869. #endregion
  6870. #endregion
  6871. Result data = await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId);
  6872. if (data.Code != 0)
  6873. {
  6874. return Ok(JsonView(false, data.Msg));
  6875. }
  6876. return Ok(JsonView(true, data.Msg, data.Data));
  6877. }
  6878. catch (Exception ex)
  6879. {
  6880. return Ok(JsonView(false, "Catch:"+ex.Message));
  6881. }
  6882. }
  6883. /// <summary>
  6884. /// 酒店预订
  6885. /// 创建 入住卷号码
  6886. /// </summary>
  6887. /// <param name="_dto"></param>
  6888. /// <returns></returns>
  6889. [HttpPost]
  6890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6891. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  6892. {
  6893. try
  6894. {
  6895. #region 参数验证
  6896. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6897. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6898. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6899. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6900. #region 页面操作权限验证
  6901. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6902. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6903. #endregion
  6904. #region 团组操作权限验证 76 酒店预定模块
  6905. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6906. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6907. #endregion
  6908. #endregion
  6909. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  6910. if (data.Code != 0)
  6911. {
  6912. return Ok(JsonView(false, data.Msg));
  6913. }
  6914. return Ok(JsonView(true, data.Msg, data.Data));
  6915. }
  6916. catch (Exception ex)
  6917. {
  6918. return Ok(JsonView(false, ex.Message));
  6919. }
  6920. }
  6921. /// <summary>
  6922. /// 酒店预订
  6923. /// 详情
  6924. /// </summary>
  6925. /// <param name="_dto"></param>
  6926. /// <returns></returns>
  6927. [HttpPost]
  6928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6929. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  6930. {
  6931. try
  6932. {
  6933. #region 参数验证
  6934. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6935. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6936. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6937. #region 团组操作权限验证 76 酒店预定模块
  6938. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6939. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6940. #endregion
  6941. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6942. #region 页面操作权限验证
  6943. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6944. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6945. #endregion
  6946. #endregion
  6947. Result data = await _hotelPriceRep._Details(_dto.PortType,_dto.Id);
  6948. if (data.Code != 0)
  6949. {
  6950. return Ok(JsonView(false, data.Msg));
  6951. }
  6952. return Ok(JsonView(true, data.Msg, data.Data));
  6953. }
  6954. catch (Exception ex)
  6955. {
  6956. return Ok(JsonView(false, ex.Message));
  6957. }
  6958. }
  6959. /// <summary>
  6960. /// 酒店预订
  6961. /// Add Or Edit
  6962. /// </summary>
  6963. /// <param name="_dto"></param>
  6964. /// <returns></returns>
  6965. [HttpPost]
  6966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6967. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  6968. {
  6969. try
  6970. {
  6971. #region 参数验证
  6972. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6973. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6974. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6975. #region 团组操作权限验证 76 酒店预定模块
  6976. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6977. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6978. #endregion
  6979. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6980. #region 页面操作权限验证
  6981. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6982. if (_dto.Id == 0) // Add
  6983. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  6984. else if (_dto.Id > 0) // Edit
  6985. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  6986. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  6987. #endregion
  6988. #endregion
  6989. Result data = await _hotelPriceRep._AddOrEdit(_dto);
  6990. if (data.Code != 0)
  6991. {
  6992. return Ok(JsonView(false, data.Msg));
  6993. }
  6994. return Ok(JsonView(true, data.Msg, data.Data));
  6995. }
  6996. catch (Exception ex)
  6997. {
  6998. return Ok(JsonView(false, ex.Message));
  6999. }
  7000. }
  7001. /// <summary>
  7002. /// 酒店预订
  7003. /// Del
  7004. /// </summary>
  7005. /// <param name="_dto"></param>
  7006. /// <returns></returns>
  7007. [HttpPost]
  7008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7009. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  7010. {
  7011. try
  7012. {
  7013. #region 参数验证
  7014. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7015. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7016. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7017. #region 团组操作权限验证 76 酒店预定模块
  7018. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7019. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7020. #endregion
  7021. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7022. #region 页面操作权限验证
  7023. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7024. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  7025. #endregion
  7026. #endregion
  7027. Result data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  7028. if (data.Code != 0)
  7029. {
  7030. return Ok(JsonView(false, data.Msg));
  7031. }
  7032. return Ok(JsonView(true, data.Msg, data.Data));
  7033. }
  7034. catch (Exception ex)
  7035. {
  7036. return Ok(JsonView(false, ex.Message));
  7037. }
  7038. }
  7039. /// <summary>
  7040. /// 酒店预订
  7041. /// 生成VOUCHER
  7042. /// </summary>
  7043. /// <param name="_dto"></param>
  7044. /// <returns></returns>
  7045. [HttpPost]
  7046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7047. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  7048. {
  7049. try
  7050. {
  7051. #region 参数验证
  7052. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7053. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7054. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7055. #region 团组操作权限验证 76 酒店预定模块
  7056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7057. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7058. #endregion
  7059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7060. #region 页面操作权限验证
  7061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7062. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7063. #endregion
  7064. #endregion
  7065. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  7066. //判断数据是否完整
  7067. if (hr != null)
  7068. {
  7069. if (!string.IsNullOrEmpty(hr.DetermineNo))
  7070. {
  7071. string strFileName = "HotelStatement/";
  7072. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  7073. if (dele != null)
  7074. strFileName += dele.TourCode;
  7075. //载入模板
  7076. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  7077. Document doc = new Document(sss);
  7078. DocumentBuilder builder = new DocumentBuilder(doc);
  7079. #region 替换Word模板书签内容
  7080. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  7081. //入住卷预定号码
  7082. if (doc.Range.Bookmarks["VNO"] != null)
  7083. {
  7084. Bookmark mark = doc.Range.Bookmarks["VNO"];
  7085. mark.Text = hr.CheckNumber;
  7086. }
  7087. //酒店时间
  7088. if (doc.Range.Bookmarks["Date"] != null)
  7089. {
  7090. Bookmark mark = doc.Range.Bookmarks["Date"];
  7091. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  7092. }
  7093. //团号
  7094. if (doc.Range.Bookmarks["TNo"] != null)
  7095. {
  7096. Bookmark mark = doc.Range.Bookmarks["TNo"];
  7097. mark.Text = dele.TourCode;
  7098. }
  7099. //预定号码
  7100. if (doc.Range.Bookmarks["BookingId"] != null)
  7101. {
  7102. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  7103. mark.Text = hr.ReservationsNo;
  7104. }
  7105. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  7106. {
  7107. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  7108. mark.Text = hr.DetermineNo;
  7109. }
  7110. //酒店城市
  7111. if (doc.Range.Bookmarks["City"] != null)
  7112. {
  7113. Bookmark mark = doc.Range.Bookmarks["City"];
  7114. mark.Text = hr.City;
  7115. }
  7116. //酒店名称
  7117. if (doc.Range.Bookmarks["HName"] != null)
  7118. {
  7119. Bookmark mark = doc.Range.Bookmarks["HName"];
  7120. mark.Text = hr.HotelName;
  7121. }
  7122. //酒店地址
  7123. if (doc.Range.Bookmarks["Address"] != null)
  7124. {
  7125. Bookmark mark = doc.Range.Bookmarks["Address"];
  7126. mark.Text = hr.HotelAddress;
  7127. }
  7128. //酒店电话
  7129. if (doc.Range.Bookmarks["Tel"] != null)
  7130. {
  7131. Bookmark mark = doc.Range.Bookmarks["Tel"];
  7132. mark.Text = hr.HotelTel;
  7133. }
  7134. //酒店传真
  7135. if (doc.Range.Bookmarks["Fax"] != null)
  7136. {
  7137. Bookmark mark = doc.Range.Bookmarks["Fax"];
  7138. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  7139. {
  7140. mark.Text = hr.HotelFax;
  7141. }
  7142. }
  7143. //入住时间
  7144. if (doc.Range.Bookmarks["CIn"] != null)
  7145. {
  7146. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  7147. Bookmark mark = doc.Range.Bookmarks["CIn"];
  7148. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  7149. }
  7150. //退房时间
  7151. if (doc.Range.Bookmarks["COut"] != null)
  7152. {
  7153. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  7154. Bookmark mark = doc.Range.Bookmarks["COut"];
  7155. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  7156. }
  7157. //客户名称
  7158. if (doc.Range.Bookmarks["GName"] != null)
  7159. {
  7160. string guestName = "";
  7161. string[] clients = new string[] { };
  7162. if (hr.GuestName.Contains(","))
  7163. {
  7164. clients = hr.GuestName.Split(",");
  7165. }
  7166. else
  7167. {
  7168. clients = new string[] { hr.GuestName };
  7169. }
  7170. List<int> clientIds_int = new List<int>();
  7171. if (clients.Length > 0)
  7172. {
  7173. foreach (var item in clients)
  7174. {
  7175. if (item.IsNumeric())
  7176. {
  7177. clientIds_int.Add(int.Parse(item));
  7178. }
  7179. }
  7180. }
  7181. if (clientIds_int.Count > 0)
  7182. {
  7183. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  7184. foreach (var client in _clientDatas)
  7185. {
  7186. //男
  7187. if (client.Sex == 0) guestName += $"Mr.";
  7188. //女
  7189. else if (client.Sex == 1) guestName += $"Ms.";
  7190. if (!String.IsNullOrEmpty(client.FirstName+ client.LastName))
  7191. {
  7192. guestName += $"{string.Join("",client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  7193. }
  7194. //guestName += $"{client.Pinyin},";
  7195. }
  7196. if (guestName.Length > 0)
  7197. {
  7198. guestName = guestName.Substring(0, guestName.Length - 1);
  7199. }
  7200. }
  7201. else
  7202. {
  7203. guestName = hr.GuestName;
  7204. }
  7205. Bookmark mark = doc.Range.Bookmarks["GName"];
  7206. mark.Text = guestName;
  7207. }
  7208. //房间介绍
  7209. if (doc.Range.Bookmarks["ROOM"] != null)
  7210. {
  7211. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  7212. mark.Text = hr.RoomExplanation;
  7213. }
  7214. //报价描述
  7215. if (doc.Range.Bookmarks["NOTE"] != null)
  7216. {
  7217. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  7218. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  7219. if (ss != null)
  7220. mark.Text = ss.Name;
  7221. }
  7222. //入住时间
  7223. if (doc.Range.Bookmarks["CheckIn"] != null)
  7224. {
  7225. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  7226. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  7227. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  7228. }
  7229. //退房时间
  7230. if (doc.Range.Bookmarks["CheckOut"] != null)
  7231. {
  7232. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  7233. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  7234. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  7235. }
  7236. //日期
  7237. if (doc.Range.Bookmarks["DT"] != null)
  7238. {
  7239. Bookmark mark = doc.Range.Bookmarks["DT"];
  7240. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  7241. }
  7242. //名称
  7243. if (doc.Range.Bookmarks["VName"] != null)
  7244. {
  7245. Bookmark mark = doc.Range.Bookmarks["VName"];
  7246. mark.Text = hr.HotelName;
  7247. }
  7248. //号码
  7249. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  7250. {
  7251. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  7252. mark.Text = hr.CheckNumber;
  7253. }
  7254. #endregion
  7255. strFileName += "VOUCHER.doc";
  7256. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  7257. doc.Save(fileDir);
  7258. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  7259. return Ok(JsonView(true, "操作成功!", Url));
  7260. }
  7261. else
  7262. {
  7263. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  7264. }
  7265. }
  7266. else
  7267. {
  7268. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  7269. }
  7270. }
  7271. catch (Exception ex)
  7272. {
  7273. return Ok(JsonView(false, ex.Message));
  7274. }
  7275. }
  7276. /// <summary>
  7277. /// 酒店预订
  7278. /// 确认单
  7279. /// </summary>
  7280. /// <param name="_dto"></param>
  7281. /// <returns></returns>
  7282. [HttpPost]
  7283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7284. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  7285. {
  7286. try
  7287. {
  7288. #region 参数验证
  7289. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7290. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7291. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7292. #region 团组操作权限验证 76 酒店预定模块
  7293. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7294. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7295. #endregion
  7296. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7297. #region 页面操作权限验证
  7298. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7299. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7300. #endregion
  7301. #endregion
  7302. //团组信息
  7303. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  7304. //酒店数据
  7305. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  7306. if (listhoteldata.Count < 0)
  7307. {
  7308. return Ok(JsonView(false, "当前团组暂无酒店预订信息!"));
  7309. }
  7310. //利datatable存储
  7311. DataTable dt = new DataTable();
  7312. dt.Columns.Add("CheckInDate", typeof(string));
  7313. dt.Columns.Add("City", typeof(string));
  7314. dt.Columns.Add("Hotel", typeof(string));
  7315. dt.Columns.Add("Room", typeof(string));
  7316. for (int i = 0; i < listhoteldata.Count; i++)
  7317. {
  7318. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  7319. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  7320. while (dayStart < dayEnd)
  7321. {
  7322. string temp = "";
  7323. DataRow row = dt.NewRow();
  7324. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  7325. row["City"] = listhoteldata[i].City;
  7326. row["Hotel"] = listhoteldata[i].HotelName;
  7327. if (listhoteldata[i].SingleRoomCount > 0)
  7328. {
  7329. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  7330. }
  7331. if (listhoteldata[i].DoubleRoomCount > 0)
  7332. {
  7333. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  7334. }
  7335. if (listhoteldata[i].SuiteRoomCount > 0)
  7336. {
  7337. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  7338. }
  7339. if (listhoteldata[i].OtherRoomCount > 0)
  7340. {
  7341. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  7342. }
  7343. row["Room"] = temp;
  7344. dt.Rows.Add(row);
  7345. dayStart = dayStart.AddDays(1);
  7346. }
  7347. }
  7348. Dictionary<string, string> dic = new Dictionary<string, string>();
  7349. dic.Add("Dele", di.TeamName);
  7350. dic.Add("City", di.VisitCountry);
  7351. //模板路径
  7352. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  7353. //载入模板
  7354. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  7355. DocumentBuilder builder = new DocumentBuilder(doc);
  7356. foreach (var key in dic.Keys)
  7357. {
  7358. builder.MoveToBookmark(key);
  7359. builder.Write(dic[key]);
  7360. }
  7361. //获取word里所有表格
  7362. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7363. //获取所填表格的序数
  7364. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7365. var rowStart = tableOne.Rows[0]; //获取第1行
  7366. //循环赋值
  7367. for (int i = 0; i < dt.Rows.Count; i++)
  7368. {
  7369. builder.MoveToCell(0, i + 1, 0, 0);
  7370. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  7371. builder.MoveToCell(0, i + 1, 1, 0);
  7372. builder.Write(dt.Rows[i]["City"].ToString());
  7373. builder.MoveToCell(0, i + 1, 2, 0);
  7374. builder.Write(dt.Rows[i]["Hotel"].ToString());
  7375. builder.MoveToCell(0, i + 1, 3, 0);
  7376. builder.Write(dt.Rows[i]["Room"].ToString());
  7377. }
  7378. //删除多余行
  7379. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  7380. {
  7381. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  7382. }
  7383. string strFileName = di.TeamName + "酒店确认单.doc";
  7384. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  7385. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  7386. return Ok(JsonView(true, "成功", url));
  7387. }
  7388. catch (Exception ex)
  7389. {
  7390. return Ok(JsonView(false, ex.Message));
  7391. }
  7392. }
  7393. #endregion
  7394. #region 团组状态
  7395. /// <summary>
  7396. /// 团组状态列表 Page
  7397. /// </summary>
  7398. /// <param name="dto">团组列表请求dto</param>
  7399. /// <returns></returns>
  7400. [HttpPost]
  7401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7402. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  7403. {
  7404. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  7405. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  7406. {
  7407. string sqlWhere = string.Empty;
  7408. if (dto.IsSure == 0) //未完成
  7409. {
  7410. sqlWhere += string.Format(@" And IsSure = 0");
  7411. }
  7412. else if (dto.IsSure == 1) //已完成
  7413. {
  7414. sqlWhere += string.Format(@" And IsSure = 1");
  7415. }
  7416. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  7417. {
  7418. string tj = dto.SearchCriteria;
  7419. 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}%')",
  7420. tj, tj, tj, tj, tj);
  7421. }
  7422. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  7423. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  7424. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  7425. From (
  7426. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  7427. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  7428. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  7429. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  7430. From Grp_DelegationInfo gdi
  7431. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  7432. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  7433. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  7434. Where gdi.IsDel = 0 {0}
  7435. ) temp ", sqlWhere);
  7436. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  7437. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  7438. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  7439. }
  7440. else
  7441. {
  7442. return Ok(JsonView(false, "查询失败"));
  7443. }
  7444. }
  7445. /// <summary>
  7446. /// 团组状态
  7447. /// 设置操作完成
  7448. /// </summary>
  7449. /// <param name="dto">团组列表请求dto</param>
  7450. /// <returns></returns>
  7451. [HttpPost]
  7452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7453. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  7454. {
  7455. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  7456. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  7457. {
  7458. Id = dto.Id,
  7459. IsSure = 1
  7460. };
  7461. var result = await _sqlSugar.Updateable(_DelegationInfo)
  7462. .UpdateColumns(it => new { it.IsSure })
  7463. .WhereColumns(it => new { it.Id })
  7464. .ExecuteCommandAsync();
  7465. if (result > 0)
  7466. {
  7467. return Ok(JsonView(true, "操作完成!"));
  7468. }
  7469. return Ok(JsonView(false, "操作失败!"));
  7470. }
  7471. #endregion
  7472. #region 保险费用录入
  7473. /// <summary>
  7474. /// 根据团组Id查询保险费用列表
  7475. /// </summary>
  7476. /// <param name="dto"></param>
  7477. /// <returns></returns>
  7478. [HttpPost]
  7479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7480. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  7481. {
  7482. try
  7483. {
  7484. Result groupData = await _customersRep.CustomersByDiId(dto);
  7485. if (groupData.Code != 0)
  7486. {
  7487. return Ok(JsonView(false, groupData.Msg));
  7488. }
  7489. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7490. }
  7491. catch (Exception ex)
  7492. {
  7493. return Ok(JsonView(false, ex.Message));
  7494. }
  7495. }
  7496. /// <summary>
  7497. /// 根据保险费用Id查询保险费用详细
  7498. /// </summary>
  7499. /// <param name="dto"></param>
  7500. /// <returns></returns>
  7501. [HttpPost]
  7502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7503. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  7504. {
  7505. try
  7506. {
  7507. Result groupData = await _customersRep.CustomersById(dto);
  7508. if (groupData.Code != 0)
  7509. {
  7510. return Ok(JsonView(false, groupData.Msg));
  7511. }
  7512. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7513. }
  7514. catch (Exception ex)
  7515. {
  7516. return Ok(JsonView(false, ex.Message));
  7517. }
  7518. }
  7519. /// <summary>
  7520. /// 保险费用录入页面初始化绑定
  7521. /// </summary>
  7522. /// <param name="dto"></param>
  7523. /// <returns></returns>
  7524. [HttpPost]
  7525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7526. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  7527. {
  7528. try
  7529. {
  7530. Result groupData = await _customersRep.CustomersInitialize(dto);
  7531. if (groupData.Code != 0)
  7532. {
  7533. return Ok(JsonView(false, groupData.Msg));
  7534. }
  7535. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7536. }
  7537. catch (Exception ex)
  7538. {
  7539. return Ok(JsonView(false, ex.Message));
  7540. }
  7541. }
  7542. /// <summary>
  7543. /// 保险费用操作(Status:1.新增,2.修改)
  7544. /// </summary>
  7545. /// <param name="dto"></param>
  7546. /// <returns></returns>
  7547. [HttpPost]
  7548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7549. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  7550. {
  7551. try
  7552. {
  7553. Result groupData = await _customersRep.OpCustomers(dto);
  7554. if (groupData.Code != 0)
  7555. {
  7556. return Ok(JsonView(false, groupData.Msg));
  7557. }
  7558. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7559. }
  7560. catch (Exception ex)
  7561. {
  7562. return Ok(JsonView(false, ex.Message));
  7563. }
  7564. }
  7565. /// <summary>
  7566. /// 保险文件上传
  7567. /// </summary>
  7568. /// <param name="file"></param>
  7569. /// <returns></returns>
  7570. [HttpPost]
  7571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7572. public async Task<IActionResult> UploadCus(IFormFile file)
  7573. {
  7574. try
  7575. {
  7576. if (file != null)
  7577. {
  7578. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7579. //文件名称
  7580. string projectFileName = file.FileName;
  7581. //上传的文件的路径
  7582. string filePath = "";
  7583. if (!Directory.Exists(fileDir))
  7584. {
  7585. Directory.CreateDirectory(fileDir);
  7586. }
  7587. //上传的文件的路径
  7588. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  7589. using (FileStream fs = System.IO.File.Create(filePath))
  7590. {
  7591. file.CopyTo(fs);
  7592. fs.Flush();
  7593. }
  7594. return Ok(JsonView(true, "上传成功!", projectFileName));
  7595. }
  7596. else
  7597. {
  7598. return Ok(JsonView(false, "上传失败!"));
  7599. }
  7600. }
  7601. catch (Exception ex)
  7602. {
  7603. return Ok(JsonView(false, "程序错误!"));
  7604. throw;
  7605. }
  7606. }
  7607. /// <summary>
  7608. /// 保险删除指定文件
  7609. /// </summary>
  7610. /// <param name="dto"></param>
  7611. /// <returns></returns>
  7612. [HttpPost]
  7613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7614. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  7615. {
  7616. try
  7617. {
  7618. string filePath = "";
  7619. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7620. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  7621. //int id = 0;
  7622. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  7623. // 删除该文件
  7624. try
  7625. {
  7626. System.IO.File.Delete(filePath);
  7627. 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()
  7628. {
  7629. Attachment = "",
  7630. }).ExecuteCommandAsync();
  7631. if (result != 0)
  7632. {
  7633. return Ok(JsonView(true, "成功!"));
  7634. }
  7635. else
  7636. {
  7637. return Ok(JsonView(false, "失败!"));
  7638. }
  7639. }
  7640. catch (Exception)
  7641. {
  7642. 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()
  7643. {
  7644. Attachment = "",
  7645. }).ExecuteCommandAsync();
  7646. if (result != 0)
  7647. {
  7648. return Ok(JsonView(true, "成功!"));
  7649. }
  7650. else
  7651. {
  7652. return Ok(JsonView(false, "失败!"));
  7653. }
  7654. }
  7655. }
  7656. catch (Exception ex)
  7657. {
  7658. return Ok(JsonView(false, "程序错误!"));
  7659. throw;
  7660. }
  7661. }
  7662. /// <summary>
  7663. /// 保险费用操作(删除)
  7664. /// </summary>
  7665. /// <param name="dto"></param>
  7666. /// <returns></returns>
  7667. [HttpPost]
  7668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7669. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  7670. {
  7671. try
  7672. {
  7673. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  7674. if (!res)
  7675. {
  7676. return Ok(JsonView(false, "删除失败"));
  7677. }
  7678. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  7679. {
  7680. IsDel = 1,
  7681. DeleteUserId = dto.DeleteUserId,
  7682. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7683. }).ExecuteCommandAsync();
  7684. return Ok(JsonView(true, "删除成功!"));
  7685. }
  7686. catch (Exception ex)
  7687. {
  7688. return Ok(JsonView(false, "程序错误!"));
  7689. throw;
  7690. }
  7691. }
  7692. #endregion
  7693. #region 接团客户名单 PageId 104
  7694. /// <summary>
  7695. /// 接团客户名单
  7696. /// 根据团组Id查询List
  7697. /// </summary>
  7698. /// <param name="dto"></param>
  7699. /// <returns></returns>
  7700. [HttpPost]
  7701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7702. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  7703. {
  7704. #region 参数验证
  7705. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  7706. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7707. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  7708. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7709. #region 页面操作权限验证
  7710. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7711. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7712. #endregion
  7713. #endregion
  7714. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType,_dto.DiId);
  7715. if (viewData.Code != 0)
  7716. {
  7717. return Ok(JsonView(false, viewData.Msg));
  7718. }
  7719. return Ok(JsonView(viewData.Data));
  7720. }
  7721. /// <summary>
  7722. /// 接团客户名单
  7723. /// 基础数据 Init
  7724. /// </summary>
  7725. /// <param name="_dto"></param>
  7726. /// <returns></returns>
  7727. [HttpPost]
  7728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7729. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  7730. {
  7731. #region 参数验证
  7732. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7733. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7734. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7735. #region 页面操作权限验证
  7736. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7737. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7738. #endregion
  7739. #endregion
  7740. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  7741. if (viewData.Code != 0)
  7742. {
  7743. return Ok(JsonView(false, viewData.Msg));
  7744. }
  7745. return Ok(JsonView(viewData.Data));
  7746. }
  7747. /// <summary>
  7748. /// 接团客户名单
  7749. /// 根据 Id查询 Details
  7750. /// </summary>
  7751. /// <param name="_dto"></param>
  7752. /// <returns></returns>
  7753. [HttpPost]
  7754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7755. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  7756. {
  7757. #region 参数验证
  7758. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7759. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7760. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7762. #region 页面操作权限验证
  7763. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7764. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7765. #endregion
  7766. #endregion
  7767. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  7768. if (viewData.Code != 0)
  7769. {
  7770. return Ok(JsonView(false, viewData.Msg));
  7771. }
  7772. return Ok(JsonView(viewData.Data));
  7773. }
  7774. /// <summary>
  7775. /// 接团客户名单
  7776. /// Add Or Edit
  7777. /// </summary>
  7778. /// <param name="_dto"></param>
  7779. /// <returns></returns>
  7780. [HttpPost]
  7781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7782. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  7783. {
  7784. #region 参数验证
  7785. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7786. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7787. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7789. #region 页面操作权限验证
  7790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7791. if (_dto.Id == 0) //添加
  7792. {
  7793. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7794. }else if (_dto.Id >= 0) //修改
  7795. {
  7796. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  7797. }
  7798. #endregion
  7799. #endregion
  7800. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  7801. if (viewData.Code != 0)
  7802. {
  7803. return Ok(JsonView(false, viewData.Msg));
  7804. }
  7805. return Ok(JsonView(true));
  7806. }
  7807. /// <summary>
  7808. /// 接团客户名单
  7809. /// AddMultiple(添加多个)
  7810. /// </summary>
  7811. /// <param name="_dto"></param>
  7812. /// <returns></returns>
  7813. [HttpPost]
  7814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7815. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  7816. {
  7817. #region 参数验证
  7818. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7819. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7820. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7821. #region 页面操作权限验证
  7822. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7823. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7824. #endregion
  7825. #endregion
  7826. var viewData = await _tourClientListRep._AddMultiple(_dto);
  7827. if (viewData.Code != 0)
  7828. {
  7829. return Ok(JsonView(false, viewData.Msg));
  7830. }
  7831. return Ok(JsonView(true));
  7832. }
  7833. /// <summary>
  7834. /// 接团客户名单
  7835. /// Del
  7836. /// </summary>
  7837. /// <param name="_dto"></param>
  7838. /// <returns></returns>
  7839. [HttpPost]
  7840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7841. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  7842. {
  7843. #region 参数验证
  7844. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7845. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7846. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7847. #region 页面操作权限验证
  7848. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7849. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  7850. #endregion
  7851. #endregion
  7852. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  7853. if (viewData.Code != 0)
  7854. {
  7855. return Ok(JsonView(false, viewData.Msg));
  7856. }
  7857. return Ok(JsonView(true));
  7858. }
  7859. /// <summary>
  7860. /// 接团客户名单
  7861. /// 文件下载 客户名单
  7862. /// </summary>
  7863. /// <param name="_dto"></param>
  7864. /// <returns></returns>
  7865. [HttpPost]
  7866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7867. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  7868. {
  7869. #region 参数验证
  7870. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7871. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7872. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  7873. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7874. #region 页面操作权限验证
  7875. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7876. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7877. #endregion
  7878. #endregion
  7879. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7880. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7881. From Grp_TourClientList tcl
  7882. Left Join
  7883. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7884. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7885. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7886. From Crm_DeleClient dc
  7887. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7888. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7889. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7890. Where dc.IsDel = 0) temp
  7891. On temp.DcId =tcl.ClientId
  7892. Where tcl.IsDel = 0 And tcl.DiId = {0}",_dto.DiId);
  7893. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  7894. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  7895. //载入模板
  7896. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  7897. //载入模板
  7898. var doc = new Document(tempPath);
  7899. DocumentBuilder builder = new DocumentBuilder(doc);
  7900. //获取word里所有表格
  7901. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7902. //获取所填表格的序数
  7903. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7904. var rowStart = tableOne.Rows[0]; //获取第1行
  7905. //循环赋值
  7906. for (int i = 0; i < DcList.Count; i++)
  7907. {
  7908. builder.MoveToCell(0, i + 1, 0, 0);
  7909. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  7910. builder.MoveToCell(0, i + 1, 1, 0);
  7911. int sex = DcList[i].Sex;
  7912. string sexStr = string.Empty;
  7913. if (sex == 0) sexStr = "男";
  7914. else if (sex == 1) sexStr = "女";
  7915. else sexStr = "未设置";
  7916. builder.Write(sexStr);
  7917. builder.MoveToCell(0, i + 1, 2, 0);
  7918. string birthDay = DcList[i].BirthDay;
  7919. string birthDayStr = string.Empty;
  7920. if (!string.IsNullOrEmpty(birthDay))
  7921. {
  7922. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  7923. }
  7924. builder.Write(birthDayStr);
  7925. builder.MoveToCell(0, i + 1, 3, 0);
  7926. builder.Write(DcList[i].CompanyFullName);
  7927. builder.MoveToCell(0, i + 1, 4, 0);
  7928. builder.Write(DcList[i].Job);
  7929. }
  7930. //删除多余行
  7931. while (tableOne.Rows.Count > DcList.Count + 1)
  7932. {
  7933. tableOne.Rows.RemoveAt(DcList.Count + 1);
  7934. }
  7935. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  7936. var fileDir = AppSettingsHelper.Get("WordBasePath") + fileName;
  7937. doc.Save(fileDir);
  7938. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + fileName;
  7939. return Ok(JsonView(true, "操作成功!", Url));
  7940. }
  7941. #endregion
  7942. #region 团组倒推表
  7943. /// <summary>
  7944. /// 倒推表基础数据
  7945. /// Init
  7946. /// </summary>
  7947. /// <param name="dto"></param>
  7948. /// <returns></returns>
  7949. [HttpPost]
  7950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7951. public async Task<IActionResult> PostInvertedListInit()
  7952. {
  7953. var viewData = await _invertedListRep._Init();
  7954. if (viewData.Code != 0)
  7955. {
  7956. return Ok(JsonView(false, viewData.Msg));
  7957. }
  7958. return Ok(JsonView(viewData.Data));
  7959. }
  7960. /// <summary>
  7961. /// 倒推表
  7962. /// Info
  7963. /// </summary>
  7964. /// <param name="dto"></param>
  7965. /// <returns></returns>
  7966. [HttpPost]
  7967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7968. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  7969. {
  7970. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  7971. if (viewData.Code != 0)
  7972. {
  7973. return Ok(JsonView(false, viewData.Msg));
  7974. }
  7975. return Ok(JsonView(viewData.Data));
  7976. }
  7977. /// <summary>
  7978. /// 倒推表
  7979. /// Create
  7980. /// </summary>
  7981. /// <param name="dto"></param>
  7982. /// <returns></returns>
  7983. [HttpPost]
  7984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7985. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  7986. {
  7987. var viewData = await _invertedListRep._Create(dto.PortType,dto.DiId);
  7988. if (viewData.Code != 0)
  7989. {
  7990. return Ok(JsonView(false, viewData.Msg));
  7991. }
  7992. return Ok(JsonView(viewData.Data));
  7993. }
  7994. /// <summary>
  7995. /// 倒推表
  7996. /// Update
  7997. /// </summary>
  7998. /// <param name="dto"></param>
  7999. /// <returns></returns>
  8000. [HttpPost]
  8001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8002. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  8003. {
  8004. var viewData = await _invertedListRep._Update(dto);
  8005. if (viewData.Code != 0)
  8006. {
  8007. return Ok(JsonView(false, viewData.Msg));
  8008. }
  8009. return Ok(JsonView(viewData.Data));
  8010. }
  8011. /// <summary>
  8012. /// 倒推表
  8013. /// File Download
  8014. /// </summary>
  8015. /// <param name="dto"></param>
  8016. /// <returns></returns>
  8017. [HttpPost]
  8018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8019. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  8020. {
  8021. var info1 = await _invertedListRep._sqlSugar.Queryable<Grp_InvertedList>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).FirstAsync();
  8022. if (info1 == null)
  8023. {
  8024. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  8025. }
  8026. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  8027. string teamName = "";
  8028. if (info != null) teamName = info.TeamName;
  8029. //载入模板
  8030. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  8031. DocumentBuilder builder = new DocumentBuilder(doc);
  8032. //利用键值对存放数据
  8033. Dictionary<string, string> dic = new Dictionary<string, string>();
  8034. dic.Add("TeamName", teamName);
  8035. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime());
  8036. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  8037. dic.Add("BPRemark", info1.ApprovalDataRemark);
  8038. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  8039. dic.Add("SQRemark", info1.ApprovalRemark);
  8040. dic.Add("CPJtime", info1.ApprovalDt.ConvertToDatetime());
  8041. dic.Add("CPJRemark", info1.ApprovalRemark);
  8042. dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  8043. dic.Add("HZRemark", info1.ApplyPassportRemark);
  8044. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  8045. dic.Add("QZRemark", info1.VisaInformationRemark);
  8046. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  8047. dic.Add("SQQZRemark", info1.SendVisaRemark);
  8048. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  8049. dic.Add("CQRemark", info1.IssueVisaRemark);
  8050. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  8051. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  8052. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  8053. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  8054. #region 填充word模板书签内容
  8055. foreach (var key in dic.Keys)
  8056. {
  8057. builder.MoveToBookmark(key);
  8058. builder.Write(dic[key]);
  8059. }
  8060. #endregion
  8061. var fileDir = AppSettingsHelper.Get("WordBasePath");
  8062. string fileName = $"{teamName}团出行准备流程表.doc";
  8063. string filePath = fileDir + $@"InvertedList/{fileName}";
  8064. doc.Save(filePath);
  8065. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  8066. return Ok(JsonView(true, "操作成功!", Url));
  8067. }
  8068. #endregion
  8069. }
  8070. }