GroupsController.cs 560 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. namespace OASystem.API.Controllers
  90. {
  91. /// <summary>
  92. /// 团组相关
  93. /// </summary>
  94. //[Authorize]
  95. [Route("api/[controller]/[action]")]
  96. public class GroupsController : ControllerBase
  97. {
  98. private readonly GrpScheduleRepository _grpScheduleRep;
  99. private readonly IMapper _mapper;
  100. private readonly DelegationInfoRepository _groupRepository;
  101. private readonly TaskAssignmentRepository _taskAssignmentRep;
  102. private readonly AirTicketResRepository _airTicketResRep;
  103. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  104. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  105. private readonly DelegationEnDataRepository _delegationEnDataRep;
  106. private readonly DelegationVisaRepository _delegationVisaRep;
  107. private readonly VisaPriceRepository _visaPriceRep;
  108. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  109. private readonly HotelPriceRepository _hotelPriceRep;
  110. private readonly CustomersRepository _customersRep;
  111. private readonly MessageRepository _message;
  112. private readonly SqlSugarClient _sqlSugar;
  113. private readonly TourClientListRepository _tourClientListRep;
  114. private readonly TeamRateRepository _teamRateRep;
  115. #region 成本相关
  116. private readonly CheckBoxsRepository _checkBoxs;
  117. private readonly GroupCostRepository _GroupCostRepository;
  118. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  119. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  120. #endregion
  121. private readonly SetDataRepository _setDataRep;
  122. private string url;
  123. private string path;
  124. private readonly EnterExitCostRepository _enterExitCostRep;
  125. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  126. private readonly UsersRepository _usersRep;
  127. private readonly IJuHeApiService _juHeApi;
  128. private readonly InvertedListRepository _invertedListRep;
  129. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  130. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  131. private readonly HotelInquiryRepository _hotelInquiryRep;
  132. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  133. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  134. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  135. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  136. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  137. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  138. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  139. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep)
  140. {
  141. _mapper = mapper;
  142. _grpScheduleRep = grpScheduleRep;
  143. _groupRepository = groupRepository;
  144. _taskAssignmentRep = taskAssignmentRep;
  145. _airTicketResRep = airTicketResRep;
  146. _sqlSugar = sqlSugar;
  147. url = AppSettingsHelper.Get("ExcelBaseUrl");
  148. path = AppSettingsHelper.Get("ExcelBasePath");
  149. if (!System.IO.Directory.Exists(path))
  150. {
  151. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  152. }
  153. _decreasePaymentsRep = decreasePaymentsRep;
  154. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  155. _delegationEnDataRep = delegationEnDataRep;
  156. _enterExitCostRep = enterExitCostRep;
  157. _delegationVisaRep = delegationVisaRep;
  158. _message = message;
  159. _visaPriceRep = visaPriceRep;
  160. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  161. _checkBoxs = checkBoxs;
  162. _GroupCostRepository = GroupCostRepository;
  163. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  164. _GroupCostParameterRepository = GroupCostParameterRepository;
  165. _hotelPriceRep = hotelPriceRep;
  166. _customersRep = customersRep;
  167. _setDataRep = setDataRep;
  168. _tourClientListRep = tourClientListRep;
  169. _teamRateRep = teamRateRep;
  170. _hubContext = hubContext;
  171. _usersRep = usersRep;
  172. _juHeApi = juHeApi;
  173. _invertedListRep = invertedListRep;
  174. _visaFeeInfoRep = visaFeeInfoRep;
  175. _ticketBlackCodeRep = ticketBlackCodeRep;
  176. _hotelInquiryRep = hotelInquiryRep;
  177. }
  178. #region 流程管控
  179. /// <summary>
  180. /// 获取团组流程管控信息
  181. /// </summary>
  182. /// <param name="paras">参数Json字符串</param>
  183. /// <returns></returns>
  184. [HttpPost]
  185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  186. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  187. {
  188. if (string.IsNullOrEmpty(_jsonDto.Paras))
  189. {
  190. return Ok(JsonView(false, "参数为空"));
  191. }
  192. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  193. if (_ScheduleDto != null)
  194. {
  195. if (_ScheduleDto.SearchType == 2)//获取列表
  196. {
  197. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  198. return Ok(JsonView(_grpScheduleViewList));
  199. }
  200. else//获取对象
  201. {
  202. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  203. if (_grpScheduleView != null)
  204. {
  205. return Ok(JsonView(_grpScheduleView));
  206. }
  207. }
  208. }
  209. else
  210. {
  211. return Ok(JsonView(false, "参数反序列化失败"));
  212. }
  213. return Ok(JsonView(false, "暂无数据!"));
  214. }
  215. /// <summary>
  216. /// 修改团组流程管控详细表数据
  217. /// </summary>
  218. /// <param name="paras"></param>
  219. /// <returns></returns>
  220. [HttpPost]
  221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  222. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  223. {
  224. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  225. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  226. .SetColumns(it => it.Duty == _detail.Duty)
  227. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  228. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  229. .SetColumns(it => it.JobContent == _detail.JobContent)
  230. .SetColumns(it => it.Remark == _detail.Remark)
  231. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  232. .Where(s => s.Id == dto.Id)
  233. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  234. .ExecuteCommandAsync();
  235. if (result > 0)
  236. {
  237. return Ok(JsonView(true, "保存成功!"));
  238. }
  239. return Ok(JsonView(false, "保存失败!"));
  240. }
  241. /// <summary>
  242. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  243. /// </summary>
  244. /// <param name="dto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  249. {
  250. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  251. _detail.IsDel = 1;
  252. _detail.DeleteUserId = dto.Duty;
  253. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  254. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  255. .SetColumns(it => it.IsDel == _detail.IsDel)
  256. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  257. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  258. .Where(it => it.Id == dto.Id)
  259. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  260. //.WhereColumns(s => s.Id == dto.Id)
  261. .ExecuteCommandAsync();
  262. if (result > 0)
  263. {
  264. return Ok(JsonView(true, "删除成功!"));
  265. }
  266. return Ok(JsonView(false, "删除失败!"));
  267. }
  268. /// <summary>
  269. /// 增加团组流程管控详细表数据
  270. /// </summary>
  271. /// <param name="dto"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  276. {
  277. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  278. if (DateTime.Now < _detail.ExpectBeginDt)
  279. {
  280. _detail.StepStatus = 0;
  281. }
  282. else
  283. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  284. _detail.StepStatus = 1;
  285. }
  286. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  287. if (result > 0)
  288. {
  289. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  290. return Ok(JsonView(true, "添加成功!", _result));
  291. }
  292. return Ok(JsonView(false, "添加失败!"));
  293. }
  294. #endregion
  295. #region 团组基本信息
  296. /// <summary>
  297. /// 接团信息列表
  298. /// </summary>
  299. /// <param name="dto">团组列表请求dto</param>
  300. /// <returns></returns>
  301. [HttpPost]
  302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  303. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  304. {
  305. var groupData = await _groupRepository.GetGroupList(dto);
  306. if (groupData.Code != 0)
  307. {
  308. return Ok(JsonView(false, groupData.Msg));
  309. }
  310. return Ok(JsonView(groupData.Data));
  311. }
  312. /// <summary>
  313. /// 接团信息列表 Page
  314. /// </summary>
  315. /// <param name="dto">团组列表请求dto</param>
  316. /// <returns></returns>
  317. [HttpPost]
  318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  319. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  320. {
  321. #region 参数验证
  322. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  323. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  324. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  325. #region 页面操作权限验证
  326. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  327. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  328. #endregion
  329. #endregion
  330. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  331. {
  332. string sqlWhere = string.Empty;
  333. if (dto.IsSure == 0) //未完成
  334. {
  335. sqlWhere += string.Format(@" And IsSure = 0");
  336. }
  337. else if (dto.IsSure == 1) //已完成
  338. {
  339. sqlWhere += string.Format(@" And IsSure = 1");
  340. }
  341. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  342. {
  343. string tj = dto.SearchCriteria;
  344. 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}%')",
  345. tj, tj, tj, tj, tj);
  346. }
  347. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  348. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  349. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  350. JietuanOperator,IsSure,CreateTime
  351. From (
  352. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  353. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  354. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  355. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  356. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  357. From Grp_DelegationInfo gdi
  358. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  359. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  360. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  361. Where gdi.IsDel = 0 {0}
  362. ) temp", sqlWhere);
  363. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  364. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  365. #region 处理所属部门
  366. /*
  367. * 1.sq 和 gyy 等显示 市场部
  368. * 2.王鸽和主管及张总还有管理员号统一国交部
  369. * 2-1. 4 管理员 ,21 张海麟
  370. */
  371. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  372. List<int> userIds1 = new List<int>() { 4, 21 };
  373. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  374. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  375. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  376. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  377. .ToList();
  378. foreach (var item in _DelegationList)
  379. {
  380. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  381. }
  382. #endregion
  383. var _view = new
  384. {
  385. PageFuncAuth = pageFunAuthView,
  386. Data = _DelegationList
  387. };
  388. return Ok(JsonView(true, "查询成功!", _view, total));
  389. }
  390. else
  391. {
  392. return Ok(JsonView(false, "查询失败"));
  393. }
  394. }
  395. /// <summary>
  396. /// 团组列表
  397. /// </summary>
  398. /// <returns></returns>
  399. [HttpPost]
  400. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  401. {
  402. #region 参数验证
  403. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  404. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  405. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  406. #region 页面操作权限验证
  407. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  408. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  409. #endregion
  410. #endregion
  411. if (dto.PortType != 1 && dto.PortType != 2)
  412. {
  413. return Ok(JsonView(false, "查询失败!"));
  414. }
  415. string orderbyStr = "order by gdi.CreateTime Desc";
  416. string sqlWhere = string.Empty;
  417. if (dto.IsSure == 0) //未完成
  418. {
  419. sqlWhere += string.Format(@" And IsSure = 0");
  420. }
  421. else if (dto.IsSure == 1) //已完成
  422. {
  423. sqlWhere += string.Format(@" And IsSure = 1");
  424. }
  425. //团组类型
  426. if (dto.TeamDid > 0)
  427. {
  428. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  429. }
  430. //团组名称
  431. if (!string.IsNullOrEmpty(dto.TeamName))
  432. {
  433. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  434. }
  435. //客户名称
  436. if (!string.IsNullOrEmpty(dto.ClientName))
  437. {
  438. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  439. }
  440. //客户单位
  441. if (!string.IsNullOrEmpty(dto.ClientUnit))
  442. {
  443. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  444. }
  445. //出访时间
  446. if (!string.IsNullOrEmpty(dto.visitDataTime))
  447. {
  448. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  449. orderbyStr = "order by gdi.VisitDate";
  450. }
  451. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  452. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  453. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  454. JietuanOperator,IsSure,CreateTime
  455. From (
  456. Select row_number() over({0}) as Row_Number,
  457. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  458. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  459. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  460. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  461. From Grp_DelegationInfo gdi
  462. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  463. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  464. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  465. Where gdi.IsDel = 0 {1}
  466. ) temp ", orderbyStr, sqlWhere);
  467. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  468. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  469. #region 处理所属部门
  470. /*
  471. * 1.sq 和 gyy 等显示 市场部
  472. * 2.王鸽和主管及张总还有管理员号统一国交部
  473. * 2-1. 4 管理员 ,21 张海麟
  474. */
  475. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  476. List<int> userIds1 = new List<int>() { 4, 21 };
  477. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  478. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  479. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  480. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  481. .ToList();
  482. foreach (var item in _DelegationList)
  483. {
  484. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  485. }
  486. #endregion
  487. var _view = new
  488. {
  489. PageFuncAuth = pageFunAuthView,
  490. Data = _DelegationList
  491. };
  492. return Ok(JsonView(true, "查询成功!", _view, total));
  493. }
  494. /// <summary>
  495. /// 接团信息详情
  496. /// </summary>
  497. /// <param name="dto">团组info请求dto</param>
  498. /// <returns></returns>
  499. [HttpPost]
  500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  501. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  502. {
  503. var groupData = await _groupRepository.GetGroupInfo(dto);
  504. if (groupData.Code != 0)
  505. {
  506. return Ok(JsonView(false, groupData.Msg));
  507. }
  508. return Ok(JsonView(groupData.Data));
  509. }
  510. /// <summary>
  511. /// 接团信息 编辑添加
  512. /// 基础信息数据源
  513. /// </summary>
  514. /// <param name="dto"></param>
  515. /// <returns></returns>
  516. [HttpPost]
  517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  518. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  519. {
  520. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  521. if (groupData.Code != 0)
  522. {
  523. return Ok(JsonView(false, groupData.Msg));
  524. }
  525. return Ok(JsonView(groupData.Data));
  526. }
  527. /// <summary>
  528. /// 接团信息 操作(增改)
  529. /// </summary>
  530. /// <param name="dto"></param>
  531. /// <returns></returns>
  532. [HttpPost]
  533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  534. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  535. {
  536. try
  537. {
  538. var groupData = await _groupRepository.GroupOperation(dto);
  539. if (groupData.Code != 0)
  540. {
  541. return Ok(JsonView(false, groupData.Msg));
  542. }
  543. int diId = 0;
  544. //添加时 默认加入团组汇率
  545. if (dto.Status == 1) //添加
  546. {
  547. diId = groupData.Data;
  548. //添加默认币种
  549. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  550. //默认分配权限
  551. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  552. //消息提示 王鸽 主管号
  553. List<int> _managerIds = new List<int>() { 22, 32 };
  554. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  555. if (userIds.Count > 0)
  556. {
  557. userIds.Add(208);
  558. //创建团组管控
  559. GroupStepForDelegation.CreateWorkStep(diId);
  560. //发送消息
  561. string groupName = dto.TeamName;
  562. string createGroupUser = string.Empty;
  563. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  564. if (userInfo != null) createGroupUser = userInfo.CnName;
  565. string title = $"系统通知";
  566. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  567. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  568. }
  569. //默认创建倒推表
  570. await _invertedListRep._Create(dto.UserId, diId);
  571. }
  572. else if (dto.Status == 2)
  573. {
  574. diId = dto.Id;
  575. }
  576. return Ok(JsonView(true, "操作成功!", diId));
  577. }
  578. catch (Exception ex)
  579. {
  580. Logs("[response]" + JsonConvert.SerializeObject(dto));
  581. Logs(ex.Message);
  582. return Ok(JsonView(false, ex.Message));
  583. }
  584. }
  585. /// <summary>
  586. /// 接团流程操作(增改)
  587. /// 安卓端使用 建团时添加客户名单
  588. /// </summary>
  589. /// <param name="dto"></param>
  590. /// <returns></returns>
  591. [HttpPost]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  594. {
  595. try
  596. {
  597. #region 参数验证
  598. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  599. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  600. #region 页面操作权限验证
  601. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  602. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  603. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  604. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  605. #endregion
  606. #endregion
  607. _sqlSugar.BeginTran();
  608. var _dto = new GroupOperationDto();
  609. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  610. var groupData = await _groupRepository.GroupOperation(_dto);
  611. if (groupData.Code != 0)
  612. {
  613. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  614. }
  615. int diId = 0;
  616. //添加时 默认加入团组汇率
  617. if (dto.Status == 1) //添加
  618. {
  619. diId = groupData.Data;
  620. //添加默认币种
  621. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  622. //默认分配权限
  623. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  624. //消息提示 王鸽 主管号
  625. List<int> _managerIds = new List<int>() { 22, 32 };
  626. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  627. if (userIds.Count > 0)
  628. {
  629. userIds.Add(208);
  630. //创建团组管控
  631. GroupStepForDelegation.CreateWorkStep(diId);
  632. //发送消息
  633. string groupName = dto.TeamName;
  634. string createGroupUser = string.Empty;
  635. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  636. if (userInfo != null) createGroupUser = userInfo.CnName;
  637. string title = $"系统通知";
  638. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  639. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  640. }
  641. }
  642. if (dto.Status == 2)
  643. {
  644. diId = dto.Id;
  645. if (diId == 0)
  646. {
  647. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  648. }
  649. }
  650. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  651. if (viewData.Code != 0)
  652. {
  653. _sqlSugar.RollbackTran();
  654. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  655. }
  656. _sqlSugar.CommitTran();
  657. return Ok(JsonView(true, "添加成功"));
  658. }
  659. catch (Exception ex)
  660. {
  661. _sqlSugar.RollbackTran();
  662. return Ok(JsonView(false, ex.Message));
  663. }
  664. }
  665. /// <summary>
  666. /// 接团信息 操作(删除)
  667. /// </summary>
  668. /// <param name="dto"></param>
  669. /// <returns></returns>
  670. [HttpPost]
  671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  672. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  673. {
  674. try
  675. {
  676. var groupData = await _groupRepository.GroupDel(dto);
  677. if (groupData.Code != 0)
  678. {
  679. return Ok(JsonView(false, groupData.Msg));
  680. }
  681. return Ok(JsonView(true));
  682. }
  683. catch (Exception ex)
  684. {
  685. Logs("[response]" + JsonConvert.SerializeObject(dto));
  686. Logs(ex.Message);
  687. return Ok(JsonView(false, ex.Message));
  688. }
  689. }
  690. /// <summary>
  691. /// 获取团组销售报价号
  692. /// 团组添加时 使用
  693. /// </summary>
  694. /// <returns></returns>
  695. [HttpPost]
  696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  697. public async Task<IActionResult> GetGroupSalesQuoteNo()
  698. {
  699. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  700. if (groupData.Code != 0)
  701. {
  702. return Ok(JsonView(false, groupData.Msg));
  703. }
  704. object salesQuoteNo = new
  705. {
  706. SalesQuoteNo = groupData.Data
  707. };
  708. return Ok(JsonView(salesQuoteNo));
  709. }
  710. /// <summary>
  711. /// 设置确认出团
  712. /// </summary>
  713. /// <param name="dto"></param>
  714. /// <returns></returns>
  715. [HttpPost]
  716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  717. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  718. {
  719. var groupData = await _groupRepository.ConfirmationGroup(dto);
  720. if (groupData.Code != 0)
  721. {
  722. return Ok(JsonView(false, groupData.Msg));
  723. }
  724. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  725. #region OA消息推送
  726. try
  727. {
  728. string groupName = groupInfo.TeamName;
  729. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  730. List<int> userIds = new List<int>();
  731. listUser.ForEach(s => userIds.Add(s.Id));
  732. string title = $"系统通知";
  733. string content = $"团组[{groupName}]已确认出团!";
  734. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  735. }
  736. catch (Exception ex)
  737. {
  738. }
  739. #endregion
  740. #region 应用推送
  741. try
  742. {
  743. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  744. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  745. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  746. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  747. {
  748. List<string> userList = new List<string>() { users.QiyeChatUserId };
  749. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  750. }
  751. }
  752. catch (Exception ex)
  753. {
  754. }
  755. #endregion
  756. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  757. return Ok(JsonView(true, "操作成功!", groupData.Data));
  758. }
  759. /// <summary>
  760. /// 获取团组名称data And 签证国别Data
  761. /// </summary>
  762. /// <param name="dto"></param>
  763. /// <returns></returns>
  764. [HttpPost]
  765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  766. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  767. {
  768. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  769. if (groupData.Code != 0)
  770. {
  771. return Ok(JsonView(false, groupData.Msg));
  772. }
  773. return Ok(JsonView(groupData.Data));
  774. }
  775. /// <summary>
  776. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  777. /// </summary>
  778. /// <returns></returns>
  779. [HttpPost]
  780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  781. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  782. {
  783. try
  784. {
  785. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  786. if (groupData.Code != 0)
  787. {
  788. return Ok(JsonView(false, groupData.Msg));
  789. }
  790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  791. }
  792. catch (Exception ex)
  793. {
  794. return Ok(JsonView(false, "程序错误!"));
  795. throw;
  796. }
  797. }
  798. #endregion
  799. #region 团组&签证
  800. /// <summary>
  801. /// 根据团组Id获取签证客户信息List
  802. /// </summary>
  803. /// <param name="dto">请求dto</param>
  804. /// <returns></returns>
  805. [HttpPost]
  806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  807. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  808. {
  809. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  810. if (groupData.Code != 0)
  811. {
  812. return Ok(JsonView(false, groupData.Msg));
  813. }
  814. return Ok(JsonView(groupData.Data));
  815. }
  816. /// <summary>
  817. /// IOS获取团组签证拍照上传进度01(团组列表)
  818. /// </summary>
  819. /// <param name="dto">请求dto</param>
  820. /// <returns></returns>
  821. [HttpPost]
  822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  823. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  824. {
  825. if (dto == null)
  826. {
  827. return Ok(JsonView(false, "参数为空"));
  828. }
  829. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  830. return Ok(JsonView(visaList));
  831. }
  832. /// <summary>
  833. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  834. /// </summary>
  835. /// <returns></returns>
  836. [HttpPost]
  837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  838. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  839. {
  840. if (dto == null)
  841. {
  842. return Ok(JsonView(false, "请求错误:"));
  843. }
  844. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  845. return Ok(JsonView(list));
  846. }
  847. /// <summary>
  848. /// IOS获取团组签证拍照上传进度03(相册)
  849. /// </summary>
  850. /// <returns></returns>
  851. [HttpPost]
  852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  853. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  854. {
  855. if (dto == null)
  856. {
  857. return Ok(JsonView(false, "请求错误:"));
  858. }
  859. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  860. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  861. list.ForEach(s => s.url = url);
  862. return Ok(JsonView(list));
  863. }
  864. /// <summary>
  865. /// IOS获取团组签证拍照上传进度04(图片上传)
  866. /// </summary>
  867. /// <param name="dto"></param>
  868. /// <returns></returns>
  869. [HttpPost]
  870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  871. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  872. {
  873. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  874. //if (!string.IsNullOrEmpty(result))
  875. //{
  876. //}
  877. //else {
  878. // return Ok(JsonView(false, "上传失败"));
  879. //}
  880. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  881. int sucNum = 0;
  882. try
  883. {
  884. foreach (var item in dto.base64DataList)
  885. {
  886. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  887. string result = decodeBase64ToImage(item, imageName);
  888. if (!string.IsNullOrEmpty(result))
  889. {
  890. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  891. pic.CreateUserId = dto.CreateUserId;
  892. pic.PicName = imageName;
  893. pic.PicPath = result;
  894. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  895. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  896. if (insertResult > 0)
  897. {
  898. sucNum++;
  899. }
  900. }
  901. }
  902. }
  903. catch (Exception ex)
  904. {
  905. return Ok(JsonView(false, ex.Message));
  906. }
  907. string msg = string.Format(@"成功上传{0}张", sucNum);
  908. return Ok(JsonView(true, msg));
  909. }
  910. private string decodeBase64ToImage(string base64DataURL, string imgName)
  911. {
  912. string filename = "";//声明一个string类型的相对路径
  913. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  914. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  915. try//会有异常抛出,try,catch一下
  916. {
  917. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  918. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  919. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  920. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  921. //文件名称
  922. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  923. //上传的文件的路径
  924. string filePath = "";
  925. if (!Directory.Exists(fileDir))
  926. {
  927. Directory.CreateDirectory(fileDir);
  928. }
  929. //上传的文件的路径
  930. filePath = fileDir + filename;
  931. //string url = HttpRuntime.AppDomainAppPath.ToString();
  932. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  933. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  934. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  935. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  936. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  937. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  938. ms.Close();//关闭当前流,并释放所有与之关联的资源
  939. bitmap.Dispose();
  940. }
  941. catch (Exception e)
  942. {
  943. string massage = e.Message;
  944. Logs("IOS图片上传Error:" + massage);
  945. //filename = e.Message;
  946. }
  947. return filename;//返回相对路径
  948. }
  949. /// <summary>
  950. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  951. /// </summary>
  952. /// <param name="dto"></param>
  953. /// <returns></returns>
  954. [HttpPost]
  955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  956. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  957. {
  958. if (dto == null)
  959. {
  960. return Ok(JsonView(false, "请求错误:"));
  961. }
  962. string msg = "参数错误";
  963. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  964. {
  965. try
  966. {
  967. //_delegationVisaRep.BeginTran();
  968. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  969. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  970. .Where(s => s.Id == dto.visaProgressCustomerId)
  971. .ExecuteCommandAsync();
  972. if (updCount > 0 && dto.publishCode == 1)
  973. {
  974. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  975. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  976. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  977. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  978. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  979. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  980. if (groupData == null)
  981. {
  982. _delegationVisaRep.RollbackTran();
  983. }
  984. string title = string.Format(@"[签证进度更新]");
  985. string content = string.Format(@"测试文本");
  986. bool rst = await _message.AddMsg(new MessageDto()
  987. {
  988. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  989. IssuerId = dto.publisher,
  990. Title = title,
  991. Content = content,
  992. ReleaseTime = DateTime.Now,
  993. UIdList = new List<int> {
  994. 234
  995. }
  996. });
  997. if (rst)
  998. {
  999. return Ok(JsonView(true, "发送通知成功"));
  1000. }
  1001. }
  1002. //_delegationVisaRep.CommitTran();
  1003. }
  1004. catch (Exception)
  1005. {
  1006. //_delegationVisaRep.RollbackTran();
  1007. }
  1008. }
  1009. return Ok(JsonView(true, msg));
  1010. }
  1011. #endregion
  1012. #region 团组任务分配
  1013. /// <summary>
  1014. /// 团组任务分配初始化
  1015. /// </summary>
  1016. /// <param name="dto"></param>
  1017. /// <returns></returns>
  1018. [HttpPost]
  1019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1020. public async Task<IActionResult> GetTaskAssignmen()
  1021. {
  1022. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1023. if (groupData.Code != 0)
  1024. {
  1025. return Ok(JsonView(false, groupData.Msg));
  1026. }
  1027. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1028. }
  1029. /// <summary>
  1030. /// 团组任务分配查询
  1031. /// </summary>
  1032. /// <param name="dto"></param>
  1033. /// <returns></returns>
  1034. [HttpPost]
  1035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1036. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1037. {
  1038. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1039. if (groupData.Code != 0)
  1040. {
  1041. return Ok(JsonView(false, groupData.Msg));
  1042. }
  1043. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1044. }
  1045. /// <summary>
  1046. /// 团组任务分配操作
  1047. /// </summary>
  1048. /// <param name="dto"></param>
  1049. /// <returns></returns>
  1050. [HttpPost]
  1051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1052. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1053. {
  1054. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1055. if (groupData.Code != 0)
  1056. {
  1057. return Ok(JsonView(false, groupData.Msg));
  1058. }
  1059. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1060. }
  1061. #endregion
  1062. #region 团组费用审核
  1063. /// <summary>
  1064. /// 费用审核
  1065. /// 团组列表 Page
  1066. /// </summary>
  1067. /// <param name="_dto">团组列表请求dto</param>
  1068. /// <returns></returns>
  1069. [HttpPost]
  1070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1071. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1072. {
  1073. #region 参数验证
  1074. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1075. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1076. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1077. #region 页面操作权限验证
  1078. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1079. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1080. #endregion
  1081. #endregion
  1082. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1083. {
  1084. string sqlWhere = string.Empty;
  1085. if (_dto.IsSure == 0) //未完成
  1086. {
  1087. sqlWhere += string.Format(@" And IsSure = 0");
  1088. }
  1089. else if (_dto.IsSure == 1) //已完成
  1090. {
  1091. sqlWhere += string.Format(@" And IsSure = 1");
  1092. }
  1093. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1094. {
  1095. string tj = _dto.SearchCriteria;
  1096. 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}%')",
  1097. tj, tj, tj, tj, tj);
  1098. }
  1099. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1100. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1101. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1102. From (
  1103. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1104. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1105. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1106. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1107. From Grp_DelegationInfo gdi
  1108. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1109. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1110. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1111. Where gdi.IsDel = 0 {0}
  1112. ) temp ", sqlWhere);
  1113. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1114. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1115. var _view = new
  1116. {
  1117. PageFuncAuth = pageFunAuthView,
  1118. Data = _DelegationList
  1119. };
  1120. return Ok(JsonView(true, "查询成功!", _view, total));
  1121. }
  1122. else
  1123. {
  1124. return Ok(JsonView(false, "查询失败"));
  1125. }
  1126. }
  1127. /// <summary>
  1128. /// 获取团组费用审核
  1129. /// </summary>
  1130. /// <param name="paras">参数Json字符串</param>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1135. {
  1136. try
  1137. {
  1138. #region 参数验证
  1139. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1140. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1141. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1142. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1143. #region 页面操作权限验证
  1144. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1145. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1146. #endregion
  1147. #endregion
  1148. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1149. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1150. #region 费用清单
  1151. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1152. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1153. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1154. List<Grp_CreditCardPayment> entityList = _groupRepository
  1155. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1156. .Where(exp.ToExpression())
  1157. .ToList();
  1158. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1159. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1160. /*
  1161. * 76://酒店预订
  1162. */
  1163. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1164. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1165. .ToListAsync();
  1166. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1167. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1168. .ToListAsync();
  1169. /*
  1170. * 79://车/导游地接
  1171. */
  1172. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1173. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1174. .ToListAsync();
  1175. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1176. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1177. .ToListAsync();
  1178. /*
  1179. * 80: //签证
  1180. */
  1181. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1182. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1183. .ToListAsync();
  1184. /*
  1185. *81: //邀请/公务活动
  1186. */
  1187. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1188. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1189. .ToListAsync();
  1190. /*
  1191. * 82: //团组客户保险
  1192. */
  1193. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1194. /*
  1195. * Lable = 85 机票预订
  1196. */
  1197. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1198. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1199. .ToListAsync();
  1200. /*
  1201. * 85 机票预定
  1202. */
  1203. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1204. /*
  1205. * 98 其他款项
  1206. */
  1207. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1208. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1209. .ToListAsync();
  1210. /*
  1211. * 285:收款退还
  1212. */
  1213. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1214. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1215. .ToListAsync();
  1216. /*
  1217. * 1015: //超支费用
  1218. */
  1219. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1220. /*
  1221. * 币种信息
  1222. */
  1223. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1224. /*
  1225. * 车/导游地接 费用类型
  1226. */
  1227. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 车/导游地接 费用类型
  1230. */
  1231. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1232. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1233. /*
  1234. * 用户信息
  1235. */
  1236. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1237. /*
  1238. * 费用模块
  1239. */
  1240. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1241. string priceModule = string.Empty;
  1242. if (sdPriceName != null)
  1243. {
  1244. priceModule = sdPriceName.Name;
  1245. }
  1246. /*
  1247. * 处理详情数据
  1248. */
  1249. foreach (var entity in entityList)
  1250. {
  1251. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1252. _detail.Id = entity.Id;
  1253. _detail.PriceName = priceModule;
  1254. /*
  1255. * 应付款金额
  1256. */
  1257. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1258. string PaymentCurrency_WaitPay = "Unknown";
  1259. string hotelCurrncyCode = "Unknown";
  1260. string hotelCurrncyName = "Unknown";
  1261. if (sdPaymentCurrency_WaitPay != null)
  1262. {
  1263. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1264. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1265. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1266. if (hotelCurrncyCode.Equals("CNY"))
  1267. {
  1268. entity.DayRate = 1.0000M;
  1269. }
  1270. }
  1271. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1272. /*
  1273. * 此次付款金额
  1274. */
  1275. decimal CurrPayStr = 0;
  1276. if (entity.PayPercentage == 0)
  1277. {
  1278. if (entity.PayThenMoney != 0)
  1279. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1280. }
  1281. else
  1282. {
  1283. if (entity.PayMoney != 0)
  1284. {
  1285. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1286. }
  1287. }
  1288. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1289. /*
  1290. * 剩余尾款
  1291. */
  1292. decimal BalanceStr = 0;
  1293. if (CurrPayStr != 0 )
  1294. {
  1295. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1296. BalanceStr = 0;
  1297. else
  1298. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1299. }
  1300. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1301. /*
  1302. * Bus名称
  1303. */
  1304. _detail.BusName = "待增加";
  1305. /*
  1306. *费用所属
  1307. */
  1308. switch (entity.CTable)
  1309. {
  1310. case 76://酒店预订
  1311. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1312. if (hotelReservations != null)
  1313. {
  1314. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1315. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1316. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1317. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1318. /*
  1319. * 费用类型
  1320. * 1:房费
  1321. * 2:早餐
  1322. * 3:地税
  1323. * 4:城市税
  1324. * </summary>
  1325. */
  1326. //地税
  1327. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1328. if (governmentRentData != null)
  1329. {
  1330. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1331. governmentRentFee = governmentRentData.Price;
  1332. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1333. if (governmentRentCurrData != null)
  1334. {
  1335. governmentRentCode = governmentRentCurrData.Name;
  1336. governmentRentName = $"({governmentRentCurrData.Remark})";
  1337. }
  1338. }
  1339. //城市税
  1340. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1341. if (cityTaxData != null)
  1342. {
  1343. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1344. cityTaxFee = cityTaxData.Price;
  1345. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1346. if (cityTaxCurrData != null)
  1347. {
  1348. cityTaxCode = cityTaxCurrData.Name;
  1349. cityTaxName = $"({cityTaxCurrData.Remark})";
  1350. }
  1351. }
  1352. //酒店早餐
  1353. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1354. if (breakfastData != null)
  1355. {
  1356. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1357. breakfastFee = breakfastData.Price;
  1358. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1359. if (breakfastCurrData != null)
  1360. {
  1361. breakfastCode = breakfastCurrData.Name;
  1362. breakfastName = $"({breakfastCurrData.Remark})";
  1363. }
  1364. }
  1365. //房间费用
  1366. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1367. if (roomData != null)
  1368. {
  1369. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1370. roomFee = roomData.Price;
  1371. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1372. if (roomCurrData != null)
  1373. {
  1374. roomCode = roomCurrData.Name;
  1375. roomName = $"({roomCurrData.Remark})";
  1376. }
  1377. }
  1378. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1379. $"房间说明: {hotelReservations.Remark} <br/>" +
  1380. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率{roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1381. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率{breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1382. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率{governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1383. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率{cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1384. _detail.PriceNameContent = hotelReservations.HotelName;
  1385. }
  1386. break;
  1387. case 79://车/导游地接
  1388. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1389. if (touristGuideGroundReservations != null)
  1390. {
  1391. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1392. {
  1393. _detail.BusName = touristGuideGroundReservations.BusName;
  1394. }
  1395. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1396. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1397. //if (isInt)
  1398. //{
  1399. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1400. // if (cityInfo != null)
  1401. // {
  1402. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1403. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1404. // if (carFeeItem != null)
  1405. // {
  1406. // nameContent += $@"({carFeeItem.Name})";
  1407. // }
  1408. // _detail.PriceNameContent = nameContent;
  1409. // }
  1410. //}
  1411. //else
  1412. //{
  1413. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1414. //}
  1415. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1416. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1417. string priceMsg = string.Empty;
  1418. foreach (var item in touristGuideGroundReservationsContents)
  1419. {
  1420. string typeName = "Unknown";
  1421. string carCurrencyCode = "Unknown";
  1422. string carCurrencyName = "Unknown";
  1423. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1424. if (carTypeData != null) typeName = carTypeData.Name;
  1425. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1426. if (currencyData != null)
  1427. {
  1428. carCurrencyCode = currencyData.Name;
  1429. carCurrencyName = currencyData.Remark;
  1430. }
  1431. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1432. "明细:" + item.PriceContent + "<br/>" +
  1433. "备注:" + item.Remark + "<br/><br/>";
  1434. }
  1435. _detail.PriceMsgContent = priceMsg;
  1436. }
  1437. break;
  1438. case 80: //签证
  1439. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1440. if (visaInfo != null)
  1441. {
  1442. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1443. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1444. }
  1445. break;
  1446. case 81: //邀请/公务活动
  1447. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1448. if (_ioa != null)
  1449. {
  1450. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1451. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1452. sendCurrName = "Unknown", //快递费用币种 Name
  1453. sendCurrCode = "Unknown", //快递费用币种 Code
  1454. eventsCurrName = "Unknown", //公务活动费币种 Name
  1455. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1456. translateCurrName = "Unknown", //公务翻译费 Name
  1457. translateCurrCode = "Unknown"; //公务翻译费 Code
  1458. #region 处理费用币种
  1459. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1460. if (inviteCurrData != null)
  1461. {
  1462. inviteCurrName = inviteCurrData.Remark;
  1463. inviteCurrCode = inviteCurrData.Name;
  1464. }
  1465. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1466. if (sendCurrData != null)
  1467. {
  1468. sendCurrName = sendCurrData.Remark;
  1469. sendCurrCode = sendCurrData.Name;
  1470. }
  1471. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1472. if (eventsCurrData != null)
  1473. {
  1474. eventsCurrName = eventsCurrData.Remark;
  1475. eventsCurrCode = eventsCurrData.Name;
  1476. }
  1477. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1478. if (translateCurrData != null)
  1479. {
  1480. translateCurrName = translateCurrData.Remark;
  1481. translateCurrCode = translateCurrData.Name;
  1482. }
  1483. #endregion
  1484. _detail.PriceNameContent = _ioa.InviterArea;
  1485. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1486. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1487. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1488. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1489. $@"备注:" + _ioa.Remark + "<br/>";
  1490. }
  1491. break;
  1492. case 82: //团组客户保险
  1493. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1494. if (customers != null)
  1495. {
  1496. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1497. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1498. }
  1499. break;
  1500. case 85: //机票预订
  1501. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1502. if (jpRes != null)
  1503. {
  1504. string FlightsDescription = jpRes.FlightsDescription;
  1505. string PriceDescription = jpRes.PriceDescription;
  1506. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1507. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1508. }
  1509. break;
  1510. case 98://其他款项
  1511. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1512. if (gdpRes != null)
  1513. {
  1514. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1515. _detail.PriceNameContent = gdpRes.PriceName;
  1516. }
  1517. break;
  1518. case 285://收款退还
  1519. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1520. if (refundAndOtherMoney != null)
  1521. {
  1522. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1523. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1524. }
  1525. break;
  1526. case 751://酒店早餐
  1527. break;
  1528. case 1015://超支费用
  1529. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1530. if (groupExtraCost != null)
  1531. {
  1532. _detail.PriceNameContent = groupExtraCost.PriceName;
  1533. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1534. }
  1535. break;
  1536. default:
  1537. break;
  1538. }
  1539. /*
  1540. * 申请人
  1541. */
  1542. string operatorName = " - ";
  1543. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1544. if (_opUser != null)
  1545. {
  1546. operatorName = _opUser.CnName;
  1547. }
  1548. _detail.OperatorName = operatorName;
  1549. /*
  1550. * 审核人
  1551. */
  1552. string auditOperatorName = "Unknown";
  1553. if (entity.AuditGMOperate == 0)
  1554. auditOperatorName = " - ";
  1555. else if (entity.AuditGMOperate == 4)
  1556. auditOperatorName = "自动审核";
  1557. else
  1558. {
  1559. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1560. if (_adUser != null)
  1561. {
  1562. auditOperatorName = _adUser.CnName;
  1563. }
  1564. }
  1565. _detail.AuditOperatorName = auditOperatorName;
  1566. /*
  1567. * 超预算比例
  1568. */
  1569. string overBudgetStr = "";
  1570. if (entity.ExceedBudget == -1)
  1571. overBudgetStr = sdPriceName.Name + "尚无预算";
  1572. else if (entity.ExceedBudget == 0)
  1573. overBudgetStr = "未超预算";
  1574. else
  1575. overBudgetStr = entity.ExceedBudget.ToString("P");
  1576. _detail.OverBudget = overBudgetStr;
  1577. /*
  1578. * 费用总计
  1579. */
  1580. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1581. {
  1582. CurrencyId = entity.PaymentCurrency,
  1583. CurrencyName = PaymentCurrency_WaitPay,
  1584. AmountPayable = entity.PayMoney,
  1585. ThisPayment = CurrPayStr,
  1586. BalancePayment = BalanceStr,
  1587. AuditedFunds = CurrPayStr
  1588. });
  1589. _detail.IsAuditGM = entity.IsAuditGM;
  1590. detailList.Add(_detail);
  1591. }
  1592. #endregion
  1593. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1594. /*
  1595. * 下方描述处理
  1596. */
  1597. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1598. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1599. if (ccpCurrencyPrice != null)
  1600. {
  1601. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1602. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1603. }
  1604. else
  1605. {
  1606. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1607. }
  1608. string amountPayableStr = string.Format(@"应付款总金额: ");
  1609. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1610. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1611. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1612. foreach (var item in nonDuplicat)
  1613. {
  1614. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1615. if (strs.Count > 0)
  1616. {
  1617. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1618. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1619. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1620. //单独处理此次付款金额
  1621. if (item.CurrencyId == 836) //人民币
  1622. {
  1623. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1624. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1625. }
  1626. else
  1627. {
  1628. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1629. }
  1630. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1631. //单独处理已审核费用
  1632. if (item.CurrencyId == 836) //人民币
  1633. {
  1634. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1635. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1636. }
  1637. else
  1638. {
  1639. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1640. }
  1641. }
  1642. }
  1643. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1644. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1645. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1646. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1647. var _view1 = new
  1648. {
  1649. PageFuncAuth = pageFunAuthView,
  1650. Data = _view
  1651. };
  1652. return Ok(JsonView(_view1));
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. return Ok(JsonView(false, ex.Message));
  1657. }
  1658. }
  1659. /// <summary>
  1660. /// 费用审核
  1661. /// 修改团组费用审核状态
  1662. /// </summary>
  1663. /// <param name="_dto">参数Json字符串</param>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1668. {
  1669. #region 参数验证
  1670. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1671. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1672. #endregion
  1673. #region 页面操作权限验证
  1674. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1675. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1676. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1677. #endregion
  1678. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1679. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1680. DateTime dtNow = DateTime.Now;
  1681. _groupRepository.BeginTran();
  1682. int rst = 0;
  1683. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1684. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1685. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1686. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1687. List<dynamic> msgDatas = new List<dynamic>();
  1688. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1689. foreach (var item in idList)
  1690. {
  1691. int CreditId = int.Parse(item);
  1692. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1693. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1694. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1695. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1696. .Where(s => s.Id == CreditId)
  1697. .ExecuteCommandAsync();
  1698. if (result < 1)
  1699. {
  1700. rst = -1;
  1701. _groupRepository.RollbackTran();
  1702. return Ok(JsonView(false, "操作失败并回滚!"));
  1703. }
  1704. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1705. if (creditData != null)
  1706. {
  1707. #region 应用通知配置
  1708. try
  1709. {
  1710. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1711. }
  1712. catch (Exception ex)
  1713. {
  1714. }
  1715. #endregion
  1716. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1717. string groupNameStr = string.Empty;
  1718. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1719. if (groupData != null) groupNameStr = groupData.TeamName;
  1720. string creditTypeStr = string.Empty;
  1721. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1722. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1723. string creditCurrency = string.Empty;
  1724. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1725. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1726. if (creditCurrency.Equals("CNY"))
  1727. {
  1728. creditData.DayRate = 1.0000M;
  1729. }
  1730. if (creditData.PayPercentage == 0.00M)
  1731. {
  1732. creditData.PayPercentage = 100M;
  1733. }
  1734. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1735. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1736. string msgContent = "";
  1737. if (creditCurrency.Equals("CNY"))
  1738. {
  1739. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1740. }
  1741. else
  1742. {
  1743. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1744. }
  1745. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1746. }
  1747. }
  1748. if (rst == 0)
  1749. {
  1750. _groupRepository.CommitTran();
  1751. foreach (var item in msgDatas)
  1752. {
  1753. //发送消息
  1754. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1755. }
  1756. #region 应用推送
  1757. try
  1758. {
  1759. foreach (var ccpId in dic_ccp_user.Keys)
  1760. {
  1761. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1762. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1763. }
  1764. }
  1765. catch (Exception)
  1766. {
  1767. }
  1768. #endregion
  1769. return Ok(JsonView(true, "操作成功!"));
  1770. }
  1771. return Ok(JsonView(false, "操作失败!"));
  1772. }
  1773. #endregion
  1774. #region 机票费用录入
  1775. /// <summary>
  1776. /// 机票录入当前登录人可操作团组
  1777. /// </summary>
  1778. /// <param name="dto"></param>
  1779. /// <returns></returns>
  1780. [HttpPost]
  1781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1782. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1783. {
  1784. try
  1785. {
  1786. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1787. if (groupData.Code != 0)
  1788. {
  1789. return Ok(JsonView(false, groupData.Msg));
  1790. }
  1791. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1792. }
  1793. catch (Exception ex)
  1794. {
  1795. return Ok(JsonView(false, "程序错误!"));
  1796. throw;
  1797. }
  1798. }
  1799. /// <summary>
  1800. /// 机票费用录入列表
  1801. /// </summary>
  1802. /// <param name="dto"></param>
  1803. /// <returns></returns>
  1804. [HttpPost]
  1805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1806. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1807. {
  1808. try
  1809. {
  1810. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1811. if (groupData.Code != 0)
  1812. {
  1813. return Ok(JsonView(false, groupData.Msg));
  1814. }
  1815. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1816. }
  1817. catch (Exception ex)
  1818. {
  1819. return Ok(JsonView(false, ex.Message));
  1820. throw;
  1821. }
  1822. }
  1823. /// <summary>
  1824. /// 根据id查询费用录入信息
  1825. /// </summary>
  1826. /// <param name="dto"></param>
  1827. /// <returns></returns>
  1828. [HttpPost]
  1829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1830. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1831. {
  1832. try
  1833. {
  1834. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1835. if (groupData.Code != 0)
  1836. {
  1837. return Ok(JsonView(false, groupData.Msg));
  1838. }
  1839. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1840. }
  1841. catch (Exception ex)
  1842. {
  1843. return Ok(JsonView(false, "程序错误!"));
  1844. throw;
  1845. }
  1846. }
  1847. /// <summary>
  1848. /// 机票费用录入操作(Status:1.新增,2.修改)
  1849. /// </summary>
  1850. /// <param name="dto"></param>
  1851. /// <returns></returns>
  1852. [HttpPost]
  1853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1854. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1855. {
  1856. try
  1857. {
  1858. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1859. if (groupData.Code != 0)
  1860. {
  1861. return Ok(JsonView(false, groupData.Msg));
  1862. }
  1863. #region 应用推送
  1864. try
  1865. {
  1866. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1867. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1868. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1869. }
  1870. catch (Exception ex)
  1871. {
  1872. }
  1873. #endregion
  1874. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1875. }
  1876. catch (Exception ex)
  1877. {
  1878. return Ok(JsonView(false, "程序错误!"));
  1879. throw;
  1880. }
  1881. }
  1882. /// <summary>
  1883. /// 根据舱位类型查询接团客户名单信息
  1884. /// </summary>
  1885. /// <param name="dto"></param>
  1886. /// <returns></returns>
  1887. [HttpPost]
  1888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1889. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1890. {
  1891. try
  1892. {
  1893. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1894. if (crm_Groups.Count != 0)
  1895. {
  1896. List<dynamic> Customer = new List<dynamic>();
  1897. foreach (var item in crm_Groups)
  1898. {
  1899. var data = new
  1900. {
  1901. Id = item.Id,
  1902. Pinyin = item.Pinyin,
  1903. Name = item.LastName + item.FirstName
  1904. };
  1905. Customer.Add(data);
  1906. }
  1907. return Ok(JsonView(true, "查询成功!", Customer));
  1908. }
  1909. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1910. }
  1911. catch (Exception ex)
  1912. {
  1913. return Ok(JsonView(false, "程序错误!"));
  1914. throw;
  1915. }
  1916. }
  1917. /// <summary>
  1918. /// 根据团号获取客户信息
  1919. /// </summary>
  1920. /// <param name="dto"></param>
  1921. /// <returns></returns>
  1922. [HttpPost]
  1923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1924. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1925. {
  1926. var jw = JsonView(false);
  1927. if (dto.DIID < 1)
  1928. {
  1929. jw.Msg += "请输入正确的diid";
  1930. return Ok(jw);
  1931. }
  1932. var arr = getSimplClientList(dto.DIID);
  1933. jw = JsonView(true, "获取成功!", arr);
  1934. return Ok(jw);
  1935. }
  1936. private List<SimplClientInfo> getSimplClientList(int diId)
  1937. {
  1938. 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);
  1939. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1940. return arr;
  1941. }
  1942. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1943. {
  1944. string result = origin;
  1945. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1946. {
  1947. string[] temparr = origin.Split(',');
  1948. string fistrStr = temparr[0];
  1949. int count = temparr.Count();
  1950. int tempId;
  1951. bool success = int.TryParse(fistrStr, out tempId);
  1952. if (success)
  1953. {
  1954. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1955. if (tempInfo != null)
  1956. {
  1957. if (count > 1)
  1958. {
  1959. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1960. }
  1961. else
  1962. {
  1963. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1964. }
  1965. }
  1966. }
  1967. }
  1968. return result;
  1969. }
  1970. /// <summary>
  1971. /// 机票费用录入,删除
  1972. /// </summary>
  1973. /// <param name="dto"></param>
  1974. /// <returns></returns>
  1975. [HttpPost]
  1976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1977. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1978. {
  1979. try
  1980. {
  1981. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1982. if (res)
  1983. {
  1984. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1985. {
  1986. IsDel = 1,
  1987. DeleteUserId = dto.DeleteUserId,
  1988. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1989. }).ExecuteCommandAsync();
  1990. return Ok(JsonView(true, "删除成功!"));
  1991. }
  1992. return Ok(JsonView(false, "删除失败!"));
  1993. }
  1994. catch (Exception ex)
  1995. {
  1996. return Ok(JsonView(false, "程序错误!"));
  1997. throw;
  1998. }
  1999. }
  2000. /// <summary>
  2001. /// 导出机票录入报表
  2002. /// </summary>
  2003. /// <param name="dto"></param>
  2004. /// <returns></returns>
  2005. [HttpPost]
  2006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2007. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2008. {
  2009. try
  2010. {
  2011. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2012. if (groupData.Code != 0)
  2013. {
  2014. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2015. }
  2016. else
  2017. {
  2018. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2019. if (AirTicketReservations.Count != 0)
  2020. {
  2021. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2022. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2023. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2024. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2025. WorkbookDesigner designer = new WorkbookDesigner();
  2026. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2027. decimal countCost = 0;
  2028. foreach (var item in AirTicketReservations)
  2029. {
  2030. #region 处理客人姓名
  2031. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2032. item.ClientName = clientNames;
  2033. #endregion
  2034. if (item.BankType == "其他")
  2035. {
  2036. item.BankNo = "--";
  2037. }
  2038. else
  2039. {
  2040. if (!string.IsNullOrEmpty(item.BankType))
  2041. {
  2042. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2043. }
  2044. }
  2045. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2046. item.Price = System.Decimal.Round(item.Price, 2);
  2047. countCost += Convert.ToDecimal(item.Price);
  2048. }
  2049. designer.SetDataSource("Export", AirTicketReservations);
  2050. designer.SetDataSource("ExportDiCode", diCode);
  2051. designer.SetDataSource("ExportDiName", diName);
  2052. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2053. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2054. designer.Process();
  2055. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2056. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2057. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2058. return Ok(JsonView(true, "成功", url = rst));
  2059. }
  2060. else
  2061. {
  2062. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2063. }
  2064. }
  2065. }
  2066. catch (Exception ex)
  2067. {
  2068. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2069. throw;
  2070. }
  2071. }
  2072. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2073. /// <summary>
  2074. /// 行程单导出
  2075. /// </summary>
  2076. /// <param name="dto"></param>
  2077. /// <returns></returns>
  2078. [HttpPost]
  2079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2080. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2081. {
  2082. try
  2083. {
  2084. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2085. if (groupData.Code != 0)
  2086. {
  2087. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2088. }
  2089. else
  2090. {
  2091. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2092. if (dto.Language == "CN")
  2093. {
  2094. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2095. DocumentBuilder builder = new DocumentBuilder(doc);
  2096. int tableIndex = 0;//表格索引
  2097. //得到文档中的第一个表格
  2098. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2099. foreach (var item in _AirTicketReservations)
  2100. {
  2101. #region 处理固定数据
  2102. string[] FlightsCode = item.FlightsCode.Split('/');
  2103. if (FlightsCode.Length != 0)
  2104. {
  2105. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2106. if (_AirCompany != null)
  2107. {
  2108. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2109. }
  2110. else
  2111. {
  2112. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2113. }
  2114. }
  2115. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2116. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2117. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2118. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2119. string name = "";
  2120. foreach (string clientName in nameArray)
  2121. {
  2122. if (!name.Contains(clientName))
  2123. {
  2124. name += clientName + ",";
  2125. }
  2126. }
  2127. if (!string.IsNullOrWhiteSpace(name))
  2128. {
  2129. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2130. }
  2131. else
  2132. {
  2133. table.Range.Bookmarks["ClientName"].Text = "--";
  2134. }
  2135. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2136. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2137. table.Range.Bookmarks["JointTicket"].Text = "--";
  2138. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2139. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2140. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2141. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2142. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2143. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2144. #endregion
  2145. #region 循环数据处理
  2146. List<AirInfo> airs = new List<AirInfo>();
  2147. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2148. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2149. for (int i = 0; i < FlightsCode.Length; i++)
  2150. {
  2151. AirInfo air = new AirInfo();
  2152. string[] tempstr = DayArray[i]
  2153. .Replace("\r\n", string.Empty)
  2154. .Replace("\\r\\n", string.Empty)
  2155. .TrimStart().TrimEnd()
  2156. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2157. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2158. string starCity = "";
  2159. if (star_Three != null)
  2160. {
  2161. starCity = star_Three.AirPort;
  2162. }
  2163. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2164. string EndCity = "";
  2165. if (End_Three != null)
  2166. {
  2167. EndCity = End_Three.AirPort;
  2168. }
  2169. air.Destination = starCity + "/" + EndCity;
  2170. air.Flight = FlightsCode[i];
  2171. air.SeatingClass = item.CTypeName;
  2172. string dateTime = tempstr[2];
  2173. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2174. air.FlightDate = DateTemp;
  2175. air.DepartureTime = tempstr[5];
  2176. air.LandingTime = tempstr[6];
  2177. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2178. air.TicketStatus = "--";
  2179. air.Luggage = "--";
  2180. air.DepartureTerminal = "--";
  2181. air.LandingTerminal = "--";
  2182. airs.Add(air);
  2183. }
  2184. int row = 13;
  2185. for (int i = 0; i < airs.Count; i++)
  2186. {
  2187. if (airs.Count > 2)
  2188. {
  2189. for (int j = 0; j < airs.Count - 2; j++)
  2190. {
  2191. var CopyRow = table.Rows[12].Clone(true);
  2192. table.Rows.Add(CopyRow);
  2193. }
  2194. }
  2195. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2196. int index = 0;
  2197. foreach (PropertyInfo property in properties)
  2198. {
  2199. string value = property.GetValue(airs[i]).ToString();
  2200. Cell ishcel0 = table.Rows[row].Cells[index];
  2201. Paragraph p = new Paragraph(doc);
  2202. string s = value;
  2203. p.AppendChild(new Run(doc, s));
  2204. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2205. ishcel0.AppendChild(p);
  2206. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2207. index++;
  2208. }
  2209. row++;
  2210. }
  2211. #endregion
  2212. Paragraph lastParagraph = new Paragraph(doc);
  2213. //第一个表格末尾加段落
  2214. table.ParentNode.InsertAfter(lastParagraph, table);
  2215. //复制第一个表格
  2216. Table cloneTable = (Table)table.Clone(true);
  2217. //在文档末尾段落后面加入复制的表格
  2218. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2219. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2220. {
  2221. int rownewsIndex = 13;
  2222. for (int i = 0; i < 2; i++)
  2223. {
  2224. var CopyRow = table.Rows[12].Clone(true);
  2225. table.Rows.RemoveAt(13);
  2226. table.Rows.Add(CopyRow);
  2227. rownewsIndex++;
  2228. }
  2229. }
  2230. else
  2231. {
  2232. table.Rows.RemoveAt(12);
  2233. }
  2234. cloneTable.Rows.RemoveAt(12);
  2235. }
  2236. if (_AirTicketReservations.Count != 0)
  2237. {
  2238. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2239. if (FlightsCode.Length != 0)
  2240. {
  2241. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2242. if (_AirCompany != null)
  2243. {
  2244. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2245. }
  2246. else
  2247. {
  2248. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2249. }
  2250. }
  2251. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2252. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2253. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2254. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2255. string name = "";
  2256. foreach (string clientName in nameArray)
  2257. {
  2258. if (!name.Contains(clientName))
  2259. {
  2260. name += clientName + ",";
  2261. }
  2262. }
  2263. if (!string.IsNullOrWhiteSpace(name))
  2264. {
  2265. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2266. }
  2267. else
  2268. {
  2269. table.Range.Bookmarks["ClientName"].Text = "--";
  2270. }
  2271. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2272. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2273. table.Range.Bookmarks["JointTicket"].Text = "--";
  2274. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2275. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2276. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2277. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2278. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2279. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2280. }
  2281. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2282. //保存合并后的文档
  2283. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2284. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2285. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2286. return Ok(JsonView(true, "成功!", rst));
  2287. }
  2288. else
  2289. {
  2290. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2291. DocumentBuilder builder = new DocumentBuilder(doc);
  2292. int tableIndex = 0;//表格索引
  2293. //得到文档中的第一个表格
  2294. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2295. List<string> texts = new List<string>();
  2296. foreach (var item in _AirTicketReservations)
  2297. {
  2298. string[] FlightsCode = item.FlightsCode.Split('/');
  2299. if (FlightsCode.Length != 0)
  2300. {
  2301. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2302. if (_AirCompany != null)
  2303. {
  2304. if (!transDic.ContainsKey(_AirCompany.CnName))
  2305. {
  2306. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2307. }
  2308. }
  2309. else
  2310. {
  2311. if (!transDic.ContainsKey("--"))
  2312. {
  2313. transDic.Add("--", "--");
  2314. }
  2315. }
  2316. }
  2317. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2318. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2319. string name = "";
  2320. foreach (string clientName in nameArray)
  2321. {
  2322. name += clientName + ",";
  2323. }
  2324. if (!texts.Contains(name))
  2325. {
  2326. texts.Add(name);
  2327. }
  2328. List<AirInfo> airs = new List<AirInfo>();
  2329. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2330. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2331. for (int i = 0; i < FlightsCode.Length; i++)
  2332. {
  2333. AirInfo air = new AirInfo();
  2334. string[] tempstr = DayArray[i]
  2335. .Replace("\r\n", string.Empty)
  2336. .Replace("\\r\\n", string.Empty)
  2337. .TrimStart().TrimEnd()
  2338. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2339. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2340. if (star_Three != null)
  2341. {
  2342. if (!transDic.ContainsKey(star_Three.AirPort))
  2343. {
  2344. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2345. }
  2346. }
  2347. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2348. if (End_Three != null)
  2349. {
  2350. if (!transDic.ContainsKey(End_Three.AirPort))
  2351. {
  2352. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2353. }
  2354. }
  2355. if (!texts.Contains(item.CTypeName))
  2356. {
  2357. texts.Add(item.CTypeName);
  2358. }
  2359. }
  2360. }
  2361. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2362. if (transData.Count > 0)
  2363. {
  2364. foreach (TranslateResult item in transData)
  2365. {
  2366. if (!transDic.ContainsKey(item.Query))
  2367. {
  2368. transDic.Add(item.Query, item.Translation);
  2369. }
  2370. }
  2371. }
  2372. foreach (var item in _AirTicketReservations)
  2373. {
  2374. #region 处理固定数据
  2375. string[] FlightsCode = item.FlightsCode.Split('/');
  2376. if (FlightsCode.Length != 0)
  2377. {
  2378. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2379. if (_AirCompany != null)
  2380. {
  2381. string str = "--";
  2382. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2383. if (!string.IsNullOrEmpty(translateResult))
  2384. {
  2385. str = translateResult;
  2386. str = _airTicketResRep.Processing(str);
  2387. }
  2388. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2389. }
  2390. else
  2391. {
  2392. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2393. }
  2394. }
  2395. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2396. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2397. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2398. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2399. string names = "";
  2400. foreach (string clientName in nameArray)
  2401. {
  2402. names += clientName + ",";
  2403. }
  2404. if (!string.IsNullOrWhiteSpace(names))
  2405. {
  2406. string str = "--";
  2407. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2408. if (!string.IsNullOrEmpty(translateResult))
  2409. {
  2410. str = translateResult;
  2411. str = _airTicketResRep.Processing(str);
  2412. }
  2413. table.Range.Bookmarks["ClientName"].Text = str;
  2414. }
  2415. else
  2416. {
  2417. table.Range.Bookmarks["ClientName"].Text = "--";
  2418. }
  2419. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2420. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2421. table.Range.Bookmarks["JointTicket"].Text = "--";
  2422. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2423. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2424. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2425. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2426. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2427. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2428. #endregion
  2429. #region 循环数据处理
  2430. List<AirInfo> airs = new List<AirInfo>();
  2431. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2432. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2433. for (int i = 0; i < FlightsCode.Length; i++)
  2434. {
  2435. AirInfo air = new AirInfo();
  2436. string[] tempstr = DayArray[i]
  2437. .Replace("\r\n", string.Empty)
  2438. .Replace("\\r\\n", string.Empty)
  2439. .TrimStart().TrimEnd()
  2440. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2441. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2442. string starCity = "";
  2443. if (star_Three != null)
  2444. {
  2445. string str2 = "--";
  2446. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2447. if (!string.IsNullOrEmpty(translateResult2))
  2448. {
  2449. str2 = translateResult2;
  2450. str2 = _airTicketResRep.Processing(str2);
  2451. }
  2452. starCity = str2;
  2453. }
  2454. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2455. string EndCity = "";
  2456. if (End_Three != null)
  2457. {
  2458. string str1 = "--";
  2459. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2460. if (!string.IsNullOrEmpty(translateResult1))
  2461. {
  2462. str1 = translateResult1;
  2463. str1 = _airTicketResRep.Processing(str1);
  2464. }
  2465. EndCity = str1;
  2466. }
  2467. air.Destination = starCity + "/" + EndCity;
  2468. air.Flight = FlightsCode[i];
  2469. string str = "--";
  2470. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2471. if (!string.IsNullOrEmpty(translateResult))
  2472. {
  2473. str = translateResult;
  2474. str = _airTicketResRep.Processing(str);
  2475. }
  2476. air.SeatingClass = str;
  2477. string dateTime = tempstr[2];
  2478. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2479. air.FlightDate = DateTemp;
  2480. air.DepartureTime = tempstr[5];
  2481. air.LandingTime = tempstr[6];
  2482. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2483. air.TicketStatus = "--";
  2484. air.Luggage = "--";
  2485. air.DepartureTerminal = "--";
  2486. air.LandingTerminal = "--";
  2487. airs.Add(air);
  2488. }
  2489. int row = 13;
  2490. for (int i = 0; i < airs.Count; i++)
  2491. {
  2492. if (airs.Count > 2)
  2493. {
  2494. for (int j = 0; j < airs.Count - 2; j++)
  2495. {
  2496. var CopyRow = table.Rows[12].Clone(true);
  2497. table.Rows.Add(CopyRow);
  2498. }
  2499. }
  2500. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2501. int index = 0;
  2502. foreach (PropertyInfo property in properties)
  2503. {
  2504. string value = property.GetValue(airs[i]).ToString();
  2505. Cell ishcel0 = table.Rows[row].Cells[index];
  2506. Paragraph p = new Paragraph(doc);
  2507. string s = value;
  2508. p.AppendChild(new Run(doc, s));
  2509. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2510. ishcel0.AppendChild(p);
  2511. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2512. //ishcel0.CellFormat.VerticalAlignment=
  2513. index++;
  2514. }
  2515. row++;
  2516. }
  2517. #endregion
  2518. Paragraph lastParagraph = new Paragraph(doc);
  2519. //第一个表格末尾加段落
  2520. table.ParentNode.InsertAfter(lastParagraph, table);
  2521. //复制第一个表格
  2522. Table cloneTable = (Table)table.Clone(true);
  2523. //在文档末尾段落后面加入复制的表格
  2524. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2525. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2526. {
  2527. int rownewsIndex = 13;
  2528. for (int i = 0; i < 2; i++)
  2529. {
  2530. var CopyRow = table.Rows[12].Clone(true);
  2531. table.Rows.RemoveAt(13);
  2532. table.Rows.Add(CopyRow);
  2533. rownewsIndex++;
  2534. }
  2535. }
  2536. else
  2537. {
  2538. table.Rows.RemoveAt(12);
  2539. }
  2540. cloneTable.Rows.RemoveAt(12);
  2541. }
  2542. if (_AirTicketReservations.Count != 0)
  2543. {
  2544. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2545. if (FlightsCode.Length != 0)
  2546. {
  2547. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2548. if (_AirCompany != null)
  2549. {
  2550. string str = "--";
  2551. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2552. if (!string.IsNullOrEmpty(translateResult))
  2553. {
  2554. str = translateResult;
  2555. str = _airTicketResRep.Processing(str);
  2556. }
  2557. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2558. }
  2559. else
  2560. {
  2561. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2562. }
  2563. }
  2564. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2565. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2566. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2567. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2568. string names = "";
  2569. foreach (string clientName in nameArray)
  2570. {
  2571. names += clientName + ",";
  2572. }
  2573. if (!string.IsNullOrWhiteSpace(names))
  2574. {
  2575. string str = "--";
  2576. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2577. if (!string.IsNullOrEmpty(translateResult))
  2578. {
  2579. str = translateResult;
  2580. str = _airTicketResRep.Processing(str);
  2581. }
  2582. table.Range.Bookmarks["ClientName"].Text = str;
  2583. }
  2584. else
  2585. {
  2586. table.Range.Bookmarks["ClientName"].Text = "--";
  2587. }
  2588. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2589. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2590. table.Range.Bookmarks["JointTicket"].Text = "--";
  2591. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2592. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2593. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2594. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2595. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2596. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2597. }
  2598. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2599. //保存合并后的文档
  2600. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2601. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2602. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2603. return Ok(JsonView(true, "成功!", rst));
  2604. }
  2605. }
  2606. }
  2607. catch (Exception ex)
  2608. {
  2609. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2610. throw;
  2611. }
  2612. }
  2613. #endregion
  2614. #region 团组增减款项 --> 其他款项
  2615. /// <summary>
  2616. /// 团组增减款项下拉框绑定
  2617. /// </summary>
  2618. /// <param name="dto"></param>
  2619. /// <returns></returns>
  2620. [HttpPost]
  2621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2622. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2623. {
  2624. #region 参数验证
  2625. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2626. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2627. #endregion
  2628. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2629. }
  2630. /// <summary>
  2631. /// 根据团组Id查询团组增减款项
  2632. /// </summary>
  2633. /// <param name="dto"></param>
  2634. /// <returns></returns>
  2635. [HttpPost]
  2636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2637. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2638. {
  2639. #region 参数验证
  2640. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2641. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2642. #endregion
  2643. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2644. }
  2645. /// <summary>
  2646. /// 团组增减款项操作(Status:1.新增,2.修改)
  2647. /// </summary>
  2648. /// <param name="dto"></param>
  2649. /// <returns></returns>
  2650. [HttpPost]
  2651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2652. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2653. {
  2654. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2655. if (groupData.Code != 200)
  2656. {
  2657. return Ok(JsonView(false, groupData.Msg));
  2658. }
  2659. #region 应用推送
  2660. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2661. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2662. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2663. #endregion
  2664. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2665. }
  2666. /// <summary>
  2667. /// 团组增减款项操作 删除
  2668. /// </summary>
  2669. /// <param name="dto"></param>
  2670. /// <returns></returns>
  2671. [HttpPost]
  2672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2673. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2674. {
  2675. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2676. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2677. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2678. if (res.Code == 0)
  2679. {
  2680. return Ok(JsonView(true, "删除成功!"));
  2681. }
  2682. return Ok(JsonView(false, "删除失败!"));
  2683. }
  2684. /// <summary>
  2685. /// 根据团组增减款项Id查询
  2686. /// </summary>
  2687. /// <param name="dto"></param>
  2688. /// <returns></returns>
  2689. [HttpPost]
  2690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2691. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2692. {
  2693. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2694. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2695. }
  2696. /// <summary>
  2697. /// 查询供应商名称
  2698. /// </summary>
  2699. /// <param name="dto"></param>
  2700. /// <returns></returns>
  2701. [HttpPost]
  2702. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2703. {
  2704. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2705. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2706. ?? new List<Grp_DecreasePayments>();
  2707. dbResult = dbResult.Distinct(new
  2708. ProductComparer ()).ToList();
  2709. var jw = JsonView(true, "success", dbResult.OrderByDescending(x=>x. Id ).Select(x => new
  2710. {
  2711. x.Id,
  2712. x.SupplierAddress,
  2713. x.SupplierArea,
  2714. x.SupplierContact,
  2715. x.SupplierContactNumber,
  2716. x.SupplierEmail,
  2717. x.SupplierName,
  2718. x.SupplierSocialAccount,
  2719. x.SupplierTypeId,
  2720. }).ToList());
  2721. return Ok(jw);
  2722. }
  2723. #endregion
  2724. #region 文件上传、删除
  2725. /// <summary>
  2726. /// region 文件上传 可以带参数
  2727. /// </summary>
  2728. /// <param name="file"></param>
  2729. /// <returns></returns>
  2730. [HttpPost]
  2731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2732. public async Task<IActionResult> UploadProject(IFormFile file)
  2733. {
  2734. try
  2735. {
  2736. var TypeName = Request.Headers["TypeName"].ToString();
  2737. if (file != null)
  2738. {
  2739. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2740. //文件名称
  2741. string projectFileName = file.FileName;
  2742. //上传的文件的路径
  2743. string filePath = "";
  2744. if (TypeName == "A")//A代表团组增减款项
  2745. {
  2746. if (!Directory.Exists(fileDir))
  2747. {
  2748. Directory.CreateDirectory(fileDir);
  2749. }
  2750. //上传的文件的路径
  2751. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2752. }
  2753. else if (TypeName == "B")//B代表商邀相关文件
  2754. {
  2755. if (!Directory.Exists(fileDir))
  2756. {
  2757. Directory.CreateDirectory(fileDir);
  2758. }
  2759. //上传的文件的路径
  2760. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2761. }
  2762. using (FileStream fs = System.IO.File.Create(filePath))
  2763. {
  2764. file.CopyTo(fs);
  2765. fs.Flush();
  2766. }
  2767. return Ok(JsonView(true, "上传成功!", projectFileName));
  2768. }
  2769. else
  2770. {
  2771. return Ok(JsonView(false, "上传失败!"));
  2772. }
  2773. }
  2774. catch (Exception ex)
  2775. {
  2776. return Ok(JsonView(false, "程序错误!"));
  2777. throw;
  2778. }
  2779. }
  2780. /// <summary>
  2781. /// 删除指定文件
  2782. /// </summary>
  2783. /// <param name="dto"></param>
  2784. /// <returns></returns>
  2785. [HttpPost]
  2786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2787. public async Task<IActionResult> DelFile(DelFileDto dto)
  2788. {
  2789. try
  2790. {
  2791. var TypeName = Request.Headers["TypeName"].ToString();
  2792. string filePath = "";
  2793. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2794. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2795. int id = 0;
  2796. if (TypeName == "A")
  2797. {
  2798. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2799. // 删除该文件
  2800. System.IO.File.Delete(filePath);
  2801. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2802. }
  2803. else if (TypeName == "B")
  2804. {
  2805. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2806. // 删除该文件
  2807. System.IO.File.Delete(filePath);
  2808. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2809. }
  2810. if (id != 0)
  2811. {
  2812. return Ok(JsonView(true, "成功!"));
  2813. }
  2814. else
  2815. {
  2816. return Ok(JsonView(false, "失败!"));
  2817. }
  2818. }
  2819. catch (Exception ex)
  2820. {
  2821. return Ok(JsonView(false, "程序错误!"));
  2822. throw;
  2823. }
  2824. }
  2825. #endregion
  2826. #region 商邀费用录入
  2827. /// <summary>
  2828. /// 根据团组Id查询商邀费用列表
  2829. /// </summary>
  2830. /// <param name="dto"></param>
  2831. /// <returns></returns>
  2832. [HttpPost]
  2833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2834. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2835. {
  2836. try
  2837. {
  2838. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2839. if (groupData.Code != 0)
  2840. {
  2841. return Ok(JsonView(false, groupData.Msg));
  2842. }
  2843. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2844. }
  2845. catch (Exception ex)
  2846. {
  2847. return Ok(JsonView(false, "程序错误!"));
  2848. throw;
  2849. }
  2850. }
  2851. //
  2852. /// <summary>
  2853. /// 商邀费用 Info Page 基础数据源
  2854. /// </summary>
  2855. /// <param name="dto"></param>
  2856. /// <returns></returns>
  2857. [HttpPost]
  2858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2859. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2860. {
  2861. try
  2862. {
  2863. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2864. if (groupData.Code != 0)
  2865. {
  2866. return Ok(JsonView(false, groupData.Msg));
  2867. }
  2868. return Ok(JsonView(true, "操作成功", groupData.Data));
  2869. }
  2870. catch (Exception ex)
  2871. {
  2872. return Ok(JsonView(false, ex.Message));
  2873. throw;
  2874. }
  2875. }
  2876. /// <summary>
  2877. /// 根据商邀费用ID查询C表和商邀费用数据
  2878. /// </summary>
  2879. /// <param name="dto"></param>
  2880. /// <returns></returns>
  2881. [HttpPost]
  2882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2883. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2884. {
  2885. try
  2886. {
  2887. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2888. if (groupData.Code != 0)
  2889. {
  2890. return Ok(JsonView(false, groupData.Msg));
  2891. }
  2892. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2893. }
  2894. catch (Exception ex)
  2895. {
  2896. return Ok(JsonView(false, ex.Message));
  2897. throw;
  2898. }
  2899. }
  2900. /// <summary>
  2901. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2902. /// </summary>
  2903. /// <param name="dto"></param>
  2904. /// <returns></returns>
  2905. [HttpPost]
  2906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2907. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2908. {
  2909. try
  2910. {
  2911. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2912. if (groupData.Code != 0)
  2913. {
  2914. return Ok(JsonView(false, groupData.Msg));
  2915. }
  2916. #region 应用推送
  2917. try
  2918. {
  2919. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2920. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2921. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2922. }
  2923. catch (Exception ex)
  2924. {
  2925. }
  2926. #endregion
  2927. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2928. }
  2929. catch (Exception ex)
  2930. {
  2931. return Ok(JsonView(false, "程序错误!"));
  2932. throw;
  2933. }
  2934. }
  2935. /// <summary>
  2936. /// 商邀删除
  2937. /// </summary>
  2938. /// <param name="dto"></param>
  2939. /// <returns></returns>
  2940. [HttpPost]
  2941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2942. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2943. {
  2944. try
  2945. {
  2946. _sqlSugar.BeginTran();
  2947. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2948. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2949. {
  2950. IsDel = 1,
  2951. DeleteUserId = dto.DeleteUserId,
  2952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2953. })
  2954. .Where(it => it.Id == dto.Id)
  2955. .ExecuteCommand();
  2956. if (res1 > 0)
  2957. {
  2958. int _diId = 0;
  2959. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2960. if (_ioaInfo != null)
  2961. {
  2962. _diId = _ioaInfo.DiId;
  2963. }
  2964. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2965. .SetColumns(a => new Grp_CreditCardPayment()
  2966. {
  2967. IsDel = 1,
  2968. DeleteUserId = dto.DeleteUserId,
  2969. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2970. })
  2971. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2972. .ExecuteCommand();
  2973. if (res2 > 0)
  2974. {
  2975. _sqlSugar.CommitTran();
  2976. return Ok(JsonView(true, "删除成功!"));
  2977. }
  2978. }
  2979. _sqlSugar.RollbackTran();
  2980. return Ok(JsonView(false, "删除失败"));
  2981. }
  2982. catch (Exception ex)
  2983. {
  2984. _sqlSugar.RollbackTran();
  2985. return Ok(JsonView(false, ex.Message));
  2986. }
  2987. }
  2988. #endregion
  2989. #region 团组英文资料
  2990. /// <summary>
  2991. /// 查询团组英文所有资料
  2992. /// </summary>
  2993. /// <param name="dto"></param>
  2994. /// <returns></returns>
  2995. [HttpPost]
  2996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2997. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2998. {
  2999. try
  3000. {
  3001. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3002. if (groupData.Code != 0)
  3003. {
  3004. return Ok(JsonView(false, groupData.Msg));
  3005. }
  3006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3007. }
  3008. catch (Exception ex)
  3009. {
  3010. return Ok(JsonView(false, "程序错误!"));
  3011. throw;
  3012. }
  3013. }
  3014. /// <summary>
  3015. /// 团组英文资料操作(Status:1.新增,2.修改)
  3016. /// </summary>
  3017. /// <param name="dto"></param>
  3018. /// <returns></returns>
  3019. [HttpPost]
  3020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3021. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3022. {
  3023. try
  3024. {
  3025. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3026. if (groupData.Code != 0)
  3027. {
  3028. return Ok(JsonView(false, groupData.Msg));
  3029. }
  3030. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3031. }
  3032. catch (Exception ex)
  3033. {
  3034. return Ok(JsonView(false, "程序错误!"));
  3035. throw;
  3036. }
  3037. }
  3038. /// <summary>
  3039. /// 团组英文资料Id查询数据
  3040. /// </summary>
  3041. /// <param name="dto"></param>
  3042. /// <returns></returns>
  3043. [HttpPost]
  3044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3045. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3046. {
  3047. try
  3048. {
  3049. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3050. if (_DelegationEnData != null)
  3051. {
  3052. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3053. }
  3054. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3055. }
  3056. catch (Exception ex)
  3057. {
  3058. return Ok(JsonView(false, "程序错误!"));
  3059. throw;
  3060. }
  3061. }
  3062. /// <summary>
  3063. /// 团组英文资料删除
  3064. /// </summary>
  3065. /// <param name="dto"></param>
  3066. /// <returns></returns>
  3067. [HttpPost]
  3068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3069. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3070. {
  3071. try
  3072. {
  3073. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3074. if (!res)
  3075. {
  3076. return Ok(JsonView(false, "删除失败"));
  3077. }
  3078. return Ok(JsonView(true, "删除成功!"));
  3079. }
  3080. catch (Exception ex)
  3081. {
  3082. return Ok(JsonView(false, "程序错误!"));
  3083. throw;
  3084. }
  3085. }
  3086. #endregion
  3087. #region 导出邀请函
  3088. /// <summary>
  3089. /// 导出邀请函页面初始化
  3090. /// </summary>
  3091. /// <param name="dto"></param>
  3092. /// <returns></returns>
  3093. [HttpPost]
  3094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3095. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3096. {
  3097. try
  3098. {
  3099. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3100. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3101. if (dto.DiId == 0)
  3102. {
  3103. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3104. }
  3105. else
  3106. {
  3107. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3108. }
  3109. return Ok(JsonView(true, "查询成功!", new
  3110. {
  3111. deleClient = crm_Deles,
  3112. delegations = grp_Delegations
  3113. }));
  3114. }
  3115. catch (Exception ex)
  3116. {
  3117. return Ok(JsonView(false, "程序错误!"));
  3118. throw;
  3119. }
  3120. }
  3121. /// <summary>
  3122. /// 导出邀请函
  3123. /// </summary>
  3124. /// <param name="dto"></param>
  3125. /// <returns></returns>
  3126. [HttpPost]
  3127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3128. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3129. {
  3130. #region 参数验证
  3131. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3132. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3133. #endregion
  3134. try
  3135. {
  3136. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3137. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3138. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3139. From Grp_TourClientList tcl
  3140. Left Join
  3141. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3142. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3143. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3144. From Crm_DeleClient dc
  3145. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3146. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3147. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3148. Where dc.IsDel = 0) temp
  3149. On temp.DcId =tcl.ClientId
  3150. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3151. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3152. List<string> texts = new List<string>();
  3153. if (datas.Count != 0)
  3154. {
  3155. foreach (TourClientListDetailsView item in datas)
  3156. {
  3157. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3158. {
  3159. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3160. }
  3161. else
  3162. {
  3163. string name = item.LastName + item.FirstName;
  3164. texts.Add(name);
  3165. }
  3166. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3167. {
  3168. if (!transDic.ContainsKey(item.Job))
  3169. {
  3170. texts.Add(item.Job);
  3171. }
  3172. }
  3173. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3174. {
  3175. texts.Add(item.CompanyFullName);
  3176. }
  3177. }
  3178. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3179. if (transData.Count > 0)
  3180. {
  3181. foreach (TranslateResult item in transData)
  3182. {
  3183. if (!transDic.ContainsKey(item.Query))
  3184. {
  3185. transDic.Add(item.Query, item.Translation);
  3186. }
  3187. }
  3188. }
  3189. List<GuestList> list = new List<GuestList>();
  3190. foreach (TourClientListDetailsView dele in datas)
  3191. {
  3192. GuestList guestList = new GuestList();
  3193. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3194. {
  3195. guestList.Name = dele.Pinyin;
  3196. }
  3197. else
  3198. {
  3199. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3200. guestList.Name = Name;
  3201. }
  3202. if (dele.Sex == 0)
  3203. {
  3204. guestList.Sex = "Male";
  3205. }
  3206. else if (dele.Sex == 1)
  3207. {
  3208. guestList.Sex = "Female";
  3209. }
  3210. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3211. if (!string.IsNullOrEmpty(dele.Job))
  3212. {
  3213. guestList.Job = dele.Job;
  3214. }
  3215. list.Add(guestList);
  3216. }
  3217. //载入模板
  3218. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3219. DocumentBuilder builder = new DocumentBuilder(doc);
  3220. //获取word里所有表格
  3221. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3222. //获取所填表格的序数
  3223. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3224. var rowStart = tableOne.Rows[0]; //获取第1行
  3225. //循环赋值
  3226. for (int i = 0; i < list.Count; i++)
  3227. {
  3228. builder.MoveToCell(0, i + 1, 0, 0);
  3229. builder.Write(list[i].Name.ToString());
  3230. builder.MoveToCell(0, i + 1, 1, 0);
  3231. builder.Write(list[i].Sex.ToString());
  3232. builder.MoveToCell(0, i + 1, 2, 0);
  3233. builder.Write(list[i].DOB.ToString());
  3234. builder.MoveToCell(0, i + 1, 3, 0);
  3235. builder.Write(list[i].Job.ToString());
  3236. }
  3237. //删除多余行
  3238. while (tableOne.Rows.Count > list.Count + 1)
  3239. {
  3240. tableOne.Rows.RemoveAt(list.Count + 1);
  3241. }
  3242. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3243. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3244. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3245. doc.Save(filePath);
  3246. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3247. return Ok(JsonView(true, "操作成功!", Url));
  3248. }
  3249. else
  3250. {
  3251. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3252. }
  3253. }
  3254. catch (Exception ex)
  3255. {
  3256. return Ok(JsonView(false, ex.Message));
  3257. throw;
  3258. }
  3259. }
  3260. #endregion
  3261. #region 团组经理模块 出入境费用
  3262. ///// <summary>
  3263. ///// 团组模块 - 出入境费用
  3264. ///// </summary>
  3265. ///// <returns></returns>
  3266. //[HttpPost]
  3267. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3268. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3269. //{
  3270. // try
  3271. // {
  3272. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3273. // if (data.Code != 0)
  3274. // {
  3275. // return Ok(JsonView(false, data.Msg));
  3276. // }
  3277. // return Ok(JsonView(true, "查询成功!"));
  3278. // }
  3279. // catch (Exception ex)
  3280. // {
  3281. // return Ok(JsonView(false, ex.Message));
  3282. // throw;
  3283. // }
  3284. //}
  3285. /// <summary>
  3286. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3287. /// </summary>
  3288. /// <returns></returns>
  3289. [HttpPost]
  3290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3291. public async Task<IActionResult> SetDayAndCostAreaChange()
  3292. {
  3293. try
  3294. {
  3295. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3296. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3297. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3298. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3299. foreach (var item in unite) //处理交集数据
  3300. {
  3301. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3302. }
  3303. foreach (var item in merge) //处理差集数据
  3304. {
  3305. int nationalTravelFeeId = 0;
  3306. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3307. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3308. else
  3309. {
  3310. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3311. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3312. }
  3313. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3314. }
  3315. //只更新dayAndCost 的 nationalTravelFeeId;
  3316. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3317. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3318. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3319. }
  3320. catch (Exception ex)
  3321. {
  3322. return Ok(JsonView(false, ex.Message));
  3323. throw;
  3324. }
  3325. }
  3326. /// <summary>
  3327. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3328. /// </summary>
  3329. /// <returns></returns>
  3330. [HttpPost]
  3331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3332. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3333. {
  3334. try
  3335. {
  3336. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3337. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3338. //SetDataInfoView
  3339. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3340. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3341. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3342. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3343. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3344. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3345. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3346. //默认币种显示
  3347. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3348. {
  3349. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3350. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3351. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3352. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3353. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3354. };
  3355. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3356. if (_currencyRate.Count > 0)
  3357. {
  3358. foreach (var item in _currencyInfos)
  3359. {
  3360. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3361. if (rateInfo != null)
  3362. {
  3363. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3364. rate1 *= 1.03M;
  3365. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3366. }
  3367. }
  3368. }
  3369. return Ok(JsonView(true, "查询成功!", new
  3370. {
  3371. GroupNameData = groupNameData.Data,
  3372. CurrencyData = _CurrencyData,
  3373. WordTypeData = _WordTypeData,
  3374. ExcelTypeData = _ExcelTypeData,
  3375. CurrencyInit = _currencyInfos
  3376. }));
  3377. }
  3378. catch (Exception ex)
  3379. {
  3380. return Ok(JsonView(false, ex.Message));
  3381. throw;
  3382. }
  3383. }
  3384. /// <summary>
  3385. /// 团组模块 - 出入境费用
  3386. /// 实时汇率 tips
  3387. /// 签证费用 tips
  3388. /// </summary>
  3389. /// <returns></returns>
  3390. [HttpPost]
  3391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3392. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3393. {
  3394. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3395. //默认币种显示
  3396. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3397. {
  3398. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3399. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3400. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3401. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3402. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3403. };
  3404. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3405. List<dynamic> reteInfos = new List<dynamic>();
  3406. if (_currencyRate.Count > 0)
  3407. {
  3408. foreach (var item in _currencyInfos)
  3409. {
  3410. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3411. if (rateInfo != null)
  3412. {
  3413. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3414. decimal rate1 = item.Rate;
  3415. rate1 *= 1.03M;
  3416. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3417. reteInfos.Add(new
  3418. {
  3419. currCode = item.CurrencyCode,
  3420. currName = item.CurrencyName,
  3421. rate = rate2,
  3422. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3423. });
  3424. }
  3425. }
  3426. }
  3427. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3428. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3429. return Ok(JsonView(true, "查询成功!", new
  3430. {
  3431. //GroupNameData = groupNameData.Data,
  3432. visaData = visaData.Data,
  3433. airData = airData.Data,
  3434. reteInfos = reteInfos
  3435. }));
  3436. }
  3437. /// <summary>
  3438. /// 团组模块 - 出入境费用 - Info
  3439. /// </summary>
  3440. /// <returns></returns>
  3441. [HttpPost]
  3442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3443. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3444. {
  3445. try
  3446. {
  3447. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3448. if (data.Code != 0)
  3449. {
  3450. return Ok(JsonView(false, data.Msg));
  3451. }
  3452. return Ok(JsonView(true, "查询成功!", data.Data));
  3453. }
  3454. catch (Exception ex)
  3455. {
  3456. return Ok(JsonView(false, ex.Message));
  3457. }
  3458. }
  3459. /// <summary>
  3460. /// 团组模块 - 出入境费用 - Add And Update
  3461. /// </summary>
  3462. /// <returns></returns>
  3463. [HttpPost]
  3464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3465. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3466. {
  3467. try
  3468. {
  3469. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3470. if (data.Code != 0)
  3471. {
  3472. return Ok(JsonView(false, data.Msg));
  3473. }
  3474. return Ok(JsonView(true, data.Msg, data.Data));
  3475. }
  3476. catch (Exception ex)
  3477. {
  3478. return Ok(JsonView(false, ex.Message));
  3479. }
  3480. }
  3481. /// <summary>
  3482. /// 团组模块 - 出入境费用 - File downlaod
  3483. /// </summary>
  3484. /// <param name="dto"></param>
  3485. /// <returns></returns>
  3486. [HttpPost]
  3487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3488. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3489. {
  3490. try
  3491. {
  3492. if (dto.DiId < 1)
  3493. {
  3494. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3495. }
  3496. if (dto.ExportType < 1)
  3497. {
  3498. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3499. }
  3500. if (dto.SubTypeId < 1)
  3501. {
  3502. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3503. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3504. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3505. 3 团组成员名单 1 团组成员名单"));
  3506. }
  3507. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3508. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3509. if (_EnterExitCosts == null)
  3510. {
  3511. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3512. }
  3513. //数据源
  3514. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3515. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3516. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3517. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3518. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3519. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3520. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3521. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3522. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3523. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3524. .Select((tcl, dc, cc) => new
  3525. {
  3526. Name = dc.LastName + dc.FirstName,
  3527. Sex = dc.Sex,
  3528. Birthday = dc.BirthDay,
  3529. Company = cc.CompanyFullName,
  3530. Job = dc.Job
  3531. })
  3532. .ToList();
  3533. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3534. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3535. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3536. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3537. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3538. if (dto.ExportType == 1) //明细表
  3539. {
  3540. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3541. {
  3542. //获取模板
  3543. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3544. //载入模板
  3545. Document doc = new Document(tempPath);
  3546. DocumentBuilder builder = new DocumentBuilder(doc);
  3547. //利用键值对存放数据
  3548. Dictionary<string, string> dic = new Dictionary<string, string>();
  3549. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3550. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3551. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3552. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3553. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3554. string row1_1 = "";
  3555. if (_EnterExitCosts.Visa > 0)
  3556. {
  3557. //insidePayTotal += _EnterExitCosts.Visa;
  3558. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3559. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3560. {
  3561. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3562. }
  3563. }
  3564. string row1_2 = "";
  3565. if (_EnterExitCosts.YiMiao > 0)
  3566. {
  3567. //insidePayTotal += _EnterExitCosts.YiMiao;
  3568. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3569. }
  3570. if (_EnterExitCosts.HeSuan > 0)
  3571. {
  3572. //insidePayTotal += _EnterExitCosts.HeSuan;
  3573. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3574. }
  3575. if (_EnterExitCosts.Service > 0)
  3576. {
  3577. //insidePayTotal += _EnterExitCosts.Service;
  3578. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3579. }
  3580. string row1_3 = "";
  3581. if (_EnterExitCosts.Safe > 0)
  3582. {
  3583. //insidePayTotal += _EnterExitCosts.Safe;
  3584. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3585. }
  3586. if (_EnterExitCosts.Ticket > 0)
  3587. {
  3588. //insidePayTotal += _EnterExitCosts.Ticket;
  3589. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3590. }
  3591. string row1 = "";
  3592. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3593. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3594. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3595. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3596. dic.Add("Row1Str", row1);
  3597. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3598. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3599. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3600. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3601. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3602. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3603. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3604. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3605. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3606. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3607. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3608. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3609. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3610. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3611. #region 填充word模板书签内容
  3612. foreach (var key in dic.Keys)
  3613. {
  3614. builder.MoveToBookmark(key);
  3615. builder.Write(dic[key]);
  3616. }
  3617. #endregion
  3618. #region 填充word表格内容
  3619. ////获读取指定表格方法二
  3620. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3621. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3622. for (int i = 0; i < dac1.Count; i++)
  3623. {
  3624. Grp_DayAndCost dac = dac1[i];
  3625. if (dac == null) continue;
  3626. builder.MoveToCell(0, i, 0, 0);
  3627. builder.Write("第" + dac.Days.ToString() + "晚:");
  3628. builder.MoveToCell(0, i, 1, 0);
  3629. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3630. //builder.Write(dac.Place == null ? "" : dac.Place);
  3631. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3632. builder.MoveToCell(0, i, 2, 0);
  3633. builder.Write("费用标准:");
  3634. string curr = "";
  3635. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3636. if (currData != null)
  3637. {
  3638. curr = currData.Name;
  3639. }
  3640. builder.MoveToCell(0, i, 3, 0);
  3641. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3642. builder.MoveToCell(0, i, 4, 0);
  3643. builder.Write("费用小计:");
  3644. builder.MoveToCell(0, i, 5, 0);
  3645. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3646. }
  3647. //删除多余行
  3648. while (table1.Rows.Count > dac1.Count)
  3649. {
  3650. table1.Rows.RemoveAt(dac1.Count);
  3651. }
  3652. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3653. for (int i = 0; i < dac2.Count; i++)
  3654. {
  3655. Grp_DayAndCost dac = dac2[i];
  3656. if (dac == null) continue;
  3657. builder.MoveToCell(1, i, 0, 0);
  3658. builder.Write("第" + dac.Days.ToString() + "天:");
  3659. builder.MoveToCell(1, i, 1, 0);
  3660. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3661. builder.MoveToCell(1, i, 2, 0);
  3662. builder.Write("费用标准:");
  3663. string curr = "";
  3664. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3665. if (currData != null)
  3666. {
  3667. curr = currData.Name;
  3668. }
  3669. builder.MoveToCell(1, i, 3, 0);
  3670. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3671. builder.MoveToCell(1, i, 4, 0);
  3672. builder.Write("费用小计:");
  3673. builder.MoveToCell(1, i, 5, 0);
  3674. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3675. }
  3676. //删除多余行
  3677. while (table2.Rows.Count > dac2.Count)
  3678. {
  3679. table2.Rows.RemoveAt(dac2.Count);
  3680. }
  3681. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3682. for (int i = 0; i < dac3.Count; i++)
  3683. {
  3684. Grp_DayAndCost dac = dac3[i];
  3685. if (dac == null) continue;
  3686. builder.MoveToCell(2, i, 0, 0);
  3687. builder.Write("第" + dac.Days.ToString() + "天:");
  3688. builder.MoveToCell(2, i, 1, 0);
  3689. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3690. builder.MoveToCell(2, i, 2, 0);
  3691. builder.Write("费用标准:");
  3692. string curr = "";
  3693. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3694. if (currData != null)
  3695. {
  3696. curr = currData.Name;
  3697. }
  3698. builder.MoveToCell(2, i, 3, 0);
  3699. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3700. builder.MoveToCell(2, i, 4, 0);
  3701. builder.Write("费用小计:");
  3702. builder.MoveToCell(2, i, 5, 0);
  3703. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3704. }
  3705. //删除多余行
  3706. while (table3.Rows.Count > dac3.Count)
  3707. {
  3708. table3.Rows.RemoveAt(dac3.Count);
  3709. }
  3710. #endregion
  3711. //文件名
  3712. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3713. AsposeHelper.removewatermark_v2180();
  3714. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3715. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3716. return Ok(JsonView(true, "成功", new { Url = url }));
  3717. }
  3718. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3719. {
  3720. //获取模板
  3721. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3722. //载入模板
  3723. Document doc = new Document(tempPath);
  3724. DocumentBuilder builder = new DocumentBuilder(doc);
  3725. Dictionary<string, string> dic = new Dictionary<string, string>();
  3726. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3727. {
  3728. List<string> list = new List<string>();
  3729. try
  3730. {
  3731. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3732. foreach (var item in spilitArr)
  3733. {
  3734. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3735. var depCode = spDotandEmpty[2].Substring(0, 3);
  3736. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3737. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3738. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3739. list.Add(depName);
  3740. list.Add(arrName);
  3741. }
  3742. list = list.Distinct().ToList();
  3743. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3744. }
  3745. catch (Exception)
  3746. {
  3747. dic.Add("ReturnCode", "行程录入不正确!");
  3748. }
  3749. }
  3750. else
  3751. {
  3752. dic.Add("ReturnCode", "未录入行程!");
  3753. }
  3754. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3755. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3756. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3757. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3758. {
  3759. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3760. dic.Add("Day", sp.Days.ToString());
  3761. }
  3762. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3763. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3764. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3765. //dic.Add("Names", Names);
  3766. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3767. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3768. decimal dac1totalPrice = 0.00M;
  3769. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3770. foreach (var dac in dac1)
  3771. {
  3772. if (dac.SubTotal == 0.00M)
  3773. {
  3774. continue;
  3775. }
  3776. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3777. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3778. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3779. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3780. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3781. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3782. builder.Write(currency);//币种
  3783. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3784. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3785. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3786. builder.Write("");//人数
  3787. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3788. builder.Write("");//天数
  3789. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3790. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3791. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3792. decimal rate = 0.00M;
  3793. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3794. builder.Write(rate.ToString("#0.0000"));//汇率
  3795. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3796. decimal rbmPrice = dac.SubTotal;
  3797. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3798. accommodationStartIndex++;
  3799. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3800. }
  3801. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3802. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3803. {
  3804. table1.Rows.RemoveAt(i - 1);
  3805. foodandotherStartIndex--;
  3806. }
  3807. if (dac2.Count == dac3.Count)//国家 币种 金额
  3808. {
  3809. for (int i = 0; i < dac2.Count; i++)
  3810. {
  3811. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3812. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3813. }
  3814. }
  3815. decimal dac2totalPrice = 0.00M;
  3816. foreach (var dac in dac2)
  3817. {
  3818. if (dac.SubTotal == 0)
  3819. {
  3820. continue;
  3821. }
  3822. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3823. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3824. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3825. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3826. builder.Write(currency);//币种
  3827. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3828. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3829. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3830. builder.Write("");//人数
  3831. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3832. builder.Write("");//天数
  3833. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3834. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3835. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3836. decimal rate = 0.00M;
  3837. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3838. builder.Write(rate.ToString("#0.0000"));//汇率
  3839. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3840. decimal rbmPrice = dac.SubTotal;
  3841. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3842. foodandotherStartIndex++;
  3843. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3844. }
  3845. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3846. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3847. {
  3848. table1.Rows.RemoveAt(i - 1);
  3849. }
  3850. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3851. string otherFeeStr = "";
  3852. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3853. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3854. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3855. if (otherFeeStr.Length > 0)
  3856. {
  3857. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3858. otherFeeStr = $"({otherFeeStr})";
  3859. dic.Add("OtherFeeStr", otherFeeStr);
  3860. }
  3861. //总计
  3862. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3863. //国际旅费
  3864. string outsideJJ = "";
  3865. string allPriceJJ = "";
  3866. if (_EnterExitCosts.SumJJC == 1)
  3867. {
  3868. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3869. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3870. }
  3871. string outsideGW = "";
  3872. string allPriceGW = "";
  3873. if (_EnterExitCosts.SumGWC == 1)
  3874. {
  3875. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3876. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3877. }
  3878. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3879. {
  3880. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3881. dic.Add("InTravelPrice", InTravelPriceStr);
  3882. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3883. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3884. }
  3885. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3886. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3887. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3888. foreach (var key in dic.Keys)
  3889. {
  3890. builder.MoveToBookmark(key);
  3891. builder.Write(dic[key]);
  3892. }
  3893. //模板文件名
  3894. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3895. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3896. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3897. return Ok(JsonView(true, "成功", new { Url = url }));
  3898. }
  3899. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3900. {
  3901. //获取模板
  3902. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3903. //载入模板
  3904. WorkbookDesigner designer = new WorkbookDesigner();
  3905. designer.Workbook = new Workbook(tempPath);
  3906. Dictionary<string, string> dic = new Dictionary<string, string>();
  3907. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3908. {
  3909. List<string> list = new List<string>();
  3910. try
  3911. {
  3912. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3913. foreach (var item in spilitArr)
  3914. {
  3915. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3916. var depCode = spDotandEmpty[2].Substring(0, 3);
  3917. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3918. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3919. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3920. list.Add(depName);
  3921. list.Add(arrName);
  3922. }
  3923. list = list.Distinct().ToList();
  3924. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3925. }
  3926. catch (Exception)
  3927. {
  3928. dic.Add("ReturnCode", "行程录入不正确!");
  3929. }
  3930. }
  3931. else
  3932. {
  3933. dic.Add("ReturnCode", "未录入行程!");
  3934. }
  3935. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3936. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3937. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3938. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3939. {
  3940. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3941. dic.Add("Day", sp.Days.ToString());
  3942. }
  3943. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3944. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3945. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3946. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3947. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3948. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3949. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3950. designer.SetDataSource("Name", Names);
  3951. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3952. designer.SetDataSource("Day", dic["Day"] + "天");
  3953. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3954. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3955. int startIndex = 10;
  3956. const int startIndexcopy = 10;
  3957. if (dac2.Count == dac3.Count)//国家 币种 金额
  3958. {
  3959. for (int i = 0; i < dac2.Count; i++)
  3960. {
  3961. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3962. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3963. }
  3964. }
  3965. DataTable dtdac1 = new DataTable();
  3966. List<string> place = new List<string>();
  3967. dtdac1.Columns.AddRange(new DataColumn[] {
  3968. new DataColumn(){ ColumnName = "city"},
  3969. new DataColumn(){ ColumnName = "curr"},
  3970. new DataColumn(){ ColumnName = "criterion"},
  3971. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3972. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3973. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3974. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3975. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3976. });
  3977. DataTable dtdac2 = new DataTable();
  3978. dtdac2.Columns.AddRange(new DataColumn[] {
  3979. new DataColumn(){ ColumnName = "city"},
  3980. new DataColumn(){ ColumnName = "curr"},
  3981. new DataColumn(){ ColumnName = "criterion"},
  3982. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3983. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3984. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3985. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3986. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3987. });
  3988. dtdac1.TableName = "tb1";
  3989. dtdac2.TableName = "tb2";
  3990. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3991. foreach (var item in dac1)
  3992. {
  3993. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  3994. if (place.Contains(item.Place))
  3995. {
  3996. continue;
  3997. }
  3998. DataRow row = dtdac1.NewRow();
  3999. row["city"] = item.Place;
  4000. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4001. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4002. row["curr"] = currency;
  4003. row["rate"] = rate.ToString("#0.0000");
  4004. row["criterion"] = item.Cost.ToString("#0.00");
  4005. row["number"] = 1;
  4006. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4007. //row["costRMB"] = rbmPrice;
  4008. dtdac1.Rows.Add(row);
  4009. place.Add(item.Place);
  4010. }
  4011. place = new List<string>();
  4012. foreach (var item in dac2)
  4013. {
  4014. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4015. if (place.Contains(item.Place))
  4016. {
  4017. continue;
  4018. }
  4019. DataRow row = dtdac2.NewRow();
  4020. row["city"] = item.Place;
  4021. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4022. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4023. row["curr"] = currency;
  4024. row["rate"] = rate.ToString("#0.0000");
  4025. row["criterion"] = item.Cost.ToString("#0.00");
  4026. row["number"] = 1;
  4027. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4028. //row["cost"] = item.SubTotal;
  4029. //row["costRMB"] = rbmPrice;
  4030. dtdac2.Rows.Add(row);
  4031. place.Add(item.Place);
  4032. //dac2totalPrice += rbmPrice;
  4033. }
  4034. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4035. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4036. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4037. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4038. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4039. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4040. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4041. string cellStr = $" 5.其他费用(";
  4042. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4043. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4044. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4045. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4046. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4047. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4048. if (cellStr.Length > 8)
  4049. {
  4050. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4051. }
  4052. cellStr += ")";
  4053. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4054. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4055. decimal pxFee = dac4.Sum(it => it.Cost);
  4056. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4057. string celllastStr1 = "";
  4058. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4059. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4060. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4061. celllastStr1 += $",国际旅费 元";
  4062. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4063. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4064. designer.SetDataSource("cell4Str", cell4Str);
  4065. designer.SetDataSource("cellStr", cellStr);
  4066. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4067. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4068. designer.SetDataSource("celllastStr", celllastStr);
  4069. Workbook wb = designer.Workbook;
  4070. var sheet = wb.Worksheets[0];
  4071. //绑定datatable数据集
  4072. designer.SetDataSource(dtdac1);
  4073. designer.SetDataSource(dtdac2);
  4074. designer.Process();
  4075. var rowStart = dtdac1.Rows.Count;
  4076. while (rowStart > 0)
  4077. {
  4078. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4079. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4080. startIndex++;
  4081. rowStart--;
  4082. }
  4083. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4084. startIndex += 1; //总计行
  4085. rowStart = dtdac2.Rows.Count;
  4086. while (rowStart > 0)
  4087. {
  4088. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4089. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4090. startIndex++;
  4091. rowStart--;
  4092. }
  4093. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4094. wb.CalculateFormula(true);
  4095. //模板文件名
  4096. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4097. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4098. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4099. return Ok(JsonView(true, "成功", new { Url = url }));
  4100. }
  4101. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4102. {
  4103. //获取模板
  4104. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4105. //载入模板
  4106. Document doc = new Document(tempPath);
  4107. DocumentBuilder builder = new DocumentBuilder(doc);
  4108. Dictionary<string, string> dic = new Dictionary<string, string>();
  4109. dic.Add("GroupName", _DelegationInfo.TeamName);
  4110. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4111. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4112. string missionLeaderJob = "";//负责人job
  4113. int groupNumber = 0; //团人数
  4114. if (DeleClientList.Count > 0)
  4115. {
  4116. missionLeader = DeleClientList[0]?.Name ?? "";
  4117. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4118. }
  4119. dic.Add("MissionLeader", missionLeader); //团负责人
  4120. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4121. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4122. #region MyRegion
  4123. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4124. //{
  4125. // List<string> list = new List<string>();
  4126. // try
  4127. // {
  4128. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4129. // foreach (var item in spilitArr)
  4130. // {
  4131. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4132. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4133. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4134. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4135. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4136. // list.Add(depName);
  4137. // list.Add(arrName);
  4138. // }
  4139. // list = list.Distinct().ToList();
  4140. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4141. // }
  4142. // catch (Exception)
  4143. // {
  4144. // dic.Add("ReturnCode", "行程录入不正确!");
  4145. // }
  4146. //}
  4147. //else
  4148. //{
  4149. // dic.Add("ReturnCode", "未录入行程!");
  4150. //}
  4151. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4152. dic.Add("ReturnCode", string.Join("、", countrys));
  4153. #endregion
  4154. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4155. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4156. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4157. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4158. //{
  4159. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4160. // dic.Add("Day", sp.Days.ToString());
  4161. //}
  4162. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4163. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4164. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4165. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4166. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4167. //培训人员名单
  4168. int cultivateRowIndex = 7;
  4169. foreach (var item in DeleClientList)
  4170. {
  4171. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4172. builder.Write(item.Name);
  4173. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4174. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4175. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4176. string birthDay = "";
  4177. if (item.Birthday != null)
  4178. {
  4179. DateTime dt = Convert.ToDateTime(item.Birthday);
  4180. birthDay = $"{dt.Year}.{dt.Month}";
  4181. }
  4182. builder.Write(birthDay);
  4183. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4184. builder.Write(item.Company);
  4185. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4186. builder.Write(item.Job);
  4187. cultivateRowIndex++;
  4188. }
  4189. //删除多余行
  4190. //cultivateRowIndex -= 2;
  4191. int delRows = 10 + 7 - cultivateRowIndex;
  4192. if (delRows > 0)
  4193. {
  4194. for (int i = 0; i < delRows; i++)
  4195. {
  4196. table1.Rows.RemoveAt(cultivateRowIndex);
  4197. //cultivateRowIndex++;
  4198. }
  4199. }
  4200. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4201. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4202. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4203. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4204. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4205. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4206. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4207. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4208. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4209. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4210. //其他费用
  4211. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4212. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4213. //其他费用合计
  4214. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4215. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4216. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4217. //公务舱合计
  4218. //国际旅费
  4219. string outsideJJ = "";
  4220. string allPriceJJ = "";
  4221. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4222. {
  4223. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4224. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4225. }
  4226. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4227. {
  4228. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4229. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4230. }
  4231. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4232. {
  4233. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4234. dic.Add("AirFeeTotal", airFeeTotalStr);
  4235. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4236. dic.Add("FeeTotal", feeTotalStr);
  4237. }
  4238. foreach (var key in dic.Keys)
  4239. {
  4240. builder.MoveToBookmark(key);
  4241. builder.Write(dic[key]);
  4242. }
  4243. //模板文件名
  4244. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4245. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4246. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4247. return Ok(JsonView(true, "成功", new { Url = url }));
  4248. }
  4249. }
  4250. else if (dto.ExportType == 2) //表格
  4251. {
  4252. //利用键值对存放数据
  4253. Dictionary<string, string> dic = new Dictionary<string, string>();
  4254. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4255. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4256. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4257. dic.Add("Day", sp.Days.ToString());
  4258. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4259. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4260. {
  4261. //获取模板
  4262. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4263. //载入模板
  4264. Document doc = new Document(tempPath);
  4265. DocumentBuilder builder = new DocumentBuilder(doc);
  4266. dic.Add("TeamName", _DelegationInfo.TeamName);
  4267. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4268. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4269. string missionLeaderName = "",
  4270. missionLeaderJob = "";
  4271. if (DeleClientList.Count > 0)
  4272. {
  4273. missionLeaderName = DeleClientList[0].Name;
  4274. missionLeaderJob = DeleClientList[0].Job;
  4275. }
  4276. dic.Add("MissionLeaderName", missionLeaderName);
  4277. dic.Add("MissionLeaderJob", missionLeaderJob);
  4278. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4279. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4280. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4281. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4282. int rowCount = 10;//总人数行
  4283. int startRowIndex = 7; //起始行
  4284. for (int i = 0; i < DeleClientList.Count; i++)
  4285. {
  4286. builder.MoveToCell(0, startRowIndex, 0, 0);
  4287. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4288. builder.MoveToCell(0, startRowIndex, 1, 0);
  4289. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4290. builder.Write(sex);//性别
  4291. builder.MoveToCell(0, startRowIndex, 2, 0);
  4292. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4293. builder.MoveToCell(0, startRowIndex, 3, 0);
  4294. builder.Write(DeleClientList[i].Company);//工作单位
  4295. builder.MoveToCell(0, startRowIndex, 4, 0);
  4296. builder.Write(DeleClientList[i].Job);//职务及级别
  4297. builder.MoveToCell(0, startRowIndex, 5, 0);
  4298. builder.Write("");//人员属性
  4299. builder.MoveToCell(0, startRowIndex, 6, 0);
  4300. builder.Write("");//上次出国时间
  4301. startRowIndex++;
  4302. }
  4303. int nullRow = rowCount - DeleClientList.Count;//空行
  4304. for (int i = 0; i < nullRow; i++)
  4305. {
  4306. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4307. }
  4308. foreach (var key in dic.Keys)
  4309. {
  4310. builder.MoveToBookmark(key);
  4311. builder.Write(dic[key]);
  4312. }
  4313. //模板文件名
  4314. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4315. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4316. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4317. return Ok(JsonView(true, "成功", new { Url = url }));
  4318. }
  4319. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4320. {
  4321. //获取模板
  4322. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4323. //载入模板
  4324. Document doc = new Document(tempPath);
  4325. DocumentBuilder builder = new DocumentBuilder(doc);
  4326. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4327. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4328. dic.Add("Names", Names);
  4329. int accommodationRows = 12, foodandotherRows = 12;
  4330. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4331. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4332. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4333. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4334. int accommodationStartIndex = 6;
  4335. decimal dac1totalPrice = 0.00M;
  4336. foreach (var dac in dac1)
  4337. {
  4338. if (dac.SubTotal == 0)
  4339. {
  4340. continue;
  4341. }
  4342. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4343. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4344. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4345. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4346. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4347. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4348. builder.Write(currency);//币种
  4349. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4350. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4351. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4352. builder.Write("");//人数
  4353. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4354. builder.Write("");//天数
  4355. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4356. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4357. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4358. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4359. builder.Write(rate.ToString("#0.0000"));//汇率
  4360. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4361. decimal rbmPrice = rate * dac.SubTotal;
  4362. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4363. accommodationStartIndex++;
  4364. dac1totalPrice += rbmPrice;
  4365. }
  4366. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4367. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4368. builder.Write("小计");
  4369. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4370. builder.Write(dac1totalPrice.ToString("#0.00"));
  4371. accommodationStartIndex++;
  4372. int nullRow = accommodationRows - dac1.Count;
  4373. //删除空行
  4374. //if (nullRow > 0)
  4375. //{
  4376. // int rowIndex = accommodationStartIndex;
  4377. // for (int i = 0; i < nullRow; i++)
  4378. // {
  4379. // Row row = table1.Rows[rowIndex];
  4380. // row.Remove();
  4381. // rowIndex++;
  4382. // }
  4383. //}
  4384. if (dac2.Count == dac3.Count)//国家 币种 金额
  4385. {
  4386. for (int i = 0; i < dac2.Count; i++)
  4387. {
  4388. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4389. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4390. }
  4391. }
  4392. int foodandotherStartIndex = 19;//
  4393. decimal dac2totalPrice = 0.00M;
  4394. foreach (var dac in dac2)
  4395. {
  4396. if (dac.SubTotal == 0)
  4397. {
  4398. continue;
  4399. }
  4400. //foodandotherStartIndex = 12;
  4401. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4402. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4403. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4404. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4405. builder.Write(currency);//币种
  4406. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4407. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4408. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4409. builder.Write("");//人数
  4410. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4411. builder.Write("");//天数
  4412. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4413. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4414. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4415. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4416. builder.Write(rate.ToString("#0.0000"));//汇率
  4417. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4418. decimal rbmPrice = rate * dac.SubTotal;
  4419. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4420. foodandotherStartIndex++;
  4421. dac2totalPrice += rbmPrice;
  4422. }
  4423. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4424. //删除空行
  4425. if (dac2.Count < foodandotherRows)
  4426. {
  4427. //int nullRow = accommodationRows - dac2.Count;
  4428. //while (table2.Rows.Count > dac2.Count)
  4429. //{
  4430. // table2.Rows.RemoveAt(dac2.Count);
  4431. //}
  4432. }
  4433. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4434. string otherFeeStr = "";
  4435. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4436. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4437. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4438. if (otherFeeStr.Length > 0)
  4439. {
  4440. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4441. otherFeeStr = $"({otherFeeStr})";
  4442. dic.Add("OtherFeeStr", otherFeeStr);
  4443. }
  4444. foreach (var key in dic.Keys)
  4445. {
  4446. builder.MoveToBookmark(key);
  4447. builder.Write(dic[key]);
  4448. }
  4449. //模板文件名
  4450. string strFileName = $"省级单位出(境)经费报销单.docx";
  4451. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4452. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4453. return Ok(JsonView(true, "成功", new { Url = url }));
  4454. }
  4455. }
  4456. else if (dto.ExportType == 3)
  4457. {
  4458. if (dto.SubTypeId == 1) //团组成员名单
  4459. {
  4460. if (DeleClientList.Count < 1)
  4461. {
  4462. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4463. }
  4464. //获取模板
  4465. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4466. //载入模板
  4467. Document doc = new Document(tempPath);
  4468. DocumentBuilder builder = new DocumentBuilder(doc);
  4469. //获取word里所有表格
  4470. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4471. //获取所填表格的序数
  4472. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4473. var rowStart = tableOne.Rows[0]; //获取第1行
  4474. //循环赋值
  4475. for (int i = 0; i < DeleClientList.Count; i++)
  4476. {
  4477. builder.MoveToCell(0, i + 1, 0, 0);
  4478. builder.Write(DeleClientList[i].Name);
  4479. builder.MoveToCell(0, i + 1, 1, 0);
  4480. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4481. builder.Write(sex);
  4482. builder.MoveToCell(0, i + 1, 2, 0);
  4483. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4484. builder.MoveToCell(0, i + 1, 3, 0);
  4485. builder.Write(DeleClientList[i].Company);
  4486. builder.MoveToCell(0, i + 1, 4, 0);
  4487. builder.Write(DeleClientList[i].Job);
  4488. }
  4489. //删除多余行
  4490. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4491. {
  4492. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4493. }
  4494. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4495. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4496. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4497. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4498. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4499. return Ok(JsonView(true, "成功", new { Url = url }));
  4500. }
  4501. }
  4502. return Ok(JsonView(false, "操作失败!"));
  4503. }
  4504. catch (Exception ex)
  4505. {
  4506. return Ok(JsonView(false, ex.Message));
  4507. }
  4508. }
  4509. /// <summary>
  4510. /// 获取三公费用标准city
  4511. /// </summary>
  4512. /// <param name="placeData"></param>
  4513. /// <param name="nationalTravelFeeId"></param>
  4514. /// <returns></returns>
  4515. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4516. {
  4517. string _city = string.Empty;
  4518. if (placeData.Count < 1) return _city;
  4519. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4520. if (data == null) return _city;
  4521. string country = data.Country;
  4522. string city = data.City;
  4523. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4524. else _city = city;
  4525. return _city;
  4526. }
  4527. /// <summary>
  4528. /// 团组模块 - 出入境费用 - 明细表导出
  4529. /// </summary>
  4530. /// <returns></returns>
  4531. [HttpPost]
  4532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4533. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4534. {
  4535. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4536. if (data.Code != 0)
  4537. {
  4538. return Ok(JsonView(false, data.Msg));
  4539. }
  4540. return Ok(JsonView(true, data.Msg, data.Data));
  4541. }
  4542. /// <summary>
  4543. /// 团组模块 - 出入境费用 - 一键清空
  4544. /// </summary>
  4545. /// <returns></returns>
  4546. [HttpPost]
  4547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4548. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4549. {
  4550. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4551. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4552. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4553. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4554. if (_view.Code == 0)
  4555. {
  4556. return Ok(JsonView(true, "操作成功"));
  4557. }
  4558. return Ok(JsonView(false, "操作失败"));
  4559. }
  4560. /// <summary>
  4561. /// 团组模块 - 出入境费用 - 子项删除
  4562. /// </summary>
  4563. /// <returns></returns>
  4564. [HttpPost]
  4565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4566. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4567. {
  4568. try
  4569. {
  4570. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4571. if (data.Code != 0)
  4572. {
  4573. return Ok(JsonView(false, data.Msg));
  4574. }
  4575. return Ok(JsonView(true, "操作成功!", data.Data));
  4576. }
  4577. catch (Exception ex)
  4578. {
  4579. return Ok(JsonView(false, ex.Message));
  4580. }
  4581. }
  4582. /// <summary>
  4583. /// 团组模块 - 出入境国家费用标准 List
  4584. /// </summary>
  4585. /// <returns></returns>
  4586. [HttpPost]
  4587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4588. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4589. {
  4590. try
  4591. {
  4592. Stopwatch sw = new Stopwatch();
  4593. sw.Start();
  4594. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4595. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4596. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4597. Where gntf.Isdel = 0");
  4598. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4599. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4600. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4601. //foreach (var item in nationalTravel)
  4602. //{
  4603. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4604. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4605. // if (otherData != null)
  4606. // {
  4607. // cityData.Remove(otherData);
  4608. // cityData.Add(otherData);
  4609. // }
  4610. // nationalTravelFeeData1.Add(new
  4611. // {
  4612. // Country = item.Country,
  4613. // CityData = cityData
  4614. // });
  4615. //}
  4616. sw.Stop();
  4617. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4618. }
  4619. catch (Exception ex)
  4620. {
  4621. return Ok(JsonView(false, ex.Message));
  4622. throw;
  4623. }
  4624. }
  4625. /// <summary>
  4626. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4627. /// </summary>
  4628. /// <returns></returns>
  4629. [HttpPost]
  4630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4631. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4632. {
  4633. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4634. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4635. List<string> countryData = new List<string>();
  4636. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4637. countryData = countryData.Distinct().ToList();
  4638. List<dynamic> dataSource = new List<dynamic>();
  4639. foreach (var item in countryData)
  4640. {
  4641. List<string> cityData1 = new List<string>();
  4642. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4643. var countryData2 = new
  4644. {
  4645. CountryName = item,
  4646. CityData = cityData1
  4647. };
  4648. dataSource.Add(countryData2);
  4649. }
  4650. return Ok(JsonView(true, "查询成功!", dataSource));
  4651. }
  4652. /// <summary>
  4653. /// 团组模块 - 出入境国家费用标准 Page List
  4654. /// </summary>
  4655. /// <returns></returns>
  4656. [HttpPost]
  4657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4658. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4659. {
  4660. int portId = dto.PortType;
  4661. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4662. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4663. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4664. string whereSql = string.Empty;
  4665. if (!string.IsNullOrEmpty(dto.Country))
  4666. {
  4667. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4668. }
  4669. if (!string.IsNullOrEmpty(dto.City))
  4670. {
  4671. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4672. }
  4673. string pageSql = string.Format(@"Select * From (
  4674. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4675. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4676. From Grp_NationalTravelFee gntf
  4677. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4678. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4679. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4680. RefAsync<int> total = 0;
  4681. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4682. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4683. }
  4684. /// <summary>
  4685. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4686. /// </summary>
  4687. /// <returns></returns>
  4688. [HttpPost]
  4689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4690. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4691. {
  4692. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4693. int portId = dto.PortType;
  4694. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4695. string whereSql = string.Empty;
  4696. if (!string.IsNullOrEmpty(dto.Country))
  4697. {
  4698. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4699. }
  4700. if (!string.IsNullOrEmpty(dto.City))
  4701. {
  4702. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4703. }
  4704. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4705. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4706. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4707. From Grp_NationalTravelFee gntf
  4708. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4709. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4710. Where gntf.Isdel = 0 {0} ", whereSql);
  4711. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4712. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4713. }
  4714. /// <summary>
  4715. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4716. /// </summary>
  4717. /// <returns></returns>
  4718. [HttpPost]
  4719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4720. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4721. {
  4722. try
  4723. {
  4724. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4725. if (data.Code != 0)
  4726. {
  4727. return Ok(JsonView(false, data.Msg));
  4728. }
  4729. return Ok(JsonView(true, "操作成功!", data.Data));
  4730. }
  4731. catch (Exception ex)
  4732. {
  4733. return Ok(JsonView(false, ex.Message));
  4734. }
  4735. }
  4736. /// <summary>
  4737. /// 团组模块 - 出入境国家费用标准 - Del
  4738. /// </summary>
  4739. /// <returns></returns>
  4740. [HttpPost]
  4741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4742. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4743. {
  4744. try
  4745. {
  4746. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4747. {
  4748. Id = dto.Id,
  4749. DeleteUserId = dto.DeleteUserId,
  4750. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4751. IsDel = 1
  4752. };
  4753. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4754. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4755. .WhereColumns(it => new { it.Id })
  4756. .ExecuteCommandAsync();
  4757. if (delStatus <= 0)
  4758. {
  4759. return Ok(JsonView(false, "删除失败!"));
  4760. }
  4761. return Ok(JsonView(true, "操作成功!"));
  4762. }
  4763. catch (Exception ex)
  4764. {
  4765. return Ok(JsonView(false, ex.Message));
  4766. }
  4767. }
  4768. #endregion
  4769. #region 签证费用录入
  4770. /// <summary>
  4771. /// 根据diid查询签证费用列表
  4772. /// </summary>
  4773. /// <param name="dto"></param>
  4774. /// <returns></returns>
  4775. [HttpPost]
  4776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4777. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4778. {
  4779. try
  4780. {
  4781. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4782. if (groupData.Code != 0)
  4783. {
  4784. return Ok(JsonView(false, groupData.Msg));
  4785. }
  4786. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4787. }
  4788. catch (Exception ex)
  4789. {
  4790. return Ok(JsonView(false, ex.Message));
  4791. }
  4792. }
  4793. /// <summary>
  4794. /// 根据签证费用Id查询单条数据及c表数据
  4795. /// </summary>
  4796. /// <param name="dto"></param>
  4797. /// <returns></returns>
  4798. [HttpPost]
  4799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4800. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4801. {
  4802. try
  4803. {
  4804. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4805. if (groupData.Code != 0)
  4806. {
  4807. return Ok(JsonView(false, groupData.Msg));
  4808. }
  4809. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4810. }
  4811. catch (Exception ex)
  4812. {
  4813. return Ok(JsonView(false, ex.Message));
  4814. }
  4815. }
  4816. /// <summary>
  4817. /// 签证费用删除
  4818. /// </summary>
  4819. /// <param name="dto"></param>
  4820. /// <returns></returns>
  4821. [HttpPost]
  4822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4823. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4824. {
  4825. _sqlSugar.BeginTran();
  4826. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4827. if (!res)
  4828. {
  4829. _sqlSugar.RollbackTran();
  4830. return Ok(JsonView(false, "删除失败"));
  4831. }
  4832. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4833. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4834. .SetColumns(a => new Grp_CreditCardPayment()
  4835. {
  4836. IsDel = 1,
  4837. DeleteUserId = dto.DeleteUserId,
  4838. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4839. }).ExecuteCommand();
  4840. if (resSub < 1)
  4841. {
  4842. _sqlSugar.RollbackTran();
  4843. return Ok(JsonView(false, "删除失败"));
  4844. }
  4845. _sqlSugar.CommitTran();
  4846. return Ok(JsonView(true, "删除成功!"));
  4847. }
  4848. /// <summary>
  4849. /// 签证费用录入下拉框初始化
  4850. /// </summary>
  4851. /// <returns></returns>
  4852. [HttpPost]
  4853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4854. public async Task<IActionResult> VisaPriceAddSelect()
  4855. {
  4856. try
  4857. {
  4858. //支付方式
  4859. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4860. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4861. //币种
  4862. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4863. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4864. //乘客类型
  4865. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4866. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4867. //卡类型
  4868. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4869. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4870. var data = new
  4871. {
  4872. Payment = _Payment,
  4873. CurrencyList = _CurrencyList,
  4874. PassengerType = _PassengerType,
  4875. BankCard = _BankCard
  4876. };
  4877. return Ok(JsonView(true, "查询成功!", data));
  4878. }
  4879. catch (Exception ex)
  4880. {
  4881. return Ok(JsonView(false, "程序错误!"));
  4882. throw;
  4883. }
  4884. }
  4885. /// <summary>
  4886. /// 签证费用录入操作(Status:1.新增,2.修改)
  4887. /// </summary>
  4888. /// <param name="dto"></param>
  4889. /// <returns></returns>
  4890. [HttpPost]
  4891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4892. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4893. {
  4894. try
  4895. {
  4896. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4897. if (groupData.Code != 0)
  4898. {
  4899. return Ok(JsonView(false, groupData.Msg));
  4900. }
  4901. #region 应用推送
  4902. try
  4903. {
  4904. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4905. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4906. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4907. }
  4908. catch (Exception ex)
  4909. {
  4910. }
  4911. #endregion
  4912. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4913. }
  4914. catch (Exception ex)
  4915. {
  4916. return Ok(JsonView(false, ex.Message));
  4917. }
  4918. }
  4919. #endregion
  4920. #region op费用录入
  4921. /// <summary>
  4922. /// 根据diid查询op费用列表
  4923. /// </summary>
  4924. /// <param name="dto"></param>
  4925. /// <returns></returns>
  4926. [HttpPost]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4929. {
  4930. try
  4931. {
  4932. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4933. if (groupData.Code != 0)
  4934. {
  4935. return Ok(JsonView(false, groupData.Msg));
  4936. }
  4937. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4938. }
  4939. catch (Exception ex)
  4940. {
  4941. return Ok(JsonView(false, ex.Message));
  4942. }
  4943. }
  4944. /// <summary>
  4945. /// 根据op费用Id查询单条数据及c表数据
  4946. /// </summary>
  4947. /// <param name="dto"></param>
  4948. /// <returns></returns>
  4949. [HttpPost]
  4950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4951. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4952. {
  4953. try
  4954. {
  4955. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4956. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4957. var data = new
  4958. {
  4959. CarTouristGuideGround = _groupData,
  4960. CreditCardPayment = _creditCardPayment
  4961. };
  4962. return Ok(JsonView(true, "查询成功!", data));
  4963. }
  4964. catch (Exception ex)
  4965. {
  4966. return Ok(JsonView(false, "程序错误!"));
  4967. }
  4968. }
  4969. /// <summary>
  4970. /// op费用删除
  4971. /// </summary>
  4972. /// <param name="dto"></param>
  4973. /// <returns></returns>
  4974. [HttpPost]
  4975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4976. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4977. {
  4978. try
  4979. {
  4980. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4981. if (!res)
  4982. {
  4983. return Ok(JsonView(false, "删除失败"));
  4984. }
  4985. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4986. {
  4987. IsDel = 1,
  4988. DeleteUserId = dto.DeleteUserId,
  4989. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4990. }).ExecuteCommandAsync();
  4991. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4992. {
  4993. IsDel = 1,
  4994. DeleteUserId = dto.DeleteUserId,
  4995. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4996. }).ExecuteCommandAsync();
  4997. return Ok(JsonView(true, "删除成功!"));
  4998. }
  4999. catch (Exception ex)
  5000. {
  5001. return Ok(JsonView(false, "程序错误!"));
  5002. throw;
  5003. }
  5004. }
  5005. /// <summary>
  5006. /// op费用录入操作(Status:1.新增,2.修改)
  5007. /// </summary>
  5008. /// <param name="dto"></param>
  5009. /// <returns></returns>
  5010. [HttpPost]
  5011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5012. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5013. {
  5014. try
  5015. {
  5016. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5017. if (groupData.Code != 0)
  5018. {
  5019. return Ok(JsonView(false, groupData.Msg));
  5020. }
  5021. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5022. }
  5023. catch (Exception ex)
  5024. {
  5025. return Ok(JsonView(false, ex.Message));
  5026. }
  5027. }
  5028. /// <summary>
  5029. /// 填写费用详细页面初始化绑定
  5030. /// </summary>
  5031. /// <param name="dto"></param>
  5032. /// <returns></returns>
  5033. [HttpPost]
  5034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5035. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5036. {
  5037. try
  5038. {
  5039. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5040. if (groupData.Code != 0)
  5041. {
  5042. return Ok(JsonView(false, groupData.Msg));
  5043. }
  5044. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5045. }
  5046. catch (Exception ex)
  5047. {
  5048. return Ok(JsonView(false, ex.Message));
  5049. }
  5050. }
  5051. /// <summary>
  5052. /// 根据op费用Id查询详细数据
  5053. /// </summary>
  5054. /// <param name="dto"></param>
  5055. /// <returns></returns>
  5056. [HttpPost]
  5057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5058. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5059. {
  5060. try
  5061. {
  5062. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5063. if (groupData.Code != 0)
  5064. {
  5065. return Ok(JsonView(false, groupData.Msg));
  5066. }
  5067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5068. }
  5069. catch (Exception ex)
  5070. {
  5071. return Ok(JsonView(false, ex.Message));
  5072. }
  5073. }
  5074. /// <summary>
  5075. /// OP费用录入填写详情
  5076. /// </summary>
  5077. /// <param name="dto"></param>
  5078. /// <returns></returns>
  5079. [HttpPost]
  5080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5081. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5082. {
  5083. try
  5084. {
  5085. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5086. if (groupData.Code != 0)
  5087. {
  5088. return Ok(JsonView(false, groupData.Msg));
  5089. }
  5090. #region 应用推送
  5091. try
  5092. {
  5093. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5094. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5095. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5096. }
  5097. catch (Exception ex)
  5098. {
  5099. }
  5100. #endregion
  5101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5102. }
  5103. catch (Exception ex)
  5104. {
  5105. return Ok(JsonView(false, ex.Message));
  5106. }
  5107. }
  5108. /// <summary>
  5109. /// 获取三公详细所有城市
  5110. /// </summary>
  5111. /// <returns></returns>
  5112. [HttpGet]
  5113. public IActionResult OpCarCityResult()
  5114. {
  5115. var jw = JsonView(false);
  5116. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5117. {
  5118. x.Id,
  5119. x.Country,
  5120. x.City,
  5121. }).ToList();
  5122. if (data.Count > 0)
  5123. {
  5124. jw = JsonView(true, "获取成功!", data);
  5125. }
  5126. else
  5127. {
  5128. jw.Msg = "城市数据为空!";
  5129. jw.Data = new string[0];
  5130. }
  5131. return Ok(jw);
  5132. }
  5133. /// <summary>
  5134. /// 导出地接费用明细
  5135. /// </summary>
  5136. /// <param name="dto"></param>
  5137. /// <returns></returns>
  5138. [HttpPost]
  5139. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5140. {
  5141. var jw = JsonView(false);
  5142. if (dto.Diid < 1)
  5143. {
  5144. jw.Msg = "请输入正确的diid!";
  5145. return Ok(jw);
  5146. }
  5147. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  5148. if (group == null)
  5149. {
  5150. jw.Msg = "未找到团组信息!";
  5151. return Ok(jw);
  5152. }
  5153. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5154. if (localGuideArr.Count == 0)
  5155. {
  5156. jw.Msg = "该团组暂无地接信息!";
  5157. return Ok(jw);
  5158. }
  5159. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5160. var overspendSoure = new Dictionary<int, int>
  5161. {
  5162. { 91, 982 }, //车
  5163. { 92 , 1059} ,//导游
  5164. { 994 , 1073}, //翻译
  5165. { 988 , 1074 }, //早餐
  5166. { 93 , 1075 }, //午餐
  5167. { 989 , 1076 }, //晚餐
  5168. };
  5169. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5170. foreach (var groupArr in localGroup)
  5171. {
  5172. var keyValue = groupArr.Key;
  5173. if (int.TryParse(keyValue, out int cityid))
  5174. {
  5175. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5176. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5177. }
  5178. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5179. foreach (var item in groupArr)
  5180. {
  5181. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a,b)=> a.SId == b.Id
  5182. ).Where((a,b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a,b)=>
  5183. new Grp_CarTouristGuideGroundReservationsContentExtend
  5184. {
  5185. Count = a.Count,
  5186. CreateTime = a.CreateTime,
  5187. CreateUserId = a.CreateUserId,
  5188. CTGGRId = a.CTGGRId,
  5189. Currency = a.Currency,
  5190. DatePrice = a.DatePrice,
  5191. DeleteTime = a.DeleteTime,
  5192. DeleteUserId = a.DeleteUserId,
  5193. DiId = a.DiId,
  5194. Id = a.Id,
  5195. IsDel = a.IsDel,
  5196. Price = a.Price,
  5197. PriceContent = a.PriceContent,
  5198. Remark = a.Remark,
  5199. SId = a.SId,
  5200. SidName = b.Name,
  5201. Units = a.Units,
  5202. }
  5203. ).ToList();
  5204. if (content.Count > 0)
  5205. {
  5206. contentArr.Add(content);
  5207. }
  5208. }
  5209. //open excel
  5210. //set excel
  5211. //save excel
  5212. try
  5213. {
  5214. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5215. IWorkbook workbook;
  5216. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5217. {
  5218. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5219. }
  5220. else
  5221. {
  5222. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5223. }
  5224. ISheet sheet = workbook.GetSheetAt(0);
  5225. var rowStartIndex = 2;
  5226. var clounmCount = 10;
  5227. var initStyleRow = sheet.GetRow(2);
  5228. var arr = contentArr.SelectMany(x => x).OrderBy(x=>x.SId).ToList();
  5229. //var overspendArrDetail =
  5230. var existsId = new List<CarCompare>();
  5231. var lastElem = arr.Last();
  5232. var thisSid = -1;
  5233. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5234. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5235. {
  5236. Name = "未知币种!",
  5237. Remark = "未知币种!",
  5238. };
  5239. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5240. Action cloneRowFn = () =>
  5241. {
  5242. rowStartIndex++;
  5243. var cloneRow = sheet.CreateRow(rowStartIndex);
  5244. // 复制样式
  5245. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5246. {
  5247. ICell sourceCell = initStyleRow.GetCell(i);
  5248. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5249. // 确保单元格存在样式
  5250. if (sourceCell.CellStyle != null)
  5251. {
  5252. targetCell.CellStyle = sourceCell.CellStyle;
  5253. }
  5254. }
  5255. };
  5256. var mergeRow = () =>
  5257. {
  5258. for (int i = 2; i < sheet.LastRowNum; i++)
  5259. {
  5260. var row = sheet.GetRow(i);
  5261. var cellFirst = row.GetCell(0);
  5262. var thisIndex = i + 1;
  5263. while (thisIndex < sheet.LastRowNum)
  5264. {
  5265. var nextRow = sheet.GetRow(thisIndex);
  5266. var nextCellFirst = nextRow.GetCell(0);
  5267. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5268. {
  5269. thisIndex++;
  5270. }
  5271. else
  5272. {
  5273. break;
  5274. }
  5275. }
  5276. thisIndex--;
  5277. if (thisIndex != i)
  5278. {
  5279. //合并row
  5280. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5281. i, // 起始行索引(0-based)
  5282. thisIndex, // 结束行索引(0-based)
  5283. 0, // 起始列索引(0-based)
  5284. 0 // 结束列索引(0-based)
  5285. );
  5286. sheet.AddMergedRegion(cellRangeAddress);
  5287. i = thisIndex;
  5288. }
  5289. }
  5290. };
  5291. var chaoshiNumber = 0;
  5292. var totalNumber = 0.00M;
  5293. string lastStr = "";
  5294. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5295. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x,b) => new
  5296. {
  5297. b.IsAuditGM,
  5298. x.Id,
  5299. x.Area,
  5300. b.PayPercentage,
  5301. b.PayMoney,
  5302. }).ToList();
  5303. string yesPayment = "", noPayment = "";
  5304. foreach (var item in queryCarArrByCityAndDiid)
  5305. {
  5306. if (item.IsAuditGM == 1)
  5307. {
  5308. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5309. }
  5310. else
  5311. {
  5312. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5313. }
  5314. }
  5315. lastStr = yesPayment + noPayment;
  5316. foreach (var item in arr)
  5317. {
  5318. if (existsId.FirstOrDefault(x=>x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5319. {
  5320. if (thisSid != item.SId)
  5321. {
  5322. if (thisSid == -1)
  5323. {
  5324. thisSid = item.SId;
  5325. }
  5326. else
  5327. {
  5328. //合并小计行
  5329. //创建合并区域的实例
  5330. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5331. rowStartIndex, // 起始行索引(0-based)
  5332. rowStartIndex, // 结束行索引(0-based)
  5333. 0, // 起始列索引(0-based)
  5334. 3 // 结束列索引(0-based)
  5335. );
  5336. sheet.AddMergedRegion(cellRangeAddress);
  5337. var CellStyle = workbook.CreateCellStyle();
  5338. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5339. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5340. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5341. for (int i = 0; i <= clounmCount; i++)
  5342. {
  5343. if (i > 6)
  5344. {
  5345. var CellStyle1 = workbook.CreateCellStyle();
  5346. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5347. IFont Font = workbook.CreateFont(); // 创建字体
  5348. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5349. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5350. CellStyle1.SetFont(Font);
  5351. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5352. }
  5353. else
  5354. {
  5355. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5356. }
  5357. }
  5358. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5359. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x=>x.SId == thisSid).Sum(x=>x.Count * x.Price).ToString("F2"));
  5360. //超时合计
  5361. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5362. //超时数
  5363. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" :chaoshiNumber.ToString());
  5364. //超时合计费用
  5365. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5366. thisSid = item.SId;
  5367. cloneRowFn();
  5368. chaoshiNumber = 0;
  5369. totalNumber = 0;
  5370. }
  5371. }
  5372. IRow row = sheet.GetRow(rowStartIndex);
  5373. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5374. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5375. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null ;
  5376. if (isOpenOverspendSoure)
  5377. {
  5378. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5379. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5380. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5381. }
  5382. for (int i = 0; i <= clounmCount; i++)
  5383. {
  5384. var cell = row.GetCell(i);
  5385. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5386. if (cell == null)
  5387. {
  5388. cell = row.CreateCell(i);
  5389. }
  5390. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5391. fontRed.CloneStyleFrom(cell.CellStyle);
  5392. IFont Font = workbook.CreateFont(); // 创建字体
  5393. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5394. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5395. fontRed.SetFont(Font);
  5396. byte[] rgb = new byte[3] { 255, 242, 204 };
  5397. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5398. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5399. byte[] rgb1 = new byte[3] { 189,215, 238 };
  5400. if (workbook is XSSFWorkbook)
  5401. {
  5402. BackgroundColor255_242_204.FillForegroundColor = 0;
  5403. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5404. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5405. }
  5406. else
  5407. {
  5408. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5409. }
  5410. if (i == 1 || i > 6)
  5411. {
  5412. if (i > 6)
  5413. {
  5414. fontRed.FillForegroundColor = 0;
  5415. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5416. fontRed.FillPattern = FillPattern.SolidForeground;
  5417. }
  5418. cell.CellStyle = fontRed;
  5419. }
  5420. if (i > 2 && i < 7)
  5421. {
  5422. cell.CellStyle = BackgroundColor255_242_204;
  5423. }
  5424. cell.SetCellValue(setCellValue); //写入单元格
  5425. }
  5426. if (overspendSoure.ContainsKey(thisSid)) {
  5427. var overspendId = overspendSoure[thisSid];
  5428. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5429. }
  5430. cloneRowFn();
  5431. existsId.Add(new CarCompare
  5432. {
  5433. DataPrice = item.DatePrice.ObjToDate(),
  5434. Sid = item.SId
  5435. });
  5436. }
  5437. if (item.Equals(lastElem))
  5438. {
  5439. //合并小计行
  5440. //创建合并区域的实例
  5441. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5442. rowStartIndex, // 起始行索引(0-based)
  5443. rowStartIndex, // 结束行索引(0-based)
  5444. 0, // 起始列索引(0-based)
  5445. 3 // 结束列索引(0-based)
  5446. );
  5447. sheet.AddMergedRegion(cellRangeAddress);
  5448. var CellStyle = workbook.CreateCellStyle();
  5449. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5450. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5451. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5452. for (int i = 0; i <= clounmCount; i++)
  5453. {
  5454. if (i > 6)
  5455. {
  5456. var CellStyle1 = workbook.CreateCellStyle();
  5457. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5458. IFont Font = workbook.CreateFont(); // 创建字体
  5459. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5460. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5461. CellStyle1.SetFont(Font);
  5462. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5463. }
  5464. else
  5465. {
  5466. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5467. }
  5468. }
  5469. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5470. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5471. //超时合计
  5472. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5473. //超时数
  5474. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5475. //超时合计费用
  5476. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5477. cloneRowFn();
  5478. // 创建合并区域的实例
  5479. cellRangeAddress = new CellRangeAddress(
  5480. rowStartIndex, // 起始行索引(0-based)
  5481. rowStartIndex, // 结束行索引(0-based)
  5482. 0, // 起始列索引(0-based)
  5483. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5484. );
  5485. // 添加合并区域
  5486. sheet.AddMergedRegion(cellRangeAddress);
  5487. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5488. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5489. }
  5490. }
  5491. mergeRow();
  5492. // 保存修改后的Excel文件到新文件
  5493. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5494. // new FileStream(newFilePath, FileMode.CreateNew)
  5495. using (var stream = new MemoryStream())
  5496. {
  5497. workbook.Write(stream,true);
  5498. stream.Flush();
  5499. stream.Seek(0, SeekOrigin.Begin);
  5500. MemoryStream memoryStream = new MemoryStream();
  5501. stream.CopyTo(memoryStream);
  5502. memoryStream.Seek(0, SeekOrigin.Begin);
  5503. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5504. }
  5505. workbook.Close();
  5506. workbook.Dispose();
  5507. }
  5508. catch (Exception ex)
  5509. {
  5510. jw.Msg = "出现异常!" + ex.Message;
  5511. return Ok(jw);
  5512. }
  5513. }
  5514. if (Zips.Count > 0)
  5515. {
  5516. IOOperatorHelper io = new IOOperatorHelper();
  5517. var byts = io.ConvertZipStream(Zips);
  5518. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5519. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5520. jw = JsonView(true, "success" , new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5521. }
  5522. else
  5523. {
  5524. jw.Msg = "暂无生成文件!";
  5525. }
  5526. return Ok(jw);
  5527. }
  5528. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5529. {
  5530. string outStr = string.Empty;
  5531. switch (i)
  5532. {
  5533. case 0:
  5534. outStr = arr[0].SidName;
  5535. break;
  5536. case 1:
  5537. outStr = arr[0].DataPriceStr;
  5538. break;
  5539. case 2:
  5540. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5541. break;
  5542. case 4:
  5543. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5544. break;
  5545. case 7:
  5546. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5547. {
  5548. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5549. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5550. outStr = arrOverspendSoure.Sum(x=>x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5551. }
  5552. break;
  5553. case 8:
  5554. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5555. {
  5556. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5557. }
  5558. break;
  5559. case 9:
  5560. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5561. {
  5562. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5563. }
  5564. break;
  5565. case 10:
  5566. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5567. {
  5568. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5569. }
  5570. break;
  5571. }
  5572. return outStr;
  5573. }
  5574. #region OP行程单
  5575. /// <summary>
  5576. /// OP行程单初始化
  5577. /// </summary>
  5578. /// <param name="dto"></param>
  5579. /// <returns></returns>
  5580. [HttpPost]
  5581. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5582. {
  5583. var jw = JsonView(false);
  5584. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5585. var group = groupList.First();
  5586. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5587. if (group == null)
  5588. {
  5589. jw.Msg = "暂无团组!";
  5590. return Ok(jw);
  5591. }
  5592. group = groupList.Find(x => x.Id == diid);
  5593. if (group == null)
  5594. {
  5595. jw.Msg = "请输入正确的团组ID!";
  5596. return Ok(jw);
  5597. }
  5598. string city = string.Empty;
  5599. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5600. if (blackCode.Count > 0)
  5601. {
  5602. var black = blackCode.First();
  5603. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5604. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5605. if (blackSp.Length > 0)
  5606. {
  5607. try
  5608. {
  5609. var cityArrCode = new List<string>(20);
  5610. foreach (var item in blackSp)
  5611. {
  5612. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5613. var IndexSelect = itemSp[2];
  5614. var cityArrCodeLength = cityArrCode.Count - 1;
  5615. var startCity = IndexSelect.Substring(0, 3);
  5616. if (cityArrCodeLength > 0)
  5617. {
  5618. var arrEndCity = cityArrCode[cityArrCodeLength];
  5619. if (arrEndCity != startCity)
  5620. {
  5621. cityArrCode.Add(startCity.ToUpper());
  5622. }
  5623. }
  5624. else
  5625. {
  5626. cityArrCode.Add(startCity.ToUpper());
  5627. }
  5628. var endCity = IndexSelect.Substring(3, 3);
  5629. cityArrCode.Add(endCity.ToUpper());
  5630. }
  5631. var cityThree = string.Empty;
  5632. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5633. cityThree = cityThree.TrimEnd(',');
  5634. if (string.IsNullOrWhiteSpace(cityThree))
  5635. {
  5636. throw new
  5637. Exception("error");
  5638. }
  5639. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5640. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5641. foreach (var item in cityArrCode)
  5642. {
  5643. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5644. if (find != null)
  5645. {
  5646. city += find.City + "/";
  5647. }
  5648. else
  5649. {
  5650. city += item + "三字码未收入/";
  5651. }
  5652. }
  5653. city = city.TrimEnd('/');
  5654. }
  5655. catch (Exception e)
  5656. {
  5657. city = "黑屏代码格式不正确!";
  5658. }
  5659. }
  5660. }
  5661. else
  5662. {
  5663. city = "未录入黑屏代码";
  5664. }
  5665. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5666. {
  5667. Date = x.Date,
  5668. Days = x.Days,
  5669. Diffgroup = x.Diffgroup,
  5670. Diid = x.Diid,
  5671. Traffic_First = x.Traffic_First,
  5672. Traffic_Second = x.Traffic_Second,
  5673. Trip = x.Trip,
  5674. WeekDay = x.WeekDay,
  5675. Id = x.Id
  5676. }).ToList();
  5677. jw.Data = new
  5678. {
  5679. groupList = groupList.Select(x => new
  5680. {
  5681. x.Id,
  5682. x.TeamName,
  5683. x.TourCode
  5684. }).ToList(),
  5685. groupInfo = new
  5686. {
  5687. group.VisitDays,
  5688. group.TourCode,
  5689. group.VisitPNumber,
  5690. group.TeamName,
  5691. city
  5692. },
  5693. OpTravelList
  5694. };
  5695. jw.Code = 200;
  5696. jw.Msg = "操作成功!";
  5697. return Ok(jw);
  5698. }
  5699. /// <summary>
  5700. /// 删除团组行程单
  5701. /// </summary>
  5702. /// <returns></returns>
  5703. [HttpPost]
  5704. public IActionResult DelTravel(DelOpTravelDto dto)
  5705. {
  5706. var jw = JsonView(false);
  5707. if (dto.UserId <= 0 || dto.Diid <= 0)
  5708. {
  5709. jw.Msg = "请输入正确的参数!";
  5710. return Ok(jw);
  5711. }
  5712. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5713. .SetColumns(x => new Grp_TravelList
  5714. {
  5715. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5716. DeleteUserId = dto.UserId,
  5717. IsDel = 1,
  5718. }).ExecuteCommand();
  5719. jw = JsonView(true);
  5720. return Ok(jw);
  5721. }
  5722. /// <summary>
  5723. /// 行程单保存
  5724. /// </summary>
  5725. /// <returns></returns>
  5726. [HttpPost]
  5727. public IActionResult TravelSave(TravelSaveDto dto)
  5728. {
  5729. var jw = JsonView(false);
  5730. if (dto.Arr.Count > 0)
  5731. {
  5732. try
  5733. {
  5734. _sqlSugar.BeginTran();
  5735. foreach (var item in dto.Arr)
  5736. {
  5737. if (item.Id == 0)
  5738. {
  5739. throw new Exception("请传入正确的Id");
  5740. }
  5741. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5742. .SetColumns(x => new Grp_TravelList
  5743. {
  5744. Trip = item.Trip
  5745. }).ExecuteCommand();
  5746. }
  5747. _sqlSugar.CommitTran();
  5748. jw = JsonView(true);
  5749. }
  5750. catch (Exception ex)
  5751. {
  5752. _sqlSugar.RollbackTran();
  5753. jw.Msg = "程序异常!" + ex.Message;
  5754. }
  5755. }
  5756. else
  5757. {
  5758. jw.Msg = "请传入正确的参数!";
  5759. }
  5760. return Ok(jw);
  5761. }
  5762. /// <summary>
  5763. /// 导出行程单
  5764. /// </summary>
  5765. /// <param name="dto"></param>
  5766. /// <returns></returns>
  5767. [HttpPost]
  5768. public IActionResult ExportTravel(InitOpTravelDto dto)
  5769. {
  5770. var jw = JsonView(false);
  5771. //数据源
  5772. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5773. int diid = 0;
  5774. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5775. if (Find == null)
  5776. {
  5777. jw.Msg = "请选择正确的团组!";
  5778. return Ok(jw);
  5779. }
  5780. else
  5781. {
  5782. diid = Find.Id;
  5783. }
  5784. DataTable dtBlack = null;
  5785. try
  5786. {
  5787. dtBlack = GetTableByBlackCode(diid);
  5788. }
  5789. catch (Exception)
  5790. {
  5791. jw.Msg = "机票黑屏代码有误!";
  5792. return Ok(jw);
  5793. }
  5794. string CityStr1 = "";
  5795. List<string> countriesList = new List<string>();
  5796. List<string> cityList = new List<string>();
  5797. string countriesIntroduction = "";
  5798. string cityIntroduction = "";
  5799. string timeDifference = "";
  5800. string currExchangeRate = "";
  5801. string txt_itemPrepare = "";
  5802. string txt_specialReminder = "";
  5803. string txt_cGPrecautions = "";
  5804. string txt_yGCG = "";
  5805. string txt_conduct = "";
  5806. string txt_commonEnglish = "";
  5807. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5808. {
  5809. //提示
  5810. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5811. }
  5812. else
  5813. {
  5814. //创建三字码示例
  5815. Res_ThreeCode t = new Res_ThreeCode();
  5816. //城市缓存
  5817. string city = "";
  5818. //出访城市
  5819. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5820. {
  5821. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5822. {
  5823. continue;
  5824. }
  5825. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5826. {
  5827. //出发城市
  5828. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5829. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5830. if (t != null)
  5831. {
  5832. city = city + "/" + t.City;
  5833. }
  5834. else
  5835. {
  5836. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5837. }
  5838. if (i == dtBlack.Rows.Count - 1)
  5839. {
  5840. //抵达城市
  5841. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5842. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5843. if (t != null)
  5844. {
  5845. city = city + "/" + t.City;
  5846. }
  5847. else
  5848. {
  5849. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5850. }
  5851. }
  5852. }
  5853. }
  5854. if (city != "" && city != null)
  5855. {
  5856. string[] cityStr2 = city.Split('/');
  5857. string[] strs = cityStr2.Distinct().ToArray(); ;
  5858. string str = "";
  5859. foreach (var s in strs)
  5860. {
  5861. str += s + "/";
  5862. }
  5863. str = str.TrimStart('/');
  5864. str = str.TrimEnd('/');
  5865. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5866. CityStr1 = city.TrimStart('/');
  5867. }
  5868. // 行程repeater
  5869. if (GetByDiid(diid).Count > 0)
  5870. {
  5871. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5872. }
  5873. else
  5874. {
  5875. //生成该时间段日期
  5876. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5877. if (timeList != null)
  5878. {
  5879. string[] str = new string[timeList.Count];
  5880. //rpData.DataSource = str;
  5881. //rpData.DataBind();
  5882. }
  5883. }
  5884. }
  5885. //创建数据源Table
  5886. DataTable dtSource = new DataTable();
  5887. dtSource.Columns.Add("Days", typeof(string));
  5888. dtSource.Columns.Add("Date", typeof(string));
  5889. dtSource.Columns.Add("Week", typeof(string));
  5890. dtSource.Columns.Add("Traffic", typeof(string));
  5891. dtSource.Columns.Add("Trip", typeof(string));
  5892. //获取数据,放到datatable
  5893. foreach (var item in _travelList)
  5894. {
  5895. DataRow dr = dtSource.NewRow();
  5896. dr["Days"] = item.Days;
  5897. dr["Date"] = item.Date;
  5898. dr["Week"] = item.WeekDay;
  5899. dr["Traffic"] = item.Traffic_First
  5900. + "\r\n"
  5901. + item.Traffic_Second;
  5902. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5903. {
  5904. item.Trip += @"
  5905. 08:00 早餐于酒店;
  5906. 09:00 公务活动;
  5907. 10:30 公务活动;
  5908. 12:00 午餐于当地餐厅;
  5909. 14:00 公务活动;
  5910. 16:00 公务活动;
  5911. 18:00 晚餐于当地餐厅;
  5912. 19:00 入住酒店休息;";
  5913. }
  5914. dr["Trip"] = item.Trip;
  5915. dtSource.Rows.Add(dr);
  5916. }
  5917. //lblTeamName.Text = di.TourCode;
  5918. //lblVisitDays.Text = di.VisitDays.ToString();
  5919. //lblVisitDays2.Text = di.VisitDays.ToString();
  5920. //lblPNumber.Text = di.VisitPNumber.ToString();
  5921. //lblGroup.Text = di.TeamName.ToString();
  5922. Dictionary<string, string> dic = new Dictionary<string, string>();
  5923. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5924. dic.Add("City", CityStr1);
  5925. dic.Add("Days", Find.VisitDays.ToString());
  5926. dic.Add("DeleCode", Find.TourCode);
  5927. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5928. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5929. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5930. if (leader != null && leader.Count > 0)
  5931. {
  5932. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5933. }
  5934. else
  5935. {
  5936. dic.Add("Leader", "");
  5937. }
  5938. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5939. int UserId = 253;
  5940. dic.Add("OP", "");
  5941. dic.Add("OPTel", "");
  5942. //dic.Add("OP", "OP姓名");
  5943. //dic.Add("OPTel", "OP手机号码");
  5944. string countriesStr = "";
  5945. countriesList.ForEach(s => countriesStr += s + "、");
  5946. countriesStr = countriesStr.TrimEnd('、');
  5947. string cityStr = "";
  5948. cityList.ForEach(s => cityStr += s + "、");
  5949. cityStr = cityStr.TrimEnd('、');
  5950. //下方数据
  5951. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5952. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5953. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5954. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5955. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5956. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5957. dic.Add("temperature", "");
  5958. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5959. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5960. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5961. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5962. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5963. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5964. //模板路径
  5965. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5966. //载入模板
  5967. Document doc = null;
  5968. DocumentBuilder builder = null;
  5969. try
  5970. {
  5971. //载入模板
  5972. doc = new Document(tempPath);
  5973. builder = new DocumentBuilder(doc);
  5974. }
  5975. catch (Exception)
  5976. {
  5977. jw.Msg = "模板位置不存在!";
  5978. return Ok(jw);
  5979. }
  5980. foreach (var key in dic.Keys)
  5981. {
  5982. Bookmark bookmark = doc.Range.Bookmarks[key];
  5983. if (bookmark != null)
  5984. {
  5985. builder.MoveToBookmark(key);
  5986. builder.Write(dic[key]);
  5987. }
  5988. }
  5989. //获取word里所有表格
  5990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5991. //获取所填表格的序数
  5992. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5993. try
  5994. {
  5995. //循环赋值
  5996. for (int i = 0; i < dtSource.Rows.Count; i++)
  5997. {
  5998. builder.MoveToCell(0, i + 1, 0, 0);
  5999. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6000. builder.MoveToCell(0, i + 1, 1, 0);
  6001. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6002. builder.MoveToCell(0, i + 1, 2, 0);
  6003. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6004. var trip = dtSource.Rows[i]["Trip"].ToString();
  6005. builder.MoveToCell(0, i + 1, 3, 0);
  6006. builder.Write(trip);
  6007. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6008. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6009. // 获取特定索引的段落
  6010. Paragraph paragraph = (Paragraph)paragraphs[0];
  6011. Run run = paragraph.Runs[0];
  6012. Aspose.Words.Font font = run.Font;
  6013. font.Name = "黑体";
  6014. //设置双休红色
  6015. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6016. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6017. paragraph = (Paragraph)paragraphs[1];
  6018. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6019. {
  6020. run = paragraph.Runs[0];
  6021. font = run.Font;
  6022. font.Color = Color.Red;
  6023. }
  6024. }
  6025. }
  6026. catch (Exception ex)
  6027. {
  6028. }
  6029. //删除多余行
  6030. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6031. {
  6032. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6033. }
  6034. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6035. if (!Directory.Exists(savePath))
  6036. {
  6037. try
  6038. {
  6039. Directory.CreateDirectory(savePath);
  6040. }
  6041. catch
  6042. {
  6043. }
  6044. }
  6045. string path = savePath + Find.TeamName + "出访日程.docx";
  6046. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  6047. try
  6048. {
  6049. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  6050. jw = JsonView(true, "导出成功", ftpPath);
  6051. }
  6052. catch (Exception)
  6053. {
  6054. jw = JsonView(false);
  6055. }
  6056. return Ok(jw);
  6057. }
  6058. /// <summary>
  6059. ///根据机票黑屏代码整理DataTable
  6060. /// </summary>
  6061. /// <param name="diid"></param>
  6062. /// <returns></returns>
  6063. DataTable GetTableByBlackCode(int diid)
  6064. {
  6065. //黑屏代码信息
  6066. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6067. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6068. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6069. DataTable dt = new DataTable();
  6070. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6071. dt.Columns.Add("Date", typeof(string));//起飞日期
  6072. dt.Columns.Add("Three", typeof(string));//三字码
  6073. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6074. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6075. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6076. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6077. dt.Columns.Add("AirModel", typeof(string)); //机型
  6078. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6079. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6080. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6081. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6082. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6083. //判断是否录入黑屏代码
  6084. if (listcode.Count() == 0 || listcode == null)
  6085. {
  6086. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6087. }
  6088. else
  6089. {
  6090. //读取单段黑屏代码
  6091. for (int i = 0; i < listcode.Count; i++)
  6092. {
  6093. //去除序号
  6094. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6095. //去除多余空格,方法一Linq扩展方法
  6096. CodeList = CodeList.Where(str => str != "").ToArray();
  6097. CodeList = CodeList.Where(str => str != " ").ToArray();
  6098. //年
  6099. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6100. //读取单条黑屏代码
  6101. for (int j = 0; j < CodeList.Count(); j++)
  6102. {
  6103. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6104. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6105. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6106. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6107. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6108. //去除多余空格
  6109. Info = Info.Where(str => str != "").ToArray();
  6110. Info = Info.Where(str => str != " ").ToArray();
  6111. //判断黑屏代码是否正确拆分; 理应拆成9段
  6112. if (Info.Count() < 9)
  6113. {
  6114. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6115. }
  6116. else
  6117. {
  6118. try
  6119. {
  6120. //月
  6121. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6122. //日
  6123. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6124. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6125. if (j > 0)
  6126. {
  6127. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6128. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6129. Temp = Temp.Where(str => str != "").ToArray();
  6130. Temp = Temp.Where(str => str != " ").ToArray();
  6131. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6132. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6133. if (month - monthTemp < 0)
  6134. {
  6135. year = year + 1;
  6136. }
  6137. //如果相邻代码三字码不顶真,提醒
  6138. string FootThree = Temp[2].Substring(3, 3);
  6139. string HeadThree = Info[2].Substring(0, 3);
  6140. if (FootThree != HeadThree)
  6141. {
  6142. //DelegationInfoService s = new DelegationInfoService();
  6143. //UsersService us = new UsersService();
  6144. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6145. //77 行程
  6146. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6147. foreach (var temp in list2)
  6148. {
  6149. //if (temp.UId != 21)
  6150. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6151. // "黑屏代码提醒",
  6152. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6153. }
  6154. //85 机票预订
  6155. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6156. foreach (var temp in list6)
  6157. {
  6158. //if (temp.UId != 21)
  6159. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6160. // "黑屏代码提醒",
  6161. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6162. }
  6163. }
  6164. }
  6165. #endregion
  6166. #region 判断到达日期是否需要加1
  6167. if (Info[4].Contains("+"))
  6168. {
  6169. //日期+1
  6170. day = day + 1;
  6171. //判断是否进入下一月
  6172. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6173. {
  6174. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6175. month = month + 1;
  6176. //判断是否进入下一年
  6177. if (month > 12)
  6178. {
  6179. month = month - 12;
  6180. year = year + 1;
  6181. }
  6182. }
  6183. //月份整理格式
  6184. string monthTemp = month.ToString();
  6185. if (month < 10)
  6186. {
  6187. monthTemp = "0" + monthTemp;
  6188. }
  6189. //日期整理格式
  6190. string daytemp = day.ToString();
  6191. if (day < 10)
  6192. {
  6193. daytemp = "0" + daytemp;
  6194. }
  6195. string temp = Info[4].Split('+')[0];
  6196. //添加起飞数据
  6197. dt.Rows.Add(Info[0],
  6198. Info[1],
  6199. Info[2],
  6200. Info[3],
  6201. temp,
  6202. Info[5],
  6203. Info[6],
  6204. Info[7],
  6205. Info[8],
  6206. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6207. year + "-" + monthTemp + "-" + daytemp,
  6208. "",
  6209. "0");
  6210. //加1天,添加到达数据
  6211. dt.Rows.Add(Info[0],
  6212. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6213. Info[2],
  6214. Info[3],
  6215. temp,
  6216. Info[5],
  6217. Info[6],
  6218. Info[7],
  6219. Info[8],
  6220. year + "-" + monthTemp + "-" + daytemp,
  6221. year + "-" + monthTemp + "-" + daytemp,
  6222. "",
  6223. "1");
  6224. }
  6225. else
  6226. {
  6227. //月份整理格式
  6228. string monthTemp = month.ToString();
  6229. if (month < 10)
  6230. {
  6231. monthTemp = "0" + monthTemp;
  6232. }
  6233. //日期整理格式
  6234. string daytemp = day.ToString();
  6235. if (day < 10)
  6236. {
  6237. daytemp = "0" + daytemp;
  6238. }
  6239. dt.Rows.Add(Info[0],
  6240. Info[1],
  6241. Info[2],
  6242. Info[3],
  6243. Info[4],
  6244. Info[5],
  6245. Info[6],
  6246. Info[7],
  6247. Info[8],
  6248. year + "-" + monthTemp + "-" + daytemp,
  6249. year + "-" + monthTemp + "-" + daytemp,
  6250. "",
  6251. "0");
  6252. }
  6253. #endregion
  6254. }
  6255. catch (Exception ex)
  6256. {
  6257. string exstr = ex.Message.ToString();
  6258. }
  6259. }
  6260. }
  6261. //排序
  6262. dt.DefaultView.Sort = "Day asc";
  6263. dt = dt.DefaultView.ToTable();
  6264. }
  6265. }
  6266. return dt;
  6267. }
  6268. /// <summary>
  6269. /// 根据团组编号查询信息
  6270. /// </summary>
  6271. /// <returns>返回空或者对象信息</returns>
  6272. List<Grp_TravelList> GetByDiid(int Diid)
  6273. {
  6274. //调用获取单个对象的方法
  6275. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6276. }
  6277. /// <summary>
  6278. /// 20210816
  6279. /// 根据datatable生成某一时间段的日期
  6280. /// </summary>
  6281. /// <param name="dt">黑屏代码生成的datatable</param>
  6282. /// <returns></returns>
  6283. List<string> GetTimeListByDataTable(DataTable dt)
  6284. {
  6285. if (dt.Rows[0]["Day"].ToString() != "")
  6286. {
  6287. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6288. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6289. List<string> timeList = new List<string>();
  6290. while (datestart <= dateend)
  6291. {
  6292. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6293. datestart = datestart.AddDays(1);
  6294. }
  6295. return timeList;
  6296. }
  6297. return null;
  6298. }
  6299. /// <summary>
  6300. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6301. /// </summary>
  6302. /// <param name="num"></param>
  6303. /// <returns></returns>
  6304. string GetNum(string num)
  6305. {
  6306. string str = "";
  6307. switch (num)
  6308. {
  6309. case "1":
  6310. str = "一";
  6311. break;
  6312. case "2":
  6313. str = "二";
  6314. break;
  6315. case "3":
  6316. str = "三";
  6317. break;
  6318. case "4":
  6319. str = "四";
  6320. break;
  6321. case "5":
  6322. str = "五";
  6323. break;
  6324. case "6":
  6325. str = "六";
  6326. break;
  6327. case "7":
  6328. str = "七";
  6329. break;
  6330. case "8":
  6331. str = "八";
  6332. break;
  6333. case "9":
  6334. str = "九";
  6335. break;
  6336. case "10":
  6337. str = "十";
  6338. break;
  6339. case "11":
  6340. str = "十一";
  6341. break;
  6342. case "12":
  6343. str = "十二";
  6344. break;
  6345. case "一":
  6346. str = "1";
  6347. break;
  6348. case "二":
  6349. str = "2";
  6350. break;
  6351. case "三":
  6352. str = "3";
  6353. break;
  6354. case "四":
  6355. str = "4";
  6356. break;
  6357. case "五":
  6358. str = "5";
  6359. break;
  6360. case "六":
  6361. str = "6";
  6362. break;
  6363. case "七":
  6364. str = "7";
  6365. break;
  6366. case "八":
  6367. str = "8";
  6368. break;
  6369. case "九":
  6370. str = "9";
  6371. break;
  6372. case "十":
  6373. str = "10";
  6374. break;
  6375. case "十一":
  6376. str = "11";
  6377. break;
  6378. case "十二":
  6379. str = "12";
  6380. break;
  6381. }
  6382. return str;
  6383. }
  6384. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6385. {
  6386. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6387. }
  6388. /// <summary>
  6389. /// 根据星期,月份的缩写,转换成数字或者全称
  6390. /// 根据币种中文名称返回币种代码
  6391. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6392. /// 20210903贾文滔
  6393. /// </summary>
  6394. /// <param name="startDate"></param>
  6395. /// <param name="endDate"></param>
  6396. /// <returns></returns>
  6397. string GetLonger(string temp)
  6398. {
  6399. string str = "";
  6400. switch (temp.ToUpper())
  6401. {
  6402. case "美元":
  6403. str = "USD";
  6404. break;
  6405. case "日元":
  6406. str = "JPY";
  6407. break;
  6408. case "英镑":
  6409. str = "GBP";
  6410. break;
  6411. case "欧元":
  6412. str = "EUR";
  6413. break;
  6414. case "港币":
  6415. str = "HKD";
  6416. break;
  6417. case "MO":
  6418. str = "星期一";
  6419. break;
  6420. case "TU":
  6421. str = "星期二";
  6422. break;
  6423. case "WE":
  6424. str = "星期三";
  6425. break;
  6426. case "TH":
  6427. str = "星期四";
  6428. break;
  6429. case "FR":
  6430. str = "星期五";
  6431. break;
  6432. case "SA":
  6433. str = "星期六";
  6434. break;
  6435. case "SU":
  6436. str = "星期天";
  6437. break;
  6438. case "JAN":
  6439. str = "01";
  6440. break;
  6441. case "FEB":
  6442. str = "02";
  6443. break;
  6444. case "MAR":
  6445. str = "03";
  6446. break;
  6447. case "APR":
  6448. str = "04";
  6449. break;
  6450. case "MAY":
  6451. str = "05";
  6452. break;
  6453. case "JUN":
  6454. str = "06";
  6455. break;
  6456. case "JUL":
  6457. str = "07";
  6458. break;
  6459. case "AUG":
  6460. str = "08";
  6461. break;
  6462. case "SEP":
  6463. str = "09";
  6464. break;
  6465. case "OCT":
  6466. str = "10";
  6467. break;
  6468. case "NOV":
  6469. str = "11";
  6470. break;
  6471. case "DEC":
  6472. str = "12";
  6473. break;
  6474. case "MONDAY":
  6475. str = "星期一";
  6476. break;
  6477. case "TUESDAY":
  6478. str = "星期二";
  6479. break;
  6480. case "WEDNESDAY":
  6481. str = "星期三";
  6482. break;
  6483. case "THURSDAY":
  6484. str = "星期四";
  6485. break;
  6486. case "FRIDAY":
  6487. str = "星期五";
  6488. break;
  6489. case "SATURDAY":
  6490. str = "星期六";
  6491. break;
  6492. case "SUNDAY":
  6493. str = "星期日";
  6494. break;
  6495. case "01":
  6496. str = "JAN";
  6497. break;
  6498. case "02":
  6499. str = "FEB";
  6500. break;
  6501. case "03":
  6502. str = "MAR";
  6503. break;
  6504. case "04":
  6505. str = "APR";
  6506. break;
  6507. case "05":
  6508. str = "MAY";
  6509. break;
  6510. case "06":
  6511. str = "JUN";
  6512. break;
  6513. case "07":
  6514. str = "JUL";
  6515. break;
  6516. case "08":
  6517. str = "AUG";
  6518. break;
  6519. case "09":
  6520. str = "SEP";
  6521. break;
  6522. case "10":
  6523. str = "OCT";
  6524. break;
  6525. case "11":
  6526. str = "NOV";
  6527. break;
  6528. case "12":
  6529. str = "DEC";
  6530. break;
  6531. case "2":
  6532. str = "空客A";
  6533. break;
  6534. case "3":
  6535. str = "空客A";
  6536. break;
  6537. case "7":
  6538. str = "波音";
  6539. break;
  6540. }
  6541. return str;
  6542. }
  6543. /// <summary>
  6544. /// 根据月份返回天数
  6545. /// </summary>
  6546. /// <param name="temp"></param>
  6547. /// <returns></returns>
  6548. string GetDaysByMonth(string Month, int year)
  6549. {
  6550. string str = "";
  6551. //判断是否是闰年
  6552. if (DateTime.IsLeapYear(year) == false)
  6553. {
  6554. switch (Month.ToUpper())
  6555. {
  6556. case "JAN":
  6557. str = "31";
  6558. break;
  6559. case "FEB":
  6560. str = "28";
  6561. break;
  6562. case "MAR":
  6563. str = "31";
  6564. break;
  6565. case "APR":
  6566. str = "30";
  6567. break;
  6568. case "MAY":
  6569. str = "31";
  6570. break;
  6571. case "JUN":
  6572. str = "30";
  6573. break;
  6574. case "JUL":
  6575. str = "31";
  6576. break;
  6577. case "AUG":
  6578. str = "31";
  6579. break;
  6580. case "SEP":
  6581. str = "30";
  6582. break;
  6583. case "OCT":
  6584. str = "31";
  6585. break;
  6586. case "NOV":
  6587. str = "30";
  6588. break;
  6589. case "DEC":
  6590. str = "31";
  6591. break;
  6592. case "01":
  6593. str = "31";
  6594. break;
  6595. case "02":
  6596. str = "28";
  6597. break;
  6598. case "03":
  6599. str = "31";
  6600. break;
  6601. case "04":
  6602. str = "30";
  6603. break;
  6604. case "05":
  6605. str = "31";
  6606. break;
  6607. case "06":
  6608. str = "30";
  6609. break;
  6610. case "07":
  6611. str = "31";
  6612. break;
  6613. case "08":
  6614. str = "31";
  6615. break;
  6616. case "09":
  6617. str = "30";
  6618. break;
  6619. case "10":
  6620. str = "31";
  6621. break;
  6622. case "11":
  6623. str = "30";
  6624. break;
  6625. case "12":
  6626. str = "31";
  6627. break;
  6628. }
  6629. }
  6630. else
  6631. {
  6632. switch (Month.ToUpper())
  6633. {
  6634. case "JAN":
  6635. str = "31";
  6636. break;
  6637. case "FEB":
  6638. str = "29";
  6639. break;
  6640. case "MAR":
  6641. str = "31";
  6642. break;
  6643. case "APR":
  6644. str = "30";
  6645. break;
  6646. case "MAY":
  6647. str = "31";
  6648. break;
  6649. case "JUN":
  6650. str = "30";
  6651. break;
  6652. case "JUL":
  6653. str = "31";
  6654. break;
  6655. case "AUG":
  6656. str = "31";
  6657. break;
  6658. case "SEP":
  6659. str = "30";
  6660. break;
  6661. case "OCT":
  6662. str = "31";
  6663. break;
  6664. case "NOV":
  6665. str = "30";
  6666. break;
  6667. case "DEC":
  6668. str = "31";
  6669. break;
  6670. case "01":
  6671. str = "31";
  6672. break;
  6673. case "02":
  6674. str = "29";
  6675. break;
  6676. case "03":
  6677. str = "31";
  6678. break;
  6679. case "04":
  6680. str = "30";
  6681. break;
  6682. case "05":
  6683. str = "31";
  6684. break;
  6685. case "06":
  6686. str = "30";
  6687. break;
  6688. case "07":
  6689. str = "31";
  6690. break;
  6691. case "08":
  6692. str = "31";
  6693. break;
  6694. case "09":
  6695. str = "30";
  6696. break;
  6697. case "10":
  6698. str = "31";
  6699. break;
  6700. case "11":
  6701. str = "30";
  6702. break;
  6703. case "12":
  6704. str = "31";
  6705. break;
  6706. }
  6707. }
  6708. return str;
  6709. }
  6710. #endregion
  6711. #endregion
  6712. #region 团组成本
  6713. /// <summary>
  6714. /// 团组成本数据初始化
  6715. /// </summary>
  6716. /// <param name="dto"></param>
  6717. /// <returns></returns>
  6718. [HttpPost]
  6719. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6720. {
  6721. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6722. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6723. WHEN COUNT(*) >= 0 THEN 'True'
  6724. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6725. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6726. ").ToList(); //团组列表
  6727. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6728. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6729. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6730. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6731. if (groupinfoValue != null)
  6732. {
  6733. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6734. var spArr = new string[1] { countryArr };
  6735. if (countryArr.Contains("|"))
  6736. {
  6737. spArr = countryArr.Split("|");
  6738. }
  6739. else if (countryArr.Contains("、"))
  6740. {
  6741. spArr = countryArr.Split("、");
  6742. }
  6743. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6744. {
  6745. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6746. if (dbQueryCountry != null)
  6747. {
  6748. visaCountryInfoArr.Add(dbQueryCountry);
  6749. }
  6750. }
  6751. }
  6752. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6753. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6754. var create = _GroupCostRepository.
  6755. CreateGroupCostByBlackCode(dto.Diid);
  6756. if (groupCost.Count == 0 && create.Code == 0)
  6757. {
  6758. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6759. }
  6760. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6761. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6762. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6763. groupCostMap = groupCostMap.Select(x =>
  6764. {
  6765. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6766. {
  6767. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6768. }
  6769. return x;
  6770. }).ToList();
  6771. //GroupCostParameter.Add(new
  6772. // Grp_GroupCostParameter());
  6773. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6774. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0 ).Count() > 0;
  6775. return Ok(JsonView(new
  6776. {
  6777. groupList,
  6778. groupInfo,
  6779. groupChecks,
  6780. groupCost = groupCostMap,
  6781. hotelNumber,
  6782. GroupCostParameter = GroupCostParameterMap,
  6783. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6784. {
  6785. x.VisaCountry,
  6786. x.VisaPrice,
  6787. x.Id,
  6788. }).ToList(),
  6789. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6790. blackCodeIsTrue = create.Code == 0 ? true : false,
  6791. hotelIsTrue = hotelIsTrue,
  6792. })) ;
  6793. }
  6794. /// <summary>
  6795. /// 团组成本信息保存
  6796. /// </summary>
  6797. /// <param name="dto"></param>
  6798. /// <returns></returns>
  6799. [HttpPost]
  6800. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6801. {
  6802. if (dto.Diid <= 0 || dto.Userid <= 0)
  6803. {
  6804. return Ok(JsonView(false));
  6805. }
  6806. JsonView jw = null;
  6807. bool isTrue = false;
  6808. #region 复制团组成本
  6809. //if (dto.Diid == 2581)
  6810. //{
  6811. // dto.Diid = 2599;
  6812. // dto.CheckBoxs.ForEach(x =>
  6813. // {
  6814. // x.Diid = 2599;
  6815. // });
  6816. // dto.GroupCosts.ForEach(x =>
  6817. // {
  6818. // x.Diid = 2599;
  6819. // });
  6820. // dto.CostTypeHotelNumbers.ForEach(x =>
  6821. // {
  6822. // x.Diid = 2599;
  6823. // });
  6824. // dto.GroupCostParameters.ForEach(x =>
  6825. // {
  6826. // x.DiId = 2599;
  6827. // });
  6828. //}
  6829. #endregion
  6830. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6831. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6832. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6833. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6834. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6835. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6836. try
  6837. {
  6838. _sqlSugar.BeginTran();
  6839. isTrue = await _GroupCostRepository.
  6840. SaveGroupCostList(Grp_groups, dto.Diid,dto.Userid); //列表
  6841. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6842. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6843. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6844. _sqlSugar.CommitTran();
  6845. jw = JsonView(true, "保存成功!", isTrue);
  6846. }
  6847. catch (Exception)
  6848. {
  6849. _sqlSugar.RollbackTran();
  6850. jw = JsonView(false);
  6851. }
  6852. return Ok(jw);
  6853. }
  6854. /// <summary>
  6855. /// 司兼导数据
  6856. /// </summary>
  6857. /// <param name="dto"></param>
  6858. /// <returns></returns>
  6859. [HttpPost]
  6860. public IActionResult GetCarGuides(CarGuidesDto dto)
  6861. {
  6862. JsonView jw = null;
  6863. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6864. jw = JsonView(true, "获取成功!", Data);
  6865. return Ok(jw);
  6866. }
  6867. /// <summary>
  6868. /// 导游数据
  6869. /// </summary>
  6870. /// <param name="dto"></param>
  6871. /// <returns></returns>
  6872. [HttpPost]
  6873. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6874. {
  6875. JsonView jw = null;
  6876. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6877. // 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
  6878. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6879. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6880. jw = JsonView(true, "获取成功!", Data);
  6881. return Ok(jw);
  6882. }
  6883. /// <summary>
  6884. /// 成本车数据
  6885. /// </summary>
  6886. /// <param name="dto"></param>
  6887. /// <returns></returns>
  6888. [HttpPost]
  6889. public IActionResult GetCarInfo(CarGuidesDto dto)
  6890. {
  6891. JsonView jw = null;
  6892. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6893. jw = JsonView(true, "获取成功!", Data);
  6894. return Ok(jw);
  6895. }
  6896. /// <summary>
  6897. /// 景点数据
  6898. /// </summary>
  6899. /// <param name="dto"></param>
  6900. /// <returns></returns>
  6901. [HttpPost]
  6902. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6903. {
  6904. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6905. return Ok(JsonView(true, "获取成功!", Data));
  6906. }
  6907. /// <summary>
  6908. /// 成本通知
  6909. /// </summary>
  6910. /// <param name="dto"></param>
  6911. /// <returns></returns>
  6912. [HttpPost]
  6913. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6914. {
  6915. if (dto.Diid < 0)
  6916. {
  6917. return Ok(JsonView(false));
  6918. }
  6919. JsonView jw = null;
  6920. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6921. if (GroupCostParameter != null)
  6922. {
  6923. int IsShare = 0;
  6924. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6925. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6926. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6927. string msg = string.Empty;
  6928. if (isTrue)
  6929. {
  6930. if (IsShare == 0)
  6931. {
  6932. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6933. }
  6934. else
  6935. {
  6936. #region 企微通知对应岗位用户
  6937. try
  6938. {
  6939. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6940. }
  6941. catch (Exception ex)
  6942. {
  6943. }
  6944. #endregion
  6945. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6946. }
  6947. jw = JsonView(isTrue, msg, new { IsShare });
  6948. }
  6949. else
  6950. {
  6951. msg = "修改失败!";
  6952. jw = JsonView(isTrue, msg);
  6953. }
  6954. }
  6955. else
  6956. {
  6957. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6958. }
  6959. return Ok(jw);
  6960. }
  6961. /// <summary>
  6962. /// 导出收款账单
  6963. /// </summary>
  6964. /// <param name="dto"></param>
  6965. /// <returns></returns>
  6966. [HttpPost]
  6967. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6968. {
  6969. if (dto.Diid == 0)
  6970. {
  6971. return Ok(JsonView(false, "请传递团组id"));
  6972. }
  6973. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6974. if (deleInfo.Code != 0)
  6975. {
  6976. return Ok(JsonView(false, "团组信息查询失败!"));
  6977. }
  6978. var di = deleInfo.Data as DelegationInfoWebView;
  6979. if (di != null)
  6980. {
  6981. //文件名
  6982. string strFileName = di.TeamName + "-收款账单.doc";
  6983. //获取模板
  6984. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6985. //载入模板
  6986. Document doc = new Document(tmppath);
  6987. decimal TotalPrice = 0.00M;
  6988. string itemStr = string.Empty;
  6989. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6990. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6991. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6992. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6993. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6994. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6995. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6996. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6997. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6998. foreach (var cost in groupCostType)
  6999. {
  7000. var List = cost.ToList();
  7001. if (cost.Key == "A")
  7002. {
  7003. foreach (var ListItem in List)
  7004. {
  7005. if (ListItem.number > 0)
  7006. {
  7007. if (ListItem.code.Contains("TBR"))
  7008. {
  7009. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7010. }
  7011. else
  7012. {
  7013. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7014. }
  7015. TotalPrice += (ListItem.number * ListItem.price);
  7016. }
  7017. }
  7018. }
  7019. else
  7020. {
  7021. itemStr = itemStr.Insert(0, "A段\r\n");
  7022. itemStr += "B段\r\n";
  7023. foreach (var ListItem in List)
  7024. {
  7025. if (ListItem.number > 0)
  7026. {
  7027. if (ListItem.code.Contains("TBR"))
  7028. {
  7029. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7030. }
  7031. else
  7032. {
  7033. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7034. }
  7035. TotalPrice += (ListItem.number * ListItem.price);
  7036. }
  7037. }
  7038. }
  7039. }
  7040. #region 替换Word模板书签内容
  7041. Dictionary<string, string> marks = new Dictionary<string, string>();
  7042. marks.Add("To", di.ClientUnit);//付款方
  7043. marks.Add("ToTel", di.TellPhone);//付款方电话
  7044. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7045. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7046. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7047. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7048. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7049. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  7050. marks.Add("PayItemContent", itemStr);//详细信息
  7051. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7052. #endregion
  7053. ////注
  7054. //if (doc.Range.Bookmarks["Attention"] != null)
  7055. //{
  7056. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7057. // mark.Text = frList[0].Attention;
  7058. //}
  7059. foreach (var item in marks.Keys)
  7060. {
  7061. if (doc.Range.Bookmarks[item] != null)
  7062. {
  7063. Bookmark mark = doc.Range.Bookmarks[item];
  7064. mark.Text = marks[item];
  7065. }
  7066. }
  7067. byte[] bytes = null;
  7068. using (MemoryStream stream = new MemoryStream())
  7069. {
  7070. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7071. bytes = stream.ToArray();
  7072. }
  7073. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7074. return Ok(JsonView(true, "", new
  7075. {
  7076. Data = bytes,
  7077. strFileName,
  7078. }));
  7079. }
  7080. else
  7081. {
  7082. return Ok(JsonView(false, "团组信息不存在!"));
  7083. }
  7084. }
  7085. /// <summary>
  7086. /// 导出团组成本
  7087. /// </summary>
  7088. /// <param name="dto"></param>
  7089. /// <returns></returns>
  7090. [HttpPost]
  7091. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7092. {
  7093. var jw = JsonView(false);
  7094. if (dto.Diid == 0)
  7095. {
  7096. return Ok(JsonView(false, "请传递团组id"));
  7097. }
  7098. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7099. if (deleInfo.Code != 0)
  7100. {
  7101. return Ok(JsonView(false, "团组信息查询失败!"));
  7102. }
  7103. var di = deleInfo.Data as DelegationInfoWebView;
  7104. if (di == null)
  7105. {
  7106. return Ok(JsonView(false, "团组信息查询失败!"));
  7107. }
  7108. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7109. WorkbookDesigner designer = new WorkbookDesigner();
  7110. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7111. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7112. for (int i = 0; i < List_GC.Count; i++)
  7113. {
  7114. GroupCost_Excel gc = new GroupCost_Excel();
  7115. gc.Id = List_GC[i].Id;
  7116. gc.Diid = List_GC[i].Diid.ToString();
  7117. gc.DAY = List_GC[i].DAY;
  7118. string week = "";
  7119. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7120. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7121. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7122. gc.ITIN = List_GC[i].ITIN;
  7123. gc.CarType = List_GC[i].CarType;
  7124. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7125. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7126. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7127. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7128. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7129. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7130. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7131. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7132. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7133. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7134. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7135. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7136. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7137. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7138. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7139. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7140. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7141. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7142. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7143. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7144. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7145. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7146. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7147. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7148. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7149. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7150. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7151. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7152. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7153. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7154. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7155. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7156. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7157. List_GC1.Add(gc);
  7158. }
  7159. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7160. dt.TableName = "TB";
  7161. //报表标题等不用dt的值
  7162. designer.SetDataSource("TeamName", dto.title.TeamName);
  7163. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7164. designer.SetDataSource("Tax", dto.title.Tax);
  7165. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7166. designer.SetDataSource("Currency", dto.title.Currency);
  7167. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7168. designer.SetDataSource("Rate", dto.title.Rate);
  7169. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7170. var Aparams = hotels.Find(x => x.Type == "Default");
  7171. if (Aparams == null)
  7172. {
  7173. return Ok(jw);
  7174. }
  7175. //酒店数量
  7176. var txtSGRNumber = Aparams.SGR.ToString();
  7177. var txtTBRNumber = Aparams.TBR.ToString();
  7178. var txtJSESNumber = Aparams.JSES.ToString();
  7179. var txtSUITENumbe = Aparams.SUITE.ToString();
  7180. if (dto.costType == "B")
  7181. {
  7182. Aparams = hotels.Find(x => x.Type == "A");
  7183. var Bparams = hotels.Find(x => x.Type == "B");
  7184. if (Aparams == null || Bparams == null)
  7185. {
  7186. return Ok(jw);
  7187. }
  7188. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7189. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7190. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7191. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7192. }
  7193. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7194. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7195. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7196. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7197. var ws = designer.Workbook.Worksheets[0];
  7198. int Row = List_GC.Count;
  7199. int startIndex = 11;
  7200. int HideRows = 0;
  7201. List<int> hideRowsList = new List<int>();
  7202. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7203. #region A段left数据
  7204. var left = dto.leftInfo.Find(x => x.Type == "A");
  7205. if (left == null)
  7206. {
  7207. return Ok(jw);
  7208. }
  7209. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7210. if (leftBindData != null)
  7211. {
  7212. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7213. designer.SetDataSource("VisaRS", leftBindData.rs);
  7214. designer.SetDataSource("VisaXS", leftBindData.xs);
  7215. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7216. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7217. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7218. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7219. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7220. }
  7221. else
  7222. {
  7223. hideRowsList.Add(Row + startIndex + HideRows);
  7224. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7225. }
  7226. HideRows += 2;
  7227. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7228. if (leftBindData != null)
  7229. {
  7230. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7231. designer.SetDataSource("BXRS", leftBindData.rs);
  7232. designer.SetDataSource("BXXS", leftBindData.xs);
  7233. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7234. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7235. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7236. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7237. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7238. }
  7239. else
  7240. {
  7241. hideRowsList.Add(Row + startIndex + HideRows);
  7242. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7243. }
  7244. HideRows += 2;
  7245. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7246. if (leftBindData != null)
  7247. {
  7248. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7249. designer.SetDataSource("HSRS", leftBindData.rs);
  7250. designer.SetDataSource("HSXS", leftBindData.xs);
  7251. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7252. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7253. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7254. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7255. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7256. }
  7257. else
  7258. {
  7259. hideRowsList.Add(Row + startIndex + HideRows);
  7260. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7261. }
  7262. HideRows += 2;
  7263. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7264. if (leftBindData != null)
  7265. {
  7266. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7267. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7268. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7269. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7270. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7271. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7272. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7273. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7274. }
  7275. else
  7276. {
  7277. hideRowsList.Add(Row + startIndex + HideRows);
  7278. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7279. }
  7280. HideRows += 2;
  7281. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7282. if (leftBindData != null)
  7283. {
  7284. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7285. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7286. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7287. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7288. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7289. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7290. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7291. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7292. }
  7293. else
  7294. {
  7295. hideRowsList.Add(Row + startIndex + HideRows);
  7296. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7297. }
  7298. HideRows += 2;
  7299. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7300. if (leftBindData != null)
  7301. {
  7302. ////TBR
  7303. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7304. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7305. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7306. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7307. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7308. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7309. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7310. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7311. }
  7312. else
  7313. {
  7314. hideRowsList.Add(Row + startIndex + HideRows);
  7315. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7316. }
  7317. HideRows += 2;
  7318. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7319. if (leftBindData != null)
  7320. {
  7321. ////SGR
  7322. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7323. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7324. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7325. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7326. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7327. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7328. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7329. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7330. }
  7331. else
  7332. {
  7333. hideRowsList.Add(Row + startIndex + HideRows);
  7334. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7335. }
  7336. HideRows += 2;
  7337. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7338. if (leftBindData != null)
  7339. {
  7340. ////JS/ES
  7341. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7342. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7343. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7344. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7345. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7346. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7347. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7348. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7349. }
  7350. else
  7351. {
  7352. hideRowsList.Add(Row + startIndex + HideRows);
  7353. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7354. }
  7355. HideRows += 2;
  7356. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7357. if (leftBindData != null)
  7358. {
  7359. ////SUITE
  7360. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7361. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7362. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7363. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7364. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7365. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7366. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7367. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7368. }
  7369. else
  7370. {
  7371. hideRowsList.Add(Row + startIndex + HideRows);
  7372. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7373. }
  7374. HideRows += 2;
  7375. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7376. if (leftBindData != null)
  7377. {
  7378. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7379. designer.SetDataSource("DJRS", leftBindData.rs);
  7380. designer.SetDataSource("DJXS", leftBindData.xs);
  7381. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7382. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7383. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7384. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7385. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7386. }
  7387. else
  7388. {
  7389. hideRowsList.Add(Row + startIndex + HideRows);
  7390. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7391. }
  7392. HideRows += 2;
  7393. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7394. if (leftBindData != null)
  7395. {
  7396. designer.SetDataSource("HCPCB", leftBindData.cb);
  7397. designer.SetDataSource("HCPRS", leftBindData.rs);
  7398. designer.SetDataSource("HCPXS", leftBindData.xs);
  7399. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7400. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7401. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7402. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7403. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7404. }
  7405. else
  7406. {
  7407. hideRowsList.Add(Row + startIndex + HideRows);
  7408. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7409. }
  7410. HideRows += 2;
  7411. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7412. if (leftBindData != null)
  7413. {
  7414. designer.SetDataSource("CPCB", leftBindData.cb);
  7415. designer.SetDataSource("CPRS", leftBindData.rs);
  7416. designer.SetDataSource("CPXS", leftBindData.xs);
  7417. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7418. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7419. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7420. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7421. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7422. }
  7423. else
  7424. {
  7425. hideRowsList.Add(Row + startIndex + HideRows);
  7426. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7427. }
  7428. HideRows += 2;
  7429. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7430. if (leftBindData != null)
  7431. {
  7432. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7433. designer.SetDataSource("GWRS", leftBindData.rs);
  7434. designer.SetDataSource("GWXS", leftBindData.xs);
  7435. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7436. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7437. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7438. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7439. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7440. }
  7441. else
  7442. {
  7443. hideRowsList.Add(Row + startIndex + HideRows);
  7444. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7445. }
  7446. HideRows += 2;
  7447. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7448. if (leftBindData != null)
  7449. {
  7450. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7451. designer.SetDataSource("LYJRS", leftBindData.rs);
  7452. designer.SetDataSource("LYJXS", leftBindData.xs);
  7453. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7454. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7455. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7456. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7457. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7458. }
  7459. else
  7460. {
  7461. hideRowsList.Add(Row + startIndex + HideRows);
  7462. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7463. }
  7464. #endregion
  7465. #region A段Right信息
  7466. var right = dto.rightInfo.Find(x => x.Type == "A");
  7467. if (right == null)
  7468. {
  7469. return Ok(jw);
  7470. }
  7471. HideRows += 4;
  7472. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7473. if (rightBindData != null)
  7474. {
  7475. //经济舱 + 双人间 TBR
  7476. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7477. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7478. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7479. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7480. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7481. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7482. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7483. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7484. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7485. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7486. }
  7487. else
  7488. {
  7489. hideRowsList.Add(Row + startIndex + HideRows);
  7490. }
  7491. HideRows += 2;
  7492. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7493. if (rightBindData != null)
  7494. {
  7495. //经济舱 + 单人间 SGR
  7496. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7497. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7498. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7499. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7500. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7501. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7502. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7503. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7504. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7505. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7506. }
  7507. else
  7508. {
  7509. hideRowsList.Add(Row + startIndex + HideRows);
  7510. }
  7511. HideRows += 2;
  7512. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7513. if (rightBindData != null)
  7514. {
  7515. //公务舱 + 单人间 SGR
  7516. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7517. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7518. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7519. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7520. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7521. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7522. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7523. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7524. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7525. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7526. }
  7527. else
  7528. {
  7529. hideRowsList.Add(Row + startIndex + HideRows);
  7530. }
  7531. HideRows += 2;
  7532. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7533. if (rightBindData != null)
  7534. {
  7535. //公务舱 + 小套房 JSES
  7536. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7537. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7538. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7539. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7540. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7541. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7542. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7543. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7544. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7545. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7546. }
  7547. else
  7548. {
  7549. hideRowsList.Add(Row + startIndex + HideRows);
  7550. }
  7551. HideRows += 2;
  7552. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7553. if (rightBindData != null)
  7554. {
  7555. //公务舱 + 小套房 JSES
  7556. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7557. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7558. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7559. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7560. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7561. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7562. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7563. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7564. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7565. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7566. }
  7567. else
  7568. {
  7569. hideRowsList.Add(Row + startIndex + HideRows);
  7570. }
  7571. HideRows += 2;
  7572. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7573. if (rightBindData != null)
  7574. {
  7575. //经济舱 + 大套房
  7576. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7577. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7578. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7579. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7580. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7581. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7582. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7583. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7584. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7585. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7586. }
  7587. else
  7588. {
  7589. hideRowsList.Add(Row + startIndex + HideRows);
  7590. }
  7591. #endregion
  7592. #region B段标题清空
  7593. designer.SetDataSource("CostBDRCB", "");
  7594. designer.SetDataSource("CostBRS", "");
  7595. designer.SetDataSource("CostBXS", "");
  7596. designer.SetDataSource("CostBZCB", "");
  7597. designer.SetDataSource("CostBDRBJ", "");
  7598. designer.SetDataSource("CostBZBJ", "");
  7599. designer.SetDataSource("CostBDRLR", "");
  7600. designer.SetDataSource("CostBZLR", "");
  7601. designer.SetDataSource("CostBDRCBOM", "");
  7602. designer.SetDataSource("CostBRSOM", "");
  7603. designer.SetDataSource("CostBZCBOM", "");
  7604. designer.SetDataSource("CostBDRBJOM", "");
  7605. designer.SetDataSource("CostBZBJOM", "");
  7606. designer.SetDataSource("CostBDRLROM", "");
  7607. designer.SetDataSource("CostBZLROM", "");
  7608. #endregion
  7609. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7610. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7611. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7612. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7613. designer.SetDataSource("DJName", "地接(CNY)");
  7614. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7615. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7616. designer.SetDataSource("GWName", "公务(CNY)");
  7617. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7618. designer.SetDataSource("LYJName", "零用金(CNY)");
  7619. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7620. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7621. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7622. designer.SetDataSource("BXName", "保险(CNY)");
  7623. designer.SetDataSource("VisaName", "签证(CNY)");
  7624. #region B段基本数据
  7625. if (dto.costType == "B")
  7626. {
  7627. left = dto.leftInfo.Find(x => x.Type == "B");
  7628. if (left == null)
  7629. {
  7630. return Ok(jw);
  7631. }
  7632. #region B段left数据
  7633. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7634. if (leftBindData != null)
  7635. {
  7636. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7637. designer.SetDataSource("BHSRS", leftBindData.rs);
  7638. designer.SetDataSource("BHSXS", leftBindData.xs);
  7639. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7640. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7641. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7642. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7643. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7644. }
  7645. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7646. if (leftBindData != null)
  7647. {
  7648. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7649. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7650. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7651. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7652. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7653. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7654. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7655. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7656. }
  7657. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7658. if (leftBindData != null)
  7659. {
  7660. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7661. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7662. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7663. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7664. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7665. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7666. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7667. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7668. }
  7669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7670. if (leftBindData != null)
  7671. {
  7672. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7673. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7674. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7675. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7676. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7677. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7678. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7679. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7680. }
  7681. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7682. if (leftBindData != null)
  7683. {
  7684. designer.SetDataSource("BCPCB", leftBindData.cb);
  7685. designer.SetDataSource("BCPRS", leftBindData.rs);
  7686. designer.SetDataSource("BCPXS", leftBindData.xs);
  7687. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7688. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7689. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7690. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7691. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7692. }
  7693. //TBR
  7694. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7695. if (leftBindData != null)
  7696. {
  7697. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7698. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7699. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7700. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7701. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7702. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7703. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7704. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7705. }
  7706. //SGR
  7707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7708. if (leftBindData != null)
  7709. {
  7710. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7711. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7712. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7713. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7714. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7715. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7716. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7717. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7718. }
  7719. //JS/ES
  7720. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7721. if (leftBindData != null)
  7722. {
  7723. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7724. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7725. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7726. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7727. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7728. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7729. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7730. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7731. }
  7732. //SUITE
  7733. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7734. if (leftBindData != null)
  7735. {
  7736. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7737. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7738. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7739. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7740. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7741. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7742. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7743. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7744. }
  7745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7746. if (leftBindData != null)
  7747. {
  7748. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7749. designer.SetDataSource("BDJRS", leftBindData.rs);
  7750. designer.SetDataSource("BDJXS", leftBindData.xs);
  7751. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7752. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7753. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7754. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7755. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7756. }
  7757. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7758. if (leftBindData != null)
  7759. {
  7760. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7761. designer.SetDataSource("BGWRS", leftBindData.rs);
  7762. designer.SetDataSource("BGWXS", leftBindData.xs);
  7763. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7764. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7765. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7766. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7767. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7768. }
  7769. #region 优化方案
  7770. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7771. //excelBind.Add("零用金", new {
  7772. //cb="",
  7773. //rs="",
  7774. //xs ="",
  7775. //zcb = "",
  7776. //});
  7777. #endregion
  7778. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7779. if (leftBindData != null)
  7780. {
  7781. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7782. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7783. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7784. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7785. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7786. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7787. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7788. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7789. }
  7790. #endregion
  7791. #region B段Right信息
  7792. right = dto.rightInfo.Find(x => x.Type == "B");
  7793. if (right == null)
  7794. {
  7795. return Ok(jw);
  7796. }
  7797. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7798. if (rightBindData != null)
  7799. {
  7800. //经济舱 + 双人间 TBR
  7801. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7802. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7803. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7804. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7805. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7806. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7807. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7808. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7809. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7810. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7811. }
  7812. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7813. if (rightBindData != null)
  7814. {
  7815. //经济舱 + 单人间 SGR
  7816. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7817. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7818. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7819. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7820. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7821. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7822. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7823. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7824. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7825. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7826. }
  7827. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7828. if (rightBindData != null)
  7829. {
  7830. //公务舱 + 单人间 SGR
  7831. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7832. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7833. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7834. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7835. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7836. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7837. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7838. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7839. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7840. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7841. }
  7842. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7843. if (rightBindData != null)
  7844. {
  7845. //公务舱 + 小套房 JSES
  7846. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7847. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7848. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7849. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7850. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7851. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7852. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7853. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7854. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7855. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7856. }
  7857. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7858. if (rightBindData != null)
  7859. {
  7860. //公务舱 + 小套房 JSES
  7861. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7862. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7863. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7864. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7865. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7866. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7867. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7868. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7869. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7870. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7871. }
  7872. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7873. if (rightBindData != null)
  7874. {
  7875. //经济舱 + 大套房
  7876. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7877. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7878. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7879. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7880. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7881. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7882. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7883. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7884. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7885. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7886. }
  7887. #endregion
  7888. #region 标题
  7889. designer.SetDataSource("CostBDRCB", "单人成本");
  7890. designer.SetDataSource("CostBRS", "人数");
  7891. designer.SetDataSource("CostBXS", "系数");
  7892. designer.SetDataSource("CostBZCB", "总成本");
  7893. designer.SetDataSource("CostBDRBJ", "单人报价");
  7894. designer.SetDataSource("CostBZBJ", "总报价");
  7895. designer.SetDataSource("CostBDRLR", "单人利润");
  7896. designer.SetDataSource("CostBZLR", "总利润");
  7897. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7898. designer.SetDataSource("CostBRSOM", "人数");
  7899. designer.SetDataSource("CostBZCBOM", "总成本");
  7900. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7901. designer.SetDataSource("CostBZBJOM", "总报价");
  7902. designer.SetDataSource("CostBDRLROM", "单人利润");
  7903. designer.SetDataSource("CostBZLROM", "总利润");
  7904. #endregion
  7905. }
  7906. #endregion
  7907. designer.SetDataSource("TzZCB2", TzZCB2);
  7908. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7909. designer.SetDataSource("TzZLR2", TzZLR2);
  7910. string[] dataSourceKeys = new string[]
  7911. {
  7912. "VF",
  7913. "TGS",
  7914. "TGOF",
  7915. "TGM",
  7916. "TGA",
  7917. "TGTF",
  7918. "TGEF",
  7919. "CFM",
  7920. "CFOF",
  7921. "B",
  7922. "L",
  7923. "D",
  7924. "TBR",
  7925. "SGR",
  7926. "JSES",
  7927. "Suite",
  7928. "TV",
  7929. "1L",
  7930. "IF",
  7931. "EF",
  7932. "BRF",
  7933. "TE",
  7934. "TGT",
  7935. "DRVT",
  7936. "PC",
  7937. "TLF",
  7938. "ECT"
  7939. };
  7940. foreach (var item in dataSourceKeys)
  7941. {
  7942. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7943. if (find != null)
  7944. {
  7945. designer.SetDataSource(item, find.text);
  7946. }
  7947. else
  7948. {
  7949. designer.SetDataSource(item, 0);
  7950. }
  7951. }
  7952. designer.SetDataSource(dt);
  7953. //根据数据源处理生成报表内容
  7954. designer.Process();
  7955. designer.Workbook.Worksheets[0].Name = "清单";
  7956. Worksheet sheet = designer.Workbook.Worksheets[0];
  7957. foreach (var Rowindex in hideRowsList)
  7958. {
  7959. ws.Cells.HideRows(Rowindex, 2);
  7960. }
  7961. byte[] bytes = null;
  7962. string strFileName = di.TeamName + "-团组-成本.xls";
  7963. using (MemoryStream stream = new MemoryStream())
  7964. {
  7965. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7966. bytes = stream.ToArray();
  7967. }
  7968. return Ok(JsonView(true, "", new
  7969. {
  7970. Data = bytes,
  7971. strFileName,
  7972. }));
  7973. }
  7974. /// <summary>
  7975. /// 导出客户报表
  7976. /// </summary>
  7977. /// <returns></returns>
  7978. [HttpPost]
  7979. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7980. {
  7981. var jw = JsonView(false);
  7982. if (dto.Diid == 0)
  7983. {
  7984. return Ok(JsonView(false, "请传递团组id"));
  7985. }
  7986. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7987. if (deleInfo.Code != 0)
  7988. {
  7989. return Ok(JsonView(false, "团组信息查询失败!"));
  7990. }
  7991. var di = deleInfo.Data as DelegationInfoWebView;
  7992. if (di == null)
  7993. {
  7994. return Ok(JsonView(false, "团组信息查询失败!"));
  7995. }
  7996. //文件名
  7997. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7998. //获取模板
  7999. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8000. //载入模板
  8001. Document doc = new Document(tmppath);
  8002. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8003. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8004. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8005. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8006. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8007. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8008. if (AParameter == null)
  8009. {
  8010. return Ok(JsonView(false, "系数不存在!"));
  8011. }
  8012. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8013. , TzAirDesc, TzZCost;
  8014. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8015. = TzAirDesc = TzZCost = string.Empty;
  8016. TzNumber = AParameter.CostTypenumber.ToString();
  8017. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8018. CarGuides1 = dto.CarGuides1;
  8019. Meal = dto.Meal;
  8020. SubsidizedMeals = dto.SubsidizedMeals;
  8021. NightRepair = dto.NightRepair;
  8022. AttractionsTickets = dto.AttractionsTickets;
  8023. MiscellaneousFees = dto.MiscellaneousFees;
  8024. ATip = dto.ATip;
  8025. TzHotelDesc = "";
  8026. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8027. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8028. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8029. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8030. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8031. TzAirDesc = "";
  8032. TzZCost = dto.TzZCost;
  8033. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8034. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8035. var index = 1;
  8036. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8037. foreach (var item in TzHotelDescArr)
  8038. {
  8039. if (AinfoArr != null)
  8040. {
  8041. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8042. if (Ainfo != null)
  8043. {
  8044. if (int.Parse(Ainfo.rs) <= 0)
  8045. {
  8046. continue;
  8047. }
  8048. var hotelText = string.Empty;
  8049. switch (item)
  8050. {
  8051. case "SGR":
  8052. hotelText = "单人间";
  8053. break;
  8054. case "JSES":
  8055. hotelText = "小套房";
  8056. break;
  8057. case "SUITE":
  8058. hotelText = "套房";
  8059. break;
  8060. case "TBR":
  8061. hotelText = "双人间";
  8062. break;
  8063. }
  8064. if (item != "TBR")
  8065. {
  8066. 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";
  8067. }
  8068. else
  8069. {
  8070. 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";
  8071. }
  8072. index++;
  8073. }
  8074. }
  8075. }
  8076. index = 1;
  8077. foreach (var item in TzAirDescArr)
  8078. {
  8079. if (AinfoArr != null)
  8080. {
  8081. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8082. if (Ainfo != null)
  8083. {
  8084. if (int.Parse(Ainfo.rs) <= 0)
  8085. {
  8086. continue;
  8087. }
  8088. 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";
  8089. index++;
  8090. }
  8091. }
  8092. }
  8093. if (dto.costType == "B")
  8094. {
  8095. if (BParameter == null)
  8096. {
  8097. return Ok(JsonView(false, "B段系数不存在!"));
  8098. }
  8099. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8100. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8101. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8102. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8103. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8104. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8105. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8106. foreach (var item in TzHotelDescArr)
  8107. {
  8108. if (AinfoArr != null)
  8109. {
  8110. TzHotelDesc += "B段信息 \r\n";
  8111. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8112. if (Ainfo != null)
  8113. {
  8114. if (int.Parse(Ainfo.rs) <= 0)
  8115. {
  8116. continue;
  8117. }
  8118. var hotelText = string.Empty;
  8119. switch (item)
  8120. {
  8121. case "SGR":
  8122. hotelText = "单人间";
  8123. break;
  8124. case "JSES":
  8125. hotelText = "小套房";
  8126. break;
  8127. case "SUITE":
  8128. hotelText = "套房";
  8129. break;
  8130. case "TBR":
  8131. hotelText = "双人间";
  8132. break;
  8133. }
  8134. if (item != "TBR")
  8135. {
  8136. 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";
  8137. }
  8138. else
  8139. {
  8140. 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";
  8141. }
  8142. index++;
  8143. }
  8144. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8145. }
  8146. }
  8147. index = 1;
  8148. foreach (var item in TzAirDescArr)
  8149. {
  8150. if (AinfoArr != null)
  8151. {
  8152. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8153. if (Ainfo != null)
  8154. {
  8155. if (int.Parse(Ainfo.rs) <= 0)
  8156. {
  8157. continue;
  8158. }
  8159. 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";
  8160. index++;
  8161. }
  8162. }
  8163. }
  8164. }
  8165. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8166. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8167. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8168. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8169. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8170. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8171. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8172. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8173. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8174. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8175. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8176. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8177. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8178. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8179. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8180. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8181. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8182. DickeyValue.Add("TzZCost", TzZCost);
  8183. foreach (var key in DickeyValue.Keys)
  8184. {
  8185. if (doc.Range.Bookmarks[key] != null)
  8186. {
  8187. Bookmark mark = doc.Range.Bookmarks[key];
  8188. mark.Text = DickeyValue[key];
  8189. }
  8190. }
  8191. byte[] bytes = null;
  8192. string strFileName = di.TeamName + "-客户报价.doc";
  8193. using (MemoryStream stream = new MemoryStream())
  8194. {
  8195. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8196. bytes = stream.ToArray();
  8197. }
  8198. return Ok(JsonView(true, "", new
  8199. {
  8200. Data = bytes,
  8201. strFileName,
  8202. }));
  8203. }
  8204. /// <summary>
  8205. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8206. /// </summary>
  8207. /// <param name="dto"></param>
  8208. /// <returns></returns>
  8209. [HttpPost]
  8210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8211. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8212. {
  8213. try
  8214. {
  8215. #region 参数验证
  8216. if (dto.DiId < 0)
  8217. {
  8218. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8219. }
  8220. List<int> cTableIds = new List<int>() {
  8221. 76 ,//酒店预订
  8222. 77 ,//行程
  8223. 79 ,//车/导游地接
  8224. 80 ,//签证
  8225. 81 ,//邀请/公务活
  8226. 82 ,//团组客户保险
  8227. 85 ,//机票预订
  8228. 98 ,//其他款项
  8229. 285 ,//收款退还
  8230. 751 ,//酒店早餐
  8231. 1015 // 超支费用
  8232. };
  8233. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8234. {
  8235. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8236. }
  8237. #endregion
  8238. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8239. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8240. if (_GroupCostParameters.Count <= 0)
  8241. {
  8242. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8243. }
  8244. if (_GroupCostParameters[0].IsShare == 0)
  8245. {
  8246. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8247. }
  8248. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8249. //处理date为空问题
  8250. if (_GroupCosts.Count > 0)
  8251. {
  8252. for (int i = 0; i < _GroupCosts.Count; i++)
  8253. {
  8254. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8255. {
  8256. if (i > 0)
  8257. {
  8258. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8259. }
  8260. }
  8261. }
  8262. }
  8263. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8264. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8265. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8266. string currCode = "";
  8267. #region currCode 验证
  8268. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8269. if (isInt)
  8270. {
  8271. var currData = currDatas.Find(it => it.Id == intCurrency);
  8272. if (currData != null)
  8273. {
  8274. currCode = currData.Name;
  8275. }
  8276. }
  8277. else
  8278. {
  8279. currCode = _GroupCostParameters[0].Currency.Trim();
  8280. }
  8281. #endregion
  8282. //op,酒店单段模式存储
  8283. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8284. {
  8285. CurrencyCode = currCode,
  8286. Rate = _GroupCostParameters[0].Rate,
  8287. CostType = _GroupCostParameters[0].CostType,
  8288. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8289. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8290. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8291. };
  8292. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8293. if (_GroupCostParameters.Count == 2)
  8294. {
  8295. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8296. }
  8297. foreach (var item in _GroupCostParameters)
  8298. {
  8299. decimal _rate = 1;
  8300. decimal _rate1 = item.Rate;
  8301. decimal _scale = 1;
  8302. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8303. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8304. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8305. //if (userInfo != null)
  8306. //{
  8307. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8308. // {
  8309. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8310. // {
  8311. // _scale = 1.00M;
  8312. // }
  8313. // }
  8314. //}
  8315. #endregion
  8316. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8317. {
  8318. CurrencyCode = currCode,
  8319. Rate = _rate1,
  8320. CostType = item.CostType,
  8321. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8322. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8323. CostTypeNumber = item.CostTypenumber
  8324. };
  8325. if (_GroupCostParameters.Count > 1)
  8326. {
  8327. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8328. }
  8329. else
  8330. {
  8331. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8332. }
  8333. if (dto.CTable == 79)//
  8334. {
  8335. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8336. modulePromptInfo.TotalCost = item.DJCB;
  8337. }
  8338. List<string> costTypes = new List<string>() { "A", "B" };
  8339. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8340. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8341. if (_GroupCostsDuplicates.Count() == 1)
  8342. {
  8343. _GroupCostsTypeData = _GroupCosts;
  8344. }
  8345. else
  8346. {
  8347. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8348. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8349. }
  8350. /*
  8351. * 76 酒店预订
  8352. * 77 行程
  8353. * 79 车/导游地接
  8354. * 80 签证
  8355. * 81 邀请/公务活动
  8356. * 82 团组客户保险
  8357. * 85 机票预订
  8358. * 98 其他款项
  8359. * 285 收款退还
  8360. * 751 酒店早餐
  8361. * 1015 超支费用
  8362. */
  8363. switch (dto.CTable)
  8364. {
  8365. case 76: // 酒店预订
  8366. _ModuleSubPromptInfo.AddRange(
  8367. _GroupCostsTypeData.Select(it => new
  8368. {
  8369. it.DAY,
  8370. it.Date,
  8371. it.ACCON,
  8372. it.ITIN,
  8373. it.SGR,
  8374. it.TBR,
  8375. it.JS_ES,
  8376. it.Suite
  8377. })
  8378. );
  8379. break;
  8380. case 79: // 车/导游地接
  8381. _ModuleSubPromptInfo.AddRange(
  8382. _GroupCostsTypeData.Select(it => new
  8383. {
  8384. Date = it.Date, //日期
  8385. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8386. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8387. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8388. TicketFee = it.EF * _rate * _scale, //门票费
  8389. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8390. AirportTransferFee = 0.00M,
  8391. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8392. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8393. LeadersFee = it.TLF * _rate * _scale, //领队费
  8394. CarFee1 = it.CarCost * _rate * _scale,
  8395. CarType = it.CarType, //车型
  8396. SpentCash = it.PC * _rate * _scale, //零用金
  8397. })
  8398. );
  8399. break;
  8400. case 85: // 机票
  8401. List<dynamic> datas = new List<dynamic>();
  8402. datas.Add(
  8403. new
  8404. {
  8405. AirType = "经济舱",
  8406. AirNum = item.JJCRS,
  8407. AirDRCB = item.JJCCB,
  8408. AirZCB = (item.JJCRS * item.JJCCB)
  8409. }
  8410. );
  8411. datas.Add(
  8412. new
  8413. {
  8414. AirType = "公务舱",
  8415. AirNum = item.GWCRS,
  8416. AirDRCB = item.GWCCB,
  8417. AirZCB = (item.GWCRS * item.GWCCB)
  8418. }
  8419. );
  8420. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8421. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8422. modulePromptInfo.Data = new {
  8423. airFeeData = datas,
  8424. airInitData = initDatas
  8425. };
  8426. _ModulePromptInfos.Add(modulePromptInfo);
  8427. break;
  8428. default:
  8429. break;
  8430. }
  8431. }
  8432. if (dto.CTable != 85)
  8433. {
  8434. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8435. _ModulePromptInfos.Add(_ModulePromptInfo);
  8436. }
  8437. _view.ModulePromptInfos = _ModulePromptInfos;
  8438. return Ok(JsonView(true, "操作成功!", _view));
  8439. }
  8440. catch (Exception ex)
  8441. {
  8442. return Ok(JsonView(false, ex.Message));
  8443. }
  8444. }
  8445. /// <summary>
  8446. /// 根据黑屏代码重新生成行程
  8447. /// </summary>
  8448. /// <param name="dto"></param>
  8449. /// <returns></returns>
  8450. [HttpPost]
  8451. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8452. {
  8453. var jw = JsonView(false);
  8454. var Create =_GroupCostRepository.
  8455. CreateGroupCostByBlackCode(dto.Diid);
  8456. jw.Msg = Create.Msg;
  8457. if (Create.Code == 0)
  8458. {
  8459. jw.Code = 200;
  8460. jw.Data = new
  8461. {
  8462. groupCost = Create.Data,
  8463. blackCodeIsTrue = true
  8464. };
  8465. }
  8466. else
  8467. {
  8468. jw.Code = 400;
  8469. jw.Data = new
  8470. {
  8471. groupCost = Create.Data,
  8472. blackCodeIsTrue = false,
  8473. };
  8474. }
  8475. return Ok(jw);
  8476. }
  8477. /// <summary>
  8478. /// 成本获取OP历史车费用
  8479. /// </summary>
  8480. /// <param name="dto"></param>
  8481. /// <returns></returns>
  8482. [HttpPost]
  8483. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8484. {
  8485. var jw = JsonView(false);
  8486. try
  8487. {
  8488. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8489. //获取现有所有车的数据
  8490. if (!dto.Param.IsNullOrWhiteSpace())
  8491. {
  8492. string sql = $@"
  8493. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8494. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8495. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8496. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  8497. AND gctggr.ServiceEndTime is not NULL
  8498. ORDER by gctggrc.id DESC
  8499. ";
  8500. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8501. var numeberResult = await Task.Run(() =>
  8502. {
  8503. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8504. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8505. return numberArr;
  8506. });
  8507. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8508. foreach (var item in numeberResult)
  8509. {
  8510. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8511. {
  8512. Country = "数据异常!",
  8513. City = string.Empty,
  8514. };
  8515. item.Area = find.Country + " " + find.City;
  8516. }
  8517. dbResult.AddRange(numeberResult);
  8518. if (dto.Param.Contains("、"))
  8519. {
  8520. var sp = dto.Param.Split("、");
  8521. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8522. .Where(x =>
  8523. {
  8524. return System.Array.Exists(sp, e =>
  8525. {
  8526. bool where = false;
  8527. if (x.Area != null)
  8528. {
  8529. where = x.Area.Contains(e);
  8530. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8531. {
  8532. return false;
  8533. }
  8534. }
  8535. if (x.PriceName != null && !where)
  8536. {
  8537. where = x.PriceName.Contains(e);
  8538. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8539. {
  8540. return false;
  8541. }
  8542. }
  8543. return where;
  8544. });
  8545. }).ToList();
  8546. }
  8547. else
  8548. {
  8549. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8550. .Where(x =>
  8551. {
  8552. bool where = false;
  8553. if (x.Area != null)
  8554. {
  8555. where = x.Area.Contains(dto.Param);
  8556. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8557. {
  8558. return false;
  8559. }
  8560. }
  8561. if (x.PriceName != null && !where)
  8562. {
  8563. where = x.PriceName.Contains(dto.Param);
  8564. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8565. {
  8566. return false;
  8567. }
  8568. }
  8569. return where;
  8570. }
  8571. )
  8572. .ToList();
  8573. }
  8574. }
  8575. var view = dbResult.Select(x => {
  8576. decimal dp = 0.00M;
  8577. var startB = DateTime.TryParse(x.Start.ToString(),out DateTime startD);
  8578. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8579. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8580. {
  8581. if (startB && endB)
  8582. {
  8583. var timesp = endD.Subtract(startD);
  8584. if ((timesp.Days + 1) != 0 )
  8585. {
  8586. dp = x.Price / (timesp.Days + 1);
  8587. }
  8588. }
  8589. }
  8590. else
  8591. {
  8592. dp = x.Price;
  8593. }
  8594. return new
  8595. {
  8596. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8597. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8598. x.Area,
  8599. x.id,
  8600. price = x.Price.ToString("F2"),
  8601. x.PriceName,
  8602. x.PriceContent,
  8603. x.TeamName,
  8604. x.DatePrice,
  8605. dayPrice = dp.ToString("F2"),
  8606. };
  8607. }).OrderByDescending(x=>x.id).ToList();
  8608. jw = JsonView(true, "获取成功!", view);
  8609. }
  8610. catch (Exception e)
  8611. {
  8612. jw = JsonView(false,e.Message);
  8613. }
  8614. return Ok(jw);
  8615. }
  8616. #endregion
  8617. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8618. /// <summary>
  8619. /// 酒店预订
  8620. /// 酒店费用列表 根据团组Id查询
  8621. /// </summary>
  8622. /// <param name="_dto"></param>
  8623. /// <returns></returns>
  8624. [HttpPost]
  8625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8626. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8627. {
  8628. #region 参数验证
  8629. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8630. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8631. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8632. #region 团组操作权限验证 76 酒店预定模块
  8633. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8634. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8635. #endregion
  8636. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8637. #region 页面操作权限验证
  8638. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8639. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8640. #endregion
  8641. #endregion
  8642. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8643. }
  8644. /// <summary>
  8645. /// 酒店预订
  8646. /// 基础数据
  8647. /// </summary>
  8648. /// <param name="_dto"></param>
  8649. /// <returns></returns>
  8650. [HttpPost]
  8651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8652. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8653. {
  8654. #region 参数验证
  8655. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8656. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8657. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8658. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8659. #region 页面操作权限验证
  8660. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8661. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8662. #endregion
  8663. #region 团组操作权限验证 76 酒店预定模块
  8664. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8665. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8666. #endregion
  8667. #endregion
  8668. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8669. }
  8670. /// <summary>
  8671. /// 酒店预订
  8672. /// 创建 入住卷号码
  8673. /// </summary>
  8674. /// <param name="_dto"></param>
  8675. /// <returns></returns>
  8676. [HttpPost]
  8677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8678. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8679. {
  8680. try
  8681. {
  8682. #region 参数验证
  8683. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8684. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8685. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8687. #region 页面操作权限验证
  8688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8690. #endregion
  8691. #region 团组操作权限验证 76 酒店预定模块
  8692. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8693. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8694. #endregion
  8695. #endregion
  8696. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8697. if (data.Code != 0)
  8698. {
  8699. return Ok(JsonView(false, data.Msg));
  8700. }
  8701. return Ok(JsonView(true, data.Msg, data.Data));
  8702. }
  8703. catch (Exception ex)
  8704. {
  8705. return Ok(JsonView(false, ex.Message));
  8706. }
  8707. }
  8708. /// <summary>
  8709. /// 酒店预订
  8710. /// 详情
  8711. /// </summary>
  8712. /// <param name="_dto"></param>
  8713. /// <returns></returns>
  8714. [HttpPost]
  8715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8716. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8717. {
  8718. #region 参数验证
  8719. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8720. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8721. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8722. #region 团组操作权限验证 76 酒店预定模块
  8723. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8724. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8725. #endregion
  8726. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8727. #region 页面操作权限验证
  8728. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8729. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8730. #endregion
  8731. #endregion
  8732. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8733. }
  8734. /// <summary>
  8735. /// 酒店预订
  8736. /// Add Or Edit
  8737. /// </summary>
  8738. /// <param name="_dto"></param>
  8739. /// <returns></returns>
  8740. [HttpPost]
  8741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8742. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8743. {
  8744. #region 参数验证
  8745. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8746. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8747. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8748. #region 团组操作权限验证 76 酒店预定模块
  8749. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8750. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8751. #endregion
  8752. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8753. #region 页面操作权限验证
  8754. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8755. if (_dto.Id == 0) // Add
  8756. {
  8757. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8758. }
  8759. else if (_dto.Id > 1) // Edit
  8760. {
  8761. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8762. }else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8763. #endregion
  8764. #endregion
  8765. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8766. if (_view.Code != 200)
  8767. {
  8768. return Ok(_view);
  8769. }
  8770. #region 应用推送
  8771. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8772. //try
  8773. //{
  8774. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8775. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8776. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8777. //}
  8778. //catch (Exception ex)
  8779. //{
  8780. //}
  8781. #endregion
  8782. return Ok(_view);
  8783. }
  8784. /// <summary>
  8785. /// 酒店预订
  8786. /// Del
  8787. /// </summary>
  8788. /// <param name="_dto"></param>
  8789. /// <returns></returns>
  8790. [HttpPost]
  8791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8792. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8793. {
  8794. #region 参数验证
  8795. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8796. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8797. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8798. #region 团组操作权限验证 76 酒店预定模块
  8799. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8800. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8801. #endregion
  8802. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8803. #region 页面操作权限验证
  8804. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8805. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8806. #endregion
  8807. #endregion
  8808. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8809. }
  8810. /// <summary>
  8811. /// 酒店预订
  8812. /// 生成VOUCHER
  8813. /// 2024.05.06 之前版本
  8814. /// </summary>
  8815. /// <param name="_dto"></param>
  8816. /// <returns></returns>
  8817. [HttpPost]
  8818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8819. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8820. {
  8821. try
  8822. {
  8823. #region 参数验证
  8824. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8825. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8826. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8827. #region 团组操作权限验证 76 酒店预定模块
  8828. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8829. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8830. #endregion
  8831. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8832. #region 页面操作权限验证
  8833. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8834. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8835. #endregion
  8836. #endregion
  8837. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8838. //判断数据是否完整
  8839. if (hr != null)
  8840. {
  8841. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8842. {
  8843. string strFileName = "HotelStatement/";
  8844. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8845. if (dele != null)
  8846. strFileName += dele.TourCode;
  8847. //载入模板
  8848. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8849. Document doc = new Document(sss);
  8850. DocumentBuilder builder = new DocumentBuilder(doc);
  8851. #region 替换Word模板书签内容
  8852. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8853. //入住卷预定号码
  8854. if (doc.Range.Bookmarks["VNO"] != null)
  8855. {
  8856. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8857. mark.Text = hr.CheckNumber;
  8858. }
  8859. //酒店时间
  8860. if (doc.Range.Bookmarks["Date"] != null)
  8861. {
  8862. Bookmark mark = doc.Range.Bookmarks["Date"];
  8863. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8864. }
  8865. //团号
  8866. if (doc.Range.Bookmarks["TNo"] != null)
  8867. {
  8868. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8869. mark.Text = dele.TourCode;
  8870. }
  8871. //预定号码
  8872. if (doc.Range.Bookmarks["BookingId"] != null)
  8873. {
  8874. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8875. mark.Text = hr.ReservationsNo;
  8876. }
  8877. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8878. {
  8879. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8880. mark.Text = hr.DetermineNo;
  8881. }
  8882. //酒店城市
  8883. if (doc.Range.Bookmarks["City"] != null)
  8884. {
  8885. Bookmark mark = doc.Range.Bookmarks["City"];
  8886. mark.Text = hr.City;
  8887. }
  8888. //酒店名称
  8889. if (doc.Range.Bookmarks["HName"] != null)
  8890. {
  8891. Bookmark mark = doc.Range.Bookmarks["HName"];
  8892. mark.Text = hr.HotelName;
  8893. }
  8894. //酒店地址
  8895. if (doc.Range.Bookmarks["Address"] != null)
  8896. {
  8897. Bookmark mark = doc.Range.Bookmarks["Address"];
  8898. mark.Text = hr.HotelAddress;
  8899. }
  8900. //酒店电话
  8901. if (doc.Range.Bookmarks["Tel"] != null)
  8902. {
  8903. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8904. mark.Text = hr.HotelTel;
  8905. }
  8906. //酒店传真
  8907. if (doc.Range.Bookmarks["Fax"] != null)
  8908. {
  8909. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8910. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8911. {
  8912. mark.Text = hr.HotelFax;
  8913. }
  8914. }
  8915. //入住时间
  8916. if (doc.Range.Bookmarks["CIn"] != null)
  8917. {
  8918. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8919. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8920. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8921. }
  8922. //退房时间
  8923. if (doc.Range.Bookmarks["COut"] != null)
  8924. {
  8925. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8926. Bookmark mark = doc.Range.Bookmarks["COut"];
  8927. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8928. }
  8929. //客户名称
  8930. if (doc.Range.Bookmarks["GName"] != null)
  8931. {
  8932. string guestName = "";
  8933. string[] clients = new string[] { };
  8934. if (hr.GuestName.Contains(","))
  8935. {
  8936. clients = hr.GuestName.Split(",");
  8937. }
  8938. else
  8939. {
  8940. clients = new string[] { hr.GuestName };
  8941. }
  8942. List<int> clientIds_int = new List<int>();
  8943. if (clients.Length > 0)
  8944. {
  8945. foreach (var item in clients)
  8946. {
  8947. if (item.IsNumeric())
  8948. {
  8949. clientIds_int.Add(int.Parse(item));
  8950. }
  8951. }
  8952. }
  8953. if (clientIds_int.Count > 0)
  8954. {
  8955. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8956. foreach (var client in _clientDatas)
  8957. {
  8958. //男
  8959. if (client.Sex == 0) guestName += $"Mr.";
  8960. //女
  8961. else if (client.Sex == 1) guestName += $"Ms.";
  8962. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8963. {
  8964. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8965. }
  8966. //guestName += $"{client.Pinyin},";
  8967. }
  8968. if (guestName.Length > 0)
  8969. {
  8970. guestName = guestName.Substring(0, guestName.Length - 1);
  8971. }
  8972. }
  8973. else
  8974. {
  8975. guestName = hr.GuestName;
  8976. }
  8977. Bookmark mark = doc.Range.Bookmarks["GName"];
  8978. mark.Text = guestName;
  8979. }
  8980. //房间介绍
  8981. if (doc.Range.Bookmarks["ROOM"] != null)
  8982. {
  8983. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8984. mark.Text = hr.RoomExplanation;
  8985. }
  8986. //报价描述
  8987. if (doc.Range.Bookmarks["NOTE"] != null)
  8988. {
  8989. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8990. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8991. if (ss != null)
  8992. mark.Text = ss.Name;
  8993. }
  8994. //入住时间
  8995. if (doc.Range.Bookmarks["CheckIn"] != null)
  8996. {
  8997. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8998. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8999. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9000. }
  9001. //退房时间
  9002. if (doc.Range.Bookmarks["CheckOut"] != null)
  9003. {
  9004. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9005. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9006. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9007. }
  9008. //日期
  9009. if (doc.Range.Bookmarks["DT"] != null)
  9010. {
  9011. Bookmark mark = doc.Range.Bookmarks["DT"];
  9012. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9013. }
  9014. //名称
  9015. if (doc.Range.Bookmarks["VName"] != null)
  9016. {
  9017. Bookmark mark = doc.Range.Bookmarks["VName"];
  9018. mark.Text = hr.HotelName;
  9019. }
  9020. //号码
  9021. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9022. {
  9023. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9024. mark.Text = hr.CheckNumber;
  9025. }
  9026. #endregion
  9027. strFileName += "VOUCHER.doc";
  9028. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9029. doc.Save(fileDir);
  9030. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9031. return Ok(JsonView(true, "操作成功!", Url));
  9032. }
  9033. else
  9034. {
  9035. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9036. }
  9037. }
  9038. else
  9039. {
  9040. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9041. }
  9042. }
  9043. catch (Exception ex)
  9044. {
  9045. return Ok(JsonView(false, ex.Message));
  9046. }
  9047. }
  9048. /// <summary>
  9049. /// 酒店预订
  9050. /// 生成VOUCHER
  9051. /// 2024.05.06 之后版本
  9052. /// </summary>
  9053. /// <param name="_dto"></param>
  9054. /// <returns></returns>
  9055. [HttpPost]
  9056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9057. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9058. {
  9059. #region 参数验证
  9060. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9061. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9062. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9063. #region 团组操作权限验证 76 酒店预定模块
  9064. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9065. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9066. #endregion
  9067. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9068. #region 页面操作权限验证
  9069. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9070. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9071. #endregion
  9072. #endregion
  9073. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9074. //判断数据是否完整
  9075. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9076. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9077. string strFileName = "HotelStatement/";
  9078. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9079. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9080. #region 数据处理
  9081. List<int> guestIds = new List<int>();
  9082. int index = 0;
  9083. foreach (var item in hrDtas)
  9084. {
  9085. if (item.GuestName.Contains(","))
  9086. {
  9087. string[] guestIdArr = item.GuestName.Split(',');
  9088. foreach (var guestIdStr in guestIdArr)
  9089. {
  9090. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9091. if (guestBool)
  9092. {
  9093. guestIds.Add(guestId);
  9094. }
  9095. }
  9096. }
  9097. else guestNames += item.GuestName;
  9098. var voucherInfo = new HotelVoucherInfoView()
  9099. {
  9100. HotelName = item.HotelName,
  9101. CheckInDate = item.CheckInDate,
  9102. CheckOutDate = item.CheckOutDate,
  9103. ConfirmationNumber = item.DetermineNo.Trim(),
  9104. RoomType = item.RoomExplanation
  9105. };
  9106. vouchers.Add(voucherInfo);
  9107. }
  9108. if (guestIds.Count > 0)
  9109. {
  9110. guestIds = guestIds.Distinct().ToList();
  9111. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9112. if (guestDatas.Count > 0)
  9113. {
  9114. guestNames = "";
  9115. foreach (var guest in guestDatas)
  9116. {
  9117. string guestName = "";
  9118. if (guest.Sex == 0) guestName += @"MR.";
  9119. else if (guest.Sex == 1) guestName += @"MS.";
  9120. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9121. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9122. guestNames += @$"{guestName.Trim()}、";
  9123. }
  9124. if (guestNames.Length > 0)
  9125. {
  9126. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9127. }
  9128. }
  9129. }
  9130. #endregion
  9131. //载入模板
  9132. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9133. Document doc = new Document(sss);
  9134. DocumentBuilder builder = new DocumentBuilder(doc);
  9135. if (doc.Range.Bookmarks["GuestName"] != null)
  9136. {
  9137. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9138. mark.Text = guestNames;
  9139. }
  9140. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9141. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9142. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9143. for (int i = 1; i <= vouchers.Count; i++)
  9144. {
  9145. HotelVoucherInfoView hviv = vouchers[i - 1];
  9146. builder.MoveToCell(0, i, 0, 0);
  9147. builder.Write(hviv.HotelName);
  9148. builder.MoveToCell(0, i, 1, 0);
  9149. builder.Write(hviv.CheckInDate);
  9150. builder.MoveToCell(0, i, 2, 0);
  9151. builder.Write(hviv.CheckOutDate);
  9152. builder.MoveToCell(0, i, 3, 0);
  9153. builder.Write(hviv.RoomType);
  9154. builder.MoveToCell(0, i, 4, 0);
  9155. builder.Write(hviv.ConfirmationNumber);
  9156. }
  9157. //删除多余行
  9158. int currRowIndex = vouchers.Count + 1;
  9159. int delRows = 21 - currRowIndex;
  9160. if (delRows > 0)
  9161. {
  9162. for (int i = 0; i < delRows; i++)
  9163. {
  9164. table.Rows.RemoveAt(currRowIndex);
  9165. //cultivateRowIndex++;
  9166. }
  9167. }
  9168. strFileName += "VOUCHER.docx";
  9169. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9170. doc.Save(fileDir);
  9171. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9172. return Ok(JsonView(true, "操作成功!", Url));
  9173. }
  9174. /// <summary>
  9175. /// 酒店预订
  9176. /// 生成 预定成本 Excel
  9177. /// </summary>
  9178. /// <param name="_dto"></param>
  9179. /// <returns></returns>
  9180. [HttpPost]
  9181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9182. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9183. {
  9184. #region 参数验证
  9185. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9186. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9187. if (!vadalitorRes.IsValid)
  9188. {
  9189. var errors = new StringBuilder();
  9190. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9191. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9192. }
  9193. #region 团组操作权限验证 76 酒店预定模块
  9194. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9195. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9196. #endregion
  9197. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9198. #region 页面操作权限验证
  9199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9200. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9201. #endregion
  9202. #endregion
  9203. decimal _rate = 1.00M;
  9204. string _currency = "";
  9205. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9206. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9207. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9208. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9209. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9210. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9211. {
  9212. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9213. }
  9214. _currency = _GroupCostParameter.Currency;
  9215. bool isIntType = int.TryParse(_currency, out int currId);
  9216. if (isIntType)
  9217. {
  9218. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9219. }
  9220. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9221. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9222. if (currInfo == null)
  9223. {
  9224. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9225. }
  9226. if (!_currency.ToUpper().Equals("CNY"))
  9227. {
  9228. _rate = _GroupCostParameter.Rate;
  9229. }
  9230. _rate = currInfo.Rate;
  9231. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9232. string strFileName = "HotelStatement/";
  9233. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9234. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9235. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9236. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9237. #region 数据处理
  9238. foreach (var item in hrDtas)
  9239. {
  9240. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9241. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9242. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9243. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9244. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9245. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  9246. string singleRoomFeeStr = string.Empty,
  9247. doubleRoomFeeStr = string.Empty,
  9248. suiteRoomFeeStr = string.Empty,
  9249. otherRoomFeeStr = string.Empty,
  9250. payMoneyStr = string.Empty,
  9251. cardPriceStr = string.Empty;
  9252. if (roomCurr.Equals(_currency))
  9253. {
  9254. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9255. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9256. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9257. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9258. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9259. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9260. }
  9261. else
  9262. {
  9263. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9264. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9265. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9266. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9267. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9268. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9269. }
  9270. string breakfastPriceStr = string.Empty,
  9271. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9272. governmentRentStr = string.Empty,
  9273. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9274. cityTaxStrStr = string.Empty,
  9275. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9276. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9277. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9278. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9279. pcfds.Add(new HotelReservations_PCFD_View()
  9280. {
  9281. City = item.City,
  9282. HotelName = item.HotelName,
  9283. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9284. // SingleRoomCount = item.SingleRoomCount,
  9285. SingleRoomPrice = singleRoomFeeStr,
  9286. // DoubleRoomCount = item.DoubleRoomCount,
  9287. DoubleRoomPrice = doubleRoomFeeStr,
  9288. //SuiteRoomCount = item.SuiteRoomCount,
  9289. SuiteRoomPrice = suiteRoomFeeStr,
  9290. OtherRoomPrice = otherRoomFeeStr,
  9291. //OtherRoomCount = item.OtherRoomCount,
  9292. BreakfastPrice = breakfastPriceStr,
  9293. GovernmentRent = governmentRentStr,
  9294. CityTax = cityTaxStrStr,
  9295. RoomExplanation = item.RoomExplanation,
  9296. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  9297. PayTime = roomInfo.ConsumptionDate,
  9298. BankNo = roomInfo.BankNo,
  9299. PayMoney = payMoneyStr,
  9300. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9301. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  9302. CardPrice = cardPriceStr,
  9303. Remark = ccpInfo.Remark
  9304. });
  9305. }
  9306. #endregion
  9307. //载入模板
  9308. WorkbookDesigner designer = new WorkbookDesigner();
  9309. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9310. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9311. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9312. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9313. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9314. designer.SetDataSource("Opertor", userInfo.CnName);
  9315. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9316. dt.TableName = "ViewMyHotelReservations";
  9317. designer.SetDataSource(dt);
  9318. designer.Process();
  9319. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9320. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9321. designer.Workbook.Save(serverPath);
  9322. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9323. #region 删除指定行
  9324. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true,cpDel=true, remarkDel = true;
  9325. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9326. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9327. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9328. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9329. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9330. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9331. cssIndex = dt.Columns["CityTax"].Ordinal,
  9332. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9333. remarkIndex = dt.Columns["Remark"].Ordinal;
  9334. //删除指定列
  9335. foreach (DataRow item in dt.Rows)
  9336. {
  9337. string singleStr = item["SingleRoomPrice"].ToString();
  9338. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9339. if (containsDigitButNotZero1) singleDel = false;
  9340. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9341. string doubleStr = item["DoubleRoomPrice"].ToString();
  9342. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9343. if (containsDigitButNotZero2) doubleDel = false;
  9344. string suiteStr = item["SuiteRoomPrice"].ToString();
  9345. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9346. if (containsDigitButNotZero3) suiteDel = false;
  9347. string otherStr = item["OtherRoomPrice"].ToString();
  9348. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9349. if (containsDigitButNotZero4) otherDel = false;
  9350. string zcStr = item["BreakfastPrice"].ToString();
  9351. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9352. if (containsDigitButNotZero5) zcDel = false;
  9353. string dsStr = item["GovernmentRent"].ToString();
  9354. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9355. if (containsDigitButNotZero6) dsDel = false;
  9356. string cssStr = item["CityTax"].ToString();
  9357. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9358. if (containsDigitButNotZero7) cssDel = false;
  9359. string cpStr = item["ConsumptionPatterns"].ToString();
  9360. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9361. string remarkStr = item["Remark"].ToString();
  9362. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9363. }
  9364. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9365. DeleteColumn(serverPath, cpIndex, cpDel);
  9366. DeleteColumn(serverPath, dsIndex, dsDel);
  9367. DeleteColumn(serverPath, cssIndex, cssDel);
  9368. DeleteColumn(serverPath, zcIndex, zcDel);
  9369. DeleteColumn(serverPath, otherIndex, otherDel);
  9370. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9371. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9372. DeleteColumn(serverPath, singleIndex, singleDel);
  9373. #endregion
  9374. //只保留第一个表格
  9375. DeleteSheet(serverPath);
  9376. return Ok(JsonView(true, "操作成功", url = rst));
  9377. }
  9378. /// <summary>
  9379. /// 删除指定列
  9380. /// </summary>
  9381. /// <param name="file"></param>
  9382. /// <param name="columnIndex"></param>
  9383. /// <param name="isDel"></param>
  9384. private void DeleteColumn(string file, int columnIndex,bool isDel)
  9385. {
  9386. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9387. //wb.Save(file);
  9388. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9389. if (sheet1 != null)
  9390. {
  9391. if (isDel)
  9392. {
  9393. Cells cells = sheet1.Cells;
  9394. cells.DeleteColumn(columnIndex);
  9395. }
  9396. }
  9397. wb.Save(file);
  9398. }
  9399. /// <summary>
  9400. /// 删除sheet
  9401. /// </summary>
  9402. /// <param name="file"></param>
  9403. /// <param name="sheetName"></param>
  9404. private void DeleteSheet(string file, string sheetName="")
  9405. {
  9406. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9407. //wb.Save(file);
  9408. List<string> sheets = new List<string>();
  9409. foreach (var item in wb.Worksheets)
  9410. {
  9411. sheets.Add(item.Name);
  9412. }
  9413. if (sheets.Count > 0)
  9414. {
  9415. sheets.RemoveAt(0);//不删除第一个sheet
  9416. foreach (var item in sheets)
  9417. {
  9418. wb.Worksheets.RemoveAt(item);
  9419. }
  9420. }
  9421. wb.Save(file);
  9422. }
  9423. /// <summary>
  9424. /// 酒店预订
  9425. /// 确认单
  9426. /// </summary>
  9427. /// <param name="_dto"></param>
  9428. /// <returns></returns>
  9429. [HttpPost]
  9430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9431. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9432. {
  9433. try
  9434. {
  9435. #region 参数验证
  9436. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9437. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9438. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9439. #region 团组操作权限验证 76 酒店预定模块
  9440. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9441. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9442. #endregion
  9443. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9444. #region 页面操作权限验证
  9445. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9446. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9447. #endregion
  9448. #endregion
  9449. //团组信息
  9450. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9451. //酒店数据
  9452. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9453. if (listhoteldata.Count < 0)
  9454. {
  9455. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9456. }
  9457. //利datatable存储
  9458. DataTable dt = new DataTable();
  9459. dt.Columns.Add("CheckInDate", typeof(string));
  9460. dt.Columns.Add("City", typeof(string));
  9461. dt.Columns.Add("Hotel", typeof(string));
  9462. dt.Columns.Add("Room", typeof(string));
  9463. for (int i = 0; i < listhoteldata.Count; i++)
  9464. {
  9465. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9466. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9467. while (dayStart < dayEnd)
  9468. {
  9469. string temp = "";
  9470. DataRow row = dt.NewRow();
  9471. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9472. row["City"] = listhoteldata[i].City;
  9473. row["Hotel"] = listhoteldata[i].HotelName;
  9474. if (listhoteldata[i].SingleRoomCount > 0)
  9475. {
  9476. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9477. }
  9478. if (listhoteldata[i].DoubleRoomCount > 0)
  9479. {
  9480. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9481. }
  9482. if (listhoteldata[i].SuiteRoomCount > 0)
  9483. {
  9484. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9485. }
  9486. if (listhoteldata[i].OtherRoomCount > 0)
  9487. {
  9488. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9489. }
  9490. row["Room"] = temp;
  9491. dt.Rows.Add(row);
  9492. dayStart = dayStart.AddDays(1);
  9493. }
  9494. }
  9495. Dictionary<string, string> dic = new Dictionary<string, string>();
  9496. dic.Add("Dele", di.TeamName);
  9497. dic.Add("City", di.VisitCountry);
  9498. //模板路径
  9499. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9500. //载入模板
  9501. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9502. DocumentBuilder builder = new DocumentBuilder(doc);
  9503. foreach (var key in dic.Keys)
  9504. {
  9505. builder.MoveToBookmark(key);
  9506. builder.Write(dic[key]);
  9507. }
  9508. //获取word里所有表格
  9509. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9510. //获取所填表格的序数
  9511. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9512. var rowStart = tableOne.Rows[0]; //获取第1行
  9513. //循环赋值
  9514. for (int i = 0; i < dt.Rows.Count; i++)
  9515. {
  9516. builder.MoveToCell(0, i + 1, 0, 0);
  9517. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9518. builder.MoveToCell(0, i + 1, 1, 0);
  9519. builder.Write(dt.Rows[i]["City"].ToString());
  9520. builder.MoveToCell(0, i + 1, 2, 0);
  9521. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9522. builder.MoveToCell(0, i + 1, 3, 0);
  9523. builder.Write(dt.Rows[i]["Room"].ToString());
  9524. }
  9525. //删除多余行
  9526. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9527. {
  9528. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9529. }
  9530. string strFileName = di.TeamName + "酒店确认单.doc";
  9531. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9532. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9533. return Ok(JsonView(true, "成功", url));
  9534. }
  9535. catch (Exception ex)
  9536. {
  9537. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9538. }
  9539. }
  9540. #endregion
  9541. #region 团组状态
  9542. /// <summary>
  9543. /// 团组状态列表 Page
  9544. /// </summary>
  9545. /// <param name="dto">团组列表请求dto</param>
  9546. /// <returns></returns>
  9547. [HttpPost]
  9548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9549. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9550. {
  9551. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9552. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9553. {
  9554. string sqlWhere = string.Empty;
  9555. if (dto.IsSure == 0) //未完成
  9556. {
  9557. sqlWhere += string.Format(@" And IsSure = 0");
  9558. }
  9559. else if (dto.IsSure == 1) //已完成
  9560. {
  9561. sqlWhere += string.Format(@" And IsSure = 1");
  9562. }
  9563. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9564. {
  9565. string tj = dto.SearchCriteria;
  9566. 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}%')",
  9567. tj, tj, tj, tj, tj);
  9568. }
  9569. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9570. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9571. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9572. From (
  9573. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9574. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9575. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9576. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9577. From Grp_DelegationInfo gdi
  9578. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9579. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9580. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9581. Where gdi.IsDel = 0 {0}
  9582. ) temp ", sqlWhere);
  9583. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9584. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9585. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9586. }
  9587. else
  9588. {
  9589. return Ok(JsonView(false, "查询失败"));
  9590. }
  9591. }
  9592. /// <summary>
  9593. /// 团组状态
  9594. /// 设置操作完成
  9595. /// </summary>
  9596. /// <param name="dto">团组列表请求dto</param>
  9597. /// <returns></returns>
  9598. [HttpPost]
  9599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9600. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9601. {
  9602. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9603. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9604. {
  9605. Id = dto.Id,
  9606. IsSure = 1
  9607. };
  9608. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9609. .UpdateColumns(it => new { it.IsSure })
  9610. .WhereColumns(it => new { it.Id })
  9611. .ExecuteCommandAsync();
  9612. if (result > 0)
  9613. {
  9614. return Ok(JsonView(true, "操作完成!"));
  9615. }
  9616. return Ok(JsonView(false, "操作失败!"));
  9617. }
  9618. #endregion
  9619. #region 保险费用录入
  9620. /// <summary>
  9621. /// 根据团组Id查询保险费用列表
  9622. /// </summary>
  9623. /// <param name="dto"></param>
  9624. /// <returns></returns>
  9625. [HttpPost]
  9626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9627. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9628. {
  9629. try
  9630. {
  9631. Result groupData = await _customersRep.CustomersByDiId(dto);
  9632. if (groupData.Code != 0)
  9633. {
  9634. return Ok(JsonView(false, groupData.Msg));
  9635. }
  9636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9637. }
  9638. catch (Exception ex)
  9639. {
  9640. return Ok(JsonView(false, ex.Message));
  9641. }
  9642. }
  9643. /// <summary>
  9644. /// 根据保险费用Id查询保险费用详细
  9645. /// </summary>
  9646. /// <param name="dto"></param>
  9647. /// <returns></returns>
  9648. [HttpPost]
  9649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9650. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9651. {
  9652. try
  9653. {
  9654. Result groupData = await _customersRep.CustomersById(dto);
  9655. if (groupData.Code != 0)
  9656. {
  9657. return Ok(JsonView(false, groupData.Msg));
  9658. }
  9659. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9660. }
  9661. catch (Exception ex)
  9662. {
  9663. return Ok(JsonView(false, ex.Message));
  9664. }
  9665. }
  9666. /// <summary>
  9667. /// 保险费用录入页面初始化绑定
  9668. /// </summary>
  9669. /// <param name="dto"></param>
  9670. /// <returns></returns>
  9671. [HttpPost]
  9672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9673. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9674. {
  9675. try
  9676. {
  9677. Result groupData = await _customersRep.CustomersInitialize(dto);
  9678. if (groupData.Code != 0)
  9679. {
  9680. return Ok(JsonView(false, groupData.Msg));
  9681. }
  9682. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9683. }
  9684. catch (Exception ex)
  9685. {
  9686. return Ok(JsonView(false, ex.Message));
  9687. }
  9688. }
  9689. /// <summary>
  9690. /// 保险费用操作(Status:1.新增,2.修改)
  9691. /// </summary>
  9692. /// <param name="dto"></param>
  9693. /// <returns></returns>
  9694. [HttpPost]
  9695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9696. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9697. {
  9698. try
  9699. {
  9700. Result groupData = await _customersRep.OpCustomers(dto);
  9701. if (groupData.Code != 0)
  9702. {
  9703. return Ok(JsonView(false, groupData.Msg));
  9704. }
  9705. #region 应用推送
  9706. try
  9707. {
  9708. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9709. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9710. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9711. }
  9712. catch (Exception ex)
  9713. {
  9714. }
  9715. #endregion
  9716. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9717. }
  9718. catch (Exception ex)
  9719. {
  9720. return Ok(JsonView(false, ex.Message));
  9721. }
  9722. }
  9723. /// <summary>
  9724. /// 保险文件上传
  9725. /// </summary>
  9726. /// <param name="file"></param>
  9727. /// <returns></returns>
  9728. [HttpPost]
  9729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9730. public async Task<IActionResult> UploadCus(IFormFile file)
  9731. {
  9732. try
  9733. {
  9734. if (file != null)
  9735. {
  9736. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9737. //文件名称
  9738. string projectFileName = file.FileName;
  9739. //上传的文件的路径
  9740. string filePath = "";
  9741. if (!Directory.Exists(fileDir))
  9742. {
  9743. Directory.CreateDirectory(fileDir);
  9744. }
  9745. //上传的文件的路径
  9746. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9747. using (FileStream fs = System.IO.File.Create(filePath))
  9748. {
  9749. file.CopyTo(fs);
  9750. fs.Flush();
  9751. }
  9752. return Ok(JsonView(true, "上传成功!", projectFileName));
  9753. }
  9754. else
  9755. {
  9756. return Ok(JsonView(false, "上传失败!"));
  9757. }
  9758. }
  9759. catch (Exception ex)
  9760. {
  9761. return Ok(JsonView(false, "程序错误!"));
  9762. throw;
  9763. }
  9764. }
  9765. /// <summary>
  9766. /// 保险删除指定文件
  9767. /// </summary>
  9768. /// <param name="dto"></param>
  9769. /// <returns></returns>
  9770. [HttpPost]
  9771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9772. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9773. {
  9774. try
  9775. {
  9776. string filePath = "";
  9777. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9778. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9779. //int id = 0;
  9780. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9781. // 删除该文件
  9782. try
  9783. {
  9784. System.IO.File.Delete(filePath);
  9785. 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()
  9786. {
  9787. Attachment = "",
  9788. }).ExecuteCommandAsync();
  9789. if (result != 0)
  9790. {
  9791. return Ok(JsonView(true, "成功!"));
  9792. }
  9793. else
  9794. {
  9795. return Ok(JsonView(false, "失败!"));
  9796. }
  9797. }
  9798. catch (Exception)
  9799. {
  9800. 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()
  9801. {
  9802. Attachment = "",
  9803. }).ExecuteCommandAsync();
  9804. if (result != 0)
  9805. {
  9806. return Ok(JsonView(true, "成功!"));
  9807. }
  9808. else
  9809. {
  9810. return Ok(JsonView(false, "失败!"));
  9811. }
  9812. }
  9813. }
  9814. catch (Exception ex)
  9815. {
  9816. return Ok(JsonView(false, "程序错误!"));
  9817. throw;
  9818. }
  9819. }
  9820. /// <summary>
  9821. /// 保险费用操作(删除)
  9822. /// </summary>
  9823. /// <param name="dto"></param>
  9824. /// <returns></returns>
  9825. [HttpPost]
  9826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9827. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9828. {
  9829. try
  9830. {
  9831. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9832. if (!res)
  9833. {
  9834. return Ok(JsonView(false, "删除失败"));
  9835. }
  9836. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9837. {
  9838. IsDel = 1,
  9839. DeleteUserId = dto.DeleteUserId,
  9840. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9841. }).ExecuteCommandAsync();
  9842. return Ok(JsonView(true, "删除成功!"));
  9843. }
  9844. catch (Exception ex)
  9845. {
  9846. return Ok(JsonView(false, "程序错误!"));
  9847. throw;
  9848. }
  9849. }
  9850. #endregion
  9851. #region 接团客户名单 PageId 104
  9852. /// <summary>
  9853. /// 接团客户名单
  9854. /// 迁移数据(慎用!)
  9855. /// </summary>
  9856. /// <param name="dto"></param>
  9857. /// <returns></returns>
  9858. [HttpPost]
  9859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9860. public async Task<IActionResult> PostTourClientListChange()
  9861. {
  9862. try
  9863. {
  9864. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9865. //var groupClinetData1
  9866. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9867. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9868. int updateCount = 0;
  9869. if (oldOAClientList.Count > 0)
  9870. {
  9871. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9872. _sqlSugar.BeginTran();
  9873. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9874. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9875. foreach (var item in oldOAClientList)
  9876. {
  9877. int comId = 0;
  9878. string format = "yyyy-MM-dd HH:mm:ss";
  9879. string data11 = "1990-01-01 00:00";
  9880. var data1 = IsValidDate(item.OPdate, format);
  9881. if (data1) data11 = item.OPdate;
  9882. //客户公司验证
  9883. if (!string.IsNullOrEmpty(item.Company))
  9884. {
  9885. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9886. if (clientComInfo == null) // add
  9887. {
  9888. var addInfo = new Crm_CustomerCompany()
  9889. {
  9890. CompanyAbbreviation = "",
  9891. CompanyFullName = item.Company,
  9892. Address = "",
  9893. PostCodes = "",
  9894. LastedOpUserId = item.OPer,
  9895. LastedOpDt = Convert.ToDateTime(data11),
  9896. CreateUserId = item.OPer,
  9897. CreateTime = Convert.ToDateTime(data11),
  9898. IsDel = 0
  9899. };
  9900. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9901. if (comId1 > 0) comId = comId1;
  9902. }
  9903. else comId = clientComInfo.Id;
  9904. }
  9905. //客户人员验证
  9906. int clientId = 0;
  9907. string name = item.LastName + item.Name;
  9908. if (!string.IsNullOrEmpty(name))
  9909. {
  9910. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9911. if (clientInfo == null)
  9912. {
  9913. DateTime? dateTime = null;
  9914. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9915. if (isDt) dateTime = birthDayDt;
  9916. var addInfo1 = new Crm_DeleClient()
  9917. {
  9918. CrmCompanyId = comId,
  9919. DiId = -1,
  9920. LastName = item.LastName,
  9921. FirstName = item.Name,
  9922. OldName = "",
  9923. Pinyin = item.Pinyin,
  9924. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9925. Marriage = 0,
  9926. Phone = item.Phone,
  9927. Job = item.Job,
  9928. BirthDay = dateTime
  9929. };
  9930. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9931. if (clientId1 > 0) clientId = clientId1;
  9932. }
  9933. else clientId = clientInfo.Id;
  9934. }
  9935. if (clientId < 1)
  9936. {
  9937. continue;
  9938. }
  9939. int airType = 0;
  9940. if (item.AirType == "超经舱") airType = 459;
  9941. else if (item.AirType == "公务舱") airType = 458;
  9942. else if (item.AirType == "经济舱") airType = 460;
  9943. else if (item.AirType == "其他") airType = 565;
  9944. else if (item.AirType == "头等舱") airType = 457;
  9945. var _TourClientListEntity = new Grp_TourClientList()
  9946. {
  9947. DiId = item.Diid,
  9948. ClientId = clientId,
  9949. CreateUserId = item.OPer,
  9950. CreateTime = Convert.ToDateTime(data11),
  9951. Remark = item.Remark,
  9952. IsDel = item.Isdel,
  9953. ShippingSpaceTypeId = airType,
  9954. ShippingSpaceSpecialNeeds = item.AirRemark,
  9955. HotelSpecialNeeds = item.RoomType
  9956. };
  9957. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9958. if (_TourClientList > 0)
  9959. {
  9960. updateCount++;
  9961. }
  9962. }
  9963. _sqlSugar.CommitTran();
  9964. }
  9965. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9966. }
  9967. catch (Exception ex)
  9968. {
  9969. _sqlSugar.RollbackTran();
  9970. return Ok(JsonView(false, ex.Message));
  9971. }
  9972. return Ok(JsonView(true));
  9973. }
  9974. private bool IsValidDate(string dateString, string format)
  9975. {
  9976. DateTime dateValue;
  9977. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9978. return valid;
  9979. }
  9980. /// <summary>
  9981. /// 接团客户名单
  9982. /// 根据团组Id查询List
  9983. /// </summary>
  9984. /// <param name="dto"></param>
  9985. /// <returns></returns>
  9986. [HttpPost]
  9987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9988. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9989. {
  9990. #region 参数验证
  9991. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9992. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9993. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9994. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9995. #region 页面操作权限验证
  9996. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9997. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9998. #endregion
  9999. #endregion
  10000. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10001. if (viewData.Code != 0)
  10002. {
  10003. return Ok(JsonView(false, viewData.Msg));
  10004. }
  10005. return Ok(JsonView(viewData.Data));
  10006. }
  10007. /// <summary>
  10008. /// 接团客户名单
  10009. /// 基础数据 Init
  10010. /// </summary>
  10011. /// <param name="_dto"></param>
  10012. /// <returns></returns>
  10013. [HttpPost]
  10014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10015. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10016. {
  10017. #region 参数验证
  10018. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10019. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10020. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10021. #region 页面操作权限验证
  10022. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10023. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10024. #endregion
  10025. #endregion
  10026. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10027. if (viewData.Code != 0)
  10028. {
  10029. return Ok(JsonView(false, viewData.Msg));
  10030. }
  10031. return Ok(JsonView(viewData.Data));
  10032. }
  10033. /// <summary>
  10034. /// 接团客户名单
  10035. /// 根据 Id查询 Details
  10036. /// </summary>
  10037. /// <param name="_dto"></param>
  10038. /// <returns></returns>
  10039. [HttpPost]
  10040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10041. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10042. {
  10043. #region 参数验证
  10044. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10045. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10046. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10047. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10048. #region 页面操作权限验证
  10049. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10050. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10051. #endregion
  10052. #endregion
  10053. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10054. if (viewData.Code != 0)
  10055. {
  10056. return Ok(JsonView(false, viewData.Msg));
  10057. }
  10058. return Ok(JsonView(viewData.Data));
  10059. }
  10060. /// <summary>
  10061. /// 接团客户名单
  10062. /// Add Or Edit
  10063. /// </summary>
  10064. /// <param name="_dto"></param>
  10065. /// <returns></returns>
  10066. [HttpPost]
  10067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10068. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10069. {
  10070. #region 参数验证
  10071. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10072. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10073. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10074. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10075. #region 页面操作权限验证
  10076. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10077. if (_dto.Id == 0) //添加
  10078. {
  10079. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10080. }
  10081. else if (_dto.Id >= 0) //修改
  10082. {
  10083. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10084. }
  10085. #endregion
  10086. #endregion
  10087. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10088. if (viewData.Code != 0)
  10089. {
  10090. return Ok(JsonView(false, viewData.Msg));
  10091. }
  10092. return Ok(JsonView(true));
  10093. }
  10094. /// <summary>
  10095. /// 接团客户名单
  10096. /// AddMultiple(添加多个)
  10097. /// </summary>
  10098. /// <param name="_dto"></param>
  10099. /// <returns></returns>
  10100. [HttpPost]
  10101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10102. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10103. {
  10104. #region 参数验证
  10105. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10106. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10107. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10108. #region 页面操作权限验证
  10109. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10110. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10111. #endregion
  10112. #endregion
  10113. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10114. if (viewData.Code != 0)
  10115. {
  10116. return Ok(JsonView(false, viewData.Msg));
  10117. }
  10118. return Ok(JsonView(true));
  10119. }
  10120. /// <summary>
  10121. /// 接团客户名单
  10122. /// Del
  10123. /// </summary>
  10124. /// <param name="_dto"></param>
  10125. /// <returns></returns>
  10126. [HttpPost]
  10127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10128. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10129. {
  10130. #region 参数验证
  10131. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10132. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10133. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10134. #region 页面操作权限验证
  10135. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10136. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10137. #endregion
  10138. #endregion
  10139. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10140. if (viewData.Code != 0)
  10141. {
  10142. return Ok(JsonView(false, viewData.Msg));
  10143. }
  10144. return Ok(JsonView(true));
  10145. }
  10146. /// <summary>
  10147. /// 接团客户名单
  10148. /// 文件下载 客户名单
  10149. /// </summary>
  10150. /// <param name="_dto"></param>
  10151. /// <returns></returns>
  10152. [HttpPost]
  10153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10154. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10155. {
  10156. #region 参数验证
  10157. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10158. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10159. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10160. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10161. #region 页面操作权限验证
  10162. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10163. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10164. #endregion
  10165. #endregion
  10166. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10167. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10168. From Grp_TourClientList tcl
  10169. Left Join
  10170. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10171. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10172. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10173. From Crm_DeleClient dc
  10174. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10175. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10176. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10177. Where dc.IsDel = 0) temp
  10178. On temp.DcId =tcl.ClientId
  10179. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10180. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10181. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10182. //载入模板
  10183. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10184. if (_dto.Language == 1)
  10185. {
  10186. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10187. }
  10188. //载入模板
  10189. var doc = new Document(tempPath);
  10190. DocumentBuilder builder = new DocumentBuilder(doc);
  10191. //获取word里所有表格
  10192. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10193. //获取所填表格的序数
  10194. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10195. var rowStart = tableOne.Rows[0]; //获取第1行
  10196. if (_dto.Language == 0)
  10197. {
  10198. //循环赋值
  10199. for (int i = 0; i < DcList.Count; i++)
  10200. {
  10201. builder.MoveToCell(0, i + 1, 0, 0);
  10202. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10203. builder.MoveToCell(0, i + 1, 1, 0);
  10204. int sex = DcList[i].Sex;
  10205. string sexStr = string.Empty;
  10206. if (sex == 0) sexStr = "男";
  10207. else if (sex == 1) sexStr = "女";
  10208. else sexStr = "未设置";
  10209. builder.Write(sexStr);
  10210. builder.MoveToCell(0, i + 1, 2, 0);
  10211. string birthDay = DcList[i].BirthDay;
  10212. string birthDayStr = string.Empty;
  10213. if (!string.IsNullOrEmpty(birthDay))
  10214. {
  10215. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10216. }
  10217. builder.Write(birthDayStr);
  10218. builder.MoveToCell(0, i + 1, 3, 0);
  10219. string company = "";
  10220. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10221. {
  10222. company = DcList[i].CompanyFullName.ToString();
  10223. }
  10224. builder.Write(company);
  10225. builder.MoveToCell(0, i + 1, 4, 0);
  10226. builder.Write(DcList[i].Job);
  10227. }
  10228. }
  10229. else if (_dto.Language == 1)
  10230. {
  10231. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10232. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10233. //循环赋值
  10234. for (int i = 0; i < DcList.Count; i++)
  10235. {
  10236. string PYName = "";
  10237. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10238. {
  10239. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10240. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10241. PYName = PY_First + " " + PY_Last;
  10242. }
  10243. else
  10244. {
  10245. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10246. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10247. PYName = PY_First + " " + PY_Last;
  10248. }
  10249. builder.MoveToCell(0, i + 1, 0, 0);
  10250. builder.Write(PYName);
  10251. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10252. builder.MoveToCell(0, i + 1, 1, 0);
  10253. builder.Write(sex);
  10254. DateTime birthDt;
  10255. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10256. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10257. builder.MoveToCell(0, i + 1, 2, 0);
  10258. builder.Write(birthday);
  10259. string company = "";
  10260. try
  10261. {
  10262. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10263. {
  10264. //查询对照表
  10265. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10266. if (tempCec != null)
  10267. {
  10268. company = tempCec.enName;
  10269. }
  10270. //翻译
  10271. else
  10272. {
  10273. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10274. }
  10275. }
  10276. }
  10277. catch (Exception)
  10278. {
  10279. }
  10280. builder.MoveToCell(0, i + 1, 3, 0);
  10281. builder.Write(company);
  10282. string job = "";
  10283. try
  10284. {
  10285. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10286. {
  10287. //查询对照表
  10288. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10289. if (tempPec != null)
  10290. {
  10291. job = tempPec.enName;
  10292. }
  10293. //翻译
  10294. else
  10295. {
  10296. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10297. }
  10298. }
  10299. }
  10300. catch (Exception ex)
  10301. {
  10302. }
  10303. builder.MoveToCell(0, i + 1, 4, 0);
  10304. builder.Write(job);
  10305. }
  10306. }
  10307. //删除多余行
  10308. while (tableOne.Rows.Count > DcList.Count + 1)
  10309. {
  10310. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10311. }
  10312. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10313. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10314. doc.Save(fileDir);
  10315. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10316. return Ok(JsonView(true, "操作成功!", Url));
  10317. }
  10318. #endregion
  10319. #region 团组倒推表
  10320. /// <summary>
  10321. /// 倒推表基础数据
  10322. /// Init
  10323. /// </summary>
  10324. /// <param name="dto"></param>
  10325. /// <returns></returns>
  10326. [HttpPost]
  10327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10328. public async Task<IActionResult> PostInvertedListInit()
  10329. {
  10330. var viewData = await _invertedListRep._Init();
  10331. if (viewData.Code != 0)
  10332. {
  10333. return Ok(JsonView(false, viewData.Msg));
  10334. }
  10335. return Ok(JsonView(viewData.Data));
  10336. }
  10337. /// <summary>
  10338. /// 倒推表
  10339. /// Info
  10340. /// </summary>
  10341. /// <param name="dto"></param>
  10342. /// <returns></returns>
  10343. [HttpPost]
  10344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10345. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10346. {
  10347. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10348. if (viewData.Code != 0)
  10349. {
  10350. return Ok(JsonView(false, viewData.Msg));
  10351. }
  10352. return Ok(JsonView(viewData.Data));
  10353. }
  10354. /// <summary>
  10355. /// 倒推表
  10356. /// Create
  10357. /// </summary>
  10358. /// <param name="dto"></param>
  10359. /// <returns></returns>
  10360. [HttpPost]
  10361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10362. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10363. {
  10364. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10365. if (viewData.Code != 0)
  10366. {
  10367. return Ok(JsonView(false, viewData.Msg));
  10368. }
  10369. return Ok(JsonView(viewData.Data));
  10370. }
  10371. /// <summary>
  10372. /// 倒推表
  10373. /// Update
  10374. /// </summary>
  10375. /// <param name="dto"></param>
  10376. /// <returns></returns>
  10377. [HttpPost]
  10378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10379. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10380. {
  10381. var viewData = await _invertedListRep._Update(dto);
  10382. if (viewData.Code != 0)
  10383. {
  10384. return Ok(JsonView(false, viewData.Msg));
  10385. }
  10386. return Ok(JsonView(viewData.Data));
  10387. }
  10388. /// <summary>
  10389. /// 倒推表
  10390. /// File Download
  10391. /// </summary>
  10392. /// <param name="dto"></param>
  10393. /// <returns></returns>
  10394. [HttpPost]
  10395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10396. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10397. {
  10398. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10399. if (info2.Code != 0)
  10400. {
  10401. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10402. }
  10403. var info1 = info2.Data as InvertedListInfoView;
  10404. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10405. string teamName = "";
  10406. if (info != null) teamName = info.TeamName;
  10407. //载入模板
  10408. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10409. DocumentBuilder builder = new DocumentBuilder(doc);
  10410. //利用键值对存放数据
  10411. Dictionary<string, string> dic = new Dictionary<string, string>();
  10412. dic.Add("TeamName", teamName);
  10413. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10414. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10415. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10416. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10417. dic.Add("SQRemark", info1.ApprovalRemark);
  10418. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10419. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10420. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10421. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10422. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10423. dic.Add("QZRemark", info1.VisaInformationRemark);
  10424. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10425. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10426. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10427. dic.Add("CQRemark", info1.IssueVisaRemark);
  10428. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10429. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10430. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10431. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10432. #region 填充word模板书签内容
  10433. foreach (var key in dic.Keys)
  10434. {
  10435. builder.MoveToBookmark(key);
  10436. builder.Write(dic[key]);
  10437. }
  10438. #endregion
  10439. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10440. string fileName = $"{teamName}团出行准备流程表.doc";
  10441. string filePath = fileDir + $@"InvertedList/{fileName}";
  10442. doc.Save(filePath);
  10443. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10444. return Ok(JsonView(true, "操作成功!", Url));
  10445. }
  10446. #endregion
  10447. #region 三公签证费用(签证费、代办费)
  10448. /// <summary>
  10449. /// 三公签证费用(签证费、代办费)
  10450. /// List
  10451. /// </summary>
  10452. /// <returns></returns>
  10453. [HttpPost]
  10454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10455. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10456. {
  10457. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10458. if (_view.Code != 0)
  10459. {
  10460. return Ok(JsonView(false, _view.Msg));
  10461. }
  10462. return Ok(JsonView(true, "操作成功!", _view.Data));
  10463. }
  10464. /// <summary>
  10465. /// 三公签证费用(签证费、代办费)
  10466. /// Add Or Update
  10467. /// </summary>
  10468. /// <returns></returns>
  10469. [HttpPost]
  10470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10471. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10472. {
  10473. var _view = await _visaFeeInfoRep._Update(_dto);
  10474. if (_view.Code != 0)
  10475. {
  10476. return Ok(JsonView(false, _view.Msg));
  10477. }
  10478. return Ok(JsonView(true, _view.Msg));
  10479. }
  10480. #endregion
  10481. #region 酒店询价
  10482. /// <summary>
  10483. /// 酒店询价
  10484. /// Init
  10485. /// </summary>
  10486. /// <param name="dto"></param>
  10487. /// <returns></returns>
  10488. [HttpPost]
  10489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10490. public async Task<IActionResult> PostHotelInquiryInit()
  10491. {
  10492. var res = await _hotelInquiryRep._Init();
  10493. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10494. return Ok(JsonView(true, res.Msg, res.Data));
  10495. }
  10496. /// <summary>
  10497. /// 酒店询价
  10498. /// page Item
  10499. /// </summary>
  10500. /// <param name="_dto"></param>
  10501. /// <returns></returns>
  10502. [HttpPost]
  10503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10504. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10505. {
  10506. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex,_dto.PageSize,_dto.PortType,_dto.DiId);
  10507. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10508. var view = res.Data as PageDataViewBase;
  10509. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10510. }
  10511. /// <summary>
  10512. /// 酒店询价
  10513. /// info
  10514. /// </summary>
  10515. /// <param name="_dto"></param>
  10516. /// <returns></returns>
  10517. [HttpPost]
  10518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10519. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10520. {
  10521. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10522. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10523. return Ok(JsonView(true, res.Msg, res.Data));
  10524. }
  10525. /// <summary>
  10526. /// 酒店询价
  10527. /// Add Or Edit
  10528. /// </summary>
  10529. /// <param name="_dto"></param>
  10530. /// <returns></returns>
  10531. [HttpPost]
  10532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10533. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10534. {
  10535. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10536. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10537. return Ok(JsonView(true, res.Msg, res.Data));
  10538. }
  10539. /// <summary>
  10540. /// 酒店询价
  10541. /// Del
  10542. /// </summary>
  10543. /// <param name="_dto"></param>
  10544. /// <returns></returns>
  10545. [HttpPost]
  10546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10547. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10548. {
  10549. var res = await _hotelInquiryRep._Del(_dto.Id,_dto.DeleteUserId);
  10550. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10551. return Ok(JsonView(true, res.Msg, res.Data));
  10552. }
  10553. #endregion
  10554. /// <summary>
  10555. /// 报批行程初始化
  10556. /// </summary>
  10557. /// <param name="dto"></param>
  10558. /// <returns></returns>
  10559. [HttpPost]
  10560. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10561. {
  10562. const int chiNumber = 5;
  10563. var jw = JsonView(false);
  10564. if (dto.Diid == -1)
  10565. {
  10566. dto.Diid = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0).Id;
  10567. }
  10568. return Ok(jw);
  10569. }
  10570. // /// <summary>
  10571. // ///
  10572. // /// </summary>
  10573. // /// <param name="_dto"></param>
  10574. // /// <returns></returns>
  10575. // [HttpPost]
  10576. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10577. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  10578. // {
  10579. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  10580. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  10581. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  10582. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  10583. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  10584. // dic_psg.Add("客人", 974);
  10585. // dic_psg.Add("司机", 975);
  10586. // dic_psg.Add("导游", 976);
  10587. // dic_psg.Add("公司内部人员", 977);
  10588. // dic_psg.Add("司机/导游/公司内部人员", 978);
  10589. // foreach (var item in list_visa)
  10590. // {
  10591. // Grp_VisaInfo temp = new Grp_VisaInfo();
  10592. // temp.Id = item.Id;
  10593. // temp.DIId = item.DIId;
  10594. // temp.VisaClient = item.VisaClient;
  10595. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  10596. // temp.VisaCurrency = item.VisaCurrency;
  10597. // temp.IsThird = item.IsThird;
  10598. // if (dic_psg.ContainsKey(item.PassengerType))
  10599. // {
  10600. // temp.PassengerType = dic_psg[item.PassengerType];
  10601. // }
  10602. // else {
  10603. // temp.PassengerType = -1;
  10604. // }
  10605. // temp.VisaNumber = item.VisaNumber;
  10606. // temp.VisaFreeNumber = item.VisaFreeNumber;
  10607. // temp.CreateUserId = item.Operators;
  10608. // DateTime dt_ct;
  10609. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  10610. // if (b_ct)
  10611. // {
  10612. // temp.CreateTime = dt_ct;
  10613. // }
  10614. // else
  10615. // {
  10616. // temp.CreateTime = DateTime.Now;
  10617. // }
  10618. // temp.DeleteTime = "";
  10619. // temp.DeleteUserId = 0;
  10620. // temp.Remark = item.Remark;
  10621. // if (string.IsNullOrEmpty(temp.Remark)) {
  10622. // temp.Remark = "";
  10623. // }
  10624. // temp.IsDel = item.IsDel;
  10625. // temp.VisaDescription = item.VisaAttachment;
  10626. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  10627. //([Id]
  10628. // ,[DIId]
  10629. // ,[VisaClient]
  10630. // ,[VisaPrice]
  10631. // ,[VisaCurrency]
  10632. // ,[IsThird]
  10633. // ,[PassengerType]
  10634. // ,[VisaNumber]
  10635. // ,[VisaFreeNumber]
  10636. // ,[CreateUserId]
  10637. // ,[CreateTime]
  10638. // ,[DeleteTime]
  10639. // ,[DeleteUserId]
  10640. // ,[Remark]
  10641. // ,[IsDel]
  10642. // ,[visaDescription])
  10643. // VALUES
  10644. // ({0},{1},'{2}',{3},{4}
  10645. //,{5},{6},{7},{8},{9}
  10646. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  10647. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  10648. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  10649. //);
  10650. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  10651. // }
  10652. // return Ok(JsonView(true, "操作成功!"));
  10653. // }
  10654. /// <summary>
  10655. /// 123132123
  10656. /// </summary>
  10657. /// <param name="_dto"></param>
  10658. /// <returns></returns>
  10659. [HttpPost]
  10660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10661. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  10662. {
  10663. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  10664. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  10665. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  10666. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  10667. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  10668. dicDetail.Add(789, 1034);
  10669. dicDetail.Add(790, 1035);
  10670. dicDetail.Add(791, 1036);
  10671. dicDetail.Add(792, 1037);
  10672. dicDetail.Add(793, 1038);
  10673. dicDetail.Add(794, 1039);
  10674. dicDetail.Add(795, 1040);
  10675. dicDetail.Add(796, 1041);
  10676. dicDetail.Add(797, 1042);
  10677. dicDetail.Add(798, 1043);
  10678. dicDetail.Add(801, 1044);
  10679. dicDetail.Add(802, 1045);
  10680. dicDetail.Add(803, 1046);
  10681. Dictionary<int, int> dic = new Dictionary<int, int>();
  10682. dic.Add(806, 1027);
  10683. dic.Add(807, 1028);
  10684. dic.Add(808, 1029);
  10685. dic.Add(809, 1030);
  10686. dic.Add(810, 1031);
  10687. dic.Add(811, 1032);
  10688. dic.Add(812, 1033);
  10689. foreach (var item in list_visa)
  10690. {
  10691. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  10692. temp.Coefficient = item.coefficient;
  10693. DateTime dtCrt;
  10694. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  10695. if (b1)
  10696. {
  10697. temp.CreateTime = dtCrt;
  10698. }
  10699. else
  10700. {
  10701. temp.CreateTime = DateTime.Now;
  10702. }
  10703. temp.CreateUserId = item.Operators;
  10704. temp.DeleteTime = "";
  10705. temp.DeleteUserId = 0;
  10706. temp.DiId = int.Parse(item.DIID);
  10707. temp.FilePath = item.FilePath;
  10708. temp.IsDel = item.IsDel;
  10709. temp.Price = item.Price;
  10710. temp.PriceCount = 1;
  10711. temp.PriceCurrency = item.Currency;
  10712. int detailId = 0;
  10713. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  10714. {
  10715. detailId = dicDetail[item.PriceTypeDetail];
  10716. }
  10717. temp.PriceDetailType = detailId;
  10718. temp.PriceDt = DateTime.Now;
  10719. temp.PriceName = item.PriceName;
  10720. temp.PriceSum = item.Price;
  10721. int tid = 0;
  10722. if (dic.ContainsKey(item.PriceType))
  10723. {
  10724. tid = dic[item.PriceType];
  10725. }
  10726. temp.PriceType = tid;
  10727. temp.Remark = item.Remark;
  10728. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  10729. }
  10730. return Ok(JsonView(true, "操作成功!"));
  10731. }
  10732. }
  10733. }