GroupsController.cs 418 KB

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