GroupsController.cs 415 KB

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